gallivm: add barrier support for compute shaders.

When the code is executing an hits a barrier, it will suspend
the coroutine and return control to the coroutine dispatcher.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
Dave Airlie 2019-08-27 12:50:35 +10:00
parent 1b24e3ba75
commit 83597ad3f2
2 changed files with 23 additions and 1 deletions

View file

@ -67,7 +67,7 @@ struct lp_build_mask_context;
struct gallivm_state;
struct lp_derivatives;
struct lp_build_tgsi_gs_iface;
struct lp_build_coro_suspend_info;
enum lp_build_tex_modifier {
LP_BLD_TEX_MODIFIER_NONE = 0,
@ -252,6 +252,7 @@ struct lp_build_tgsi_params {
LLVMValueRef ssbo_sizes_ptr;
const struct lp_build_image_soa *image;
LLVMValueRef shared_ptr;
const struct lp_build_coro_suspend_info *coro;
};
void
@ -486,6 +487,8 @@ struct lp_build_tgsi_soa_context
LLVMValueRef shared_ptr;
const struct lp_build_coro_suspend_info *coro;
const struct lp_build_sampler_soa *sampler;
const struct lp_build_image_soa *image;

View file

@ -60,6 +60,7 @@
#include "lp_bld_misc.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_flow.h"
#include "lp_bld_coro.h"
#include "lp_bld_quad.h"
#include "lp_bld_tgsi.h"
#include "lp_bld_limits.h"
@ -3895,6 +3896,21 @@ atomic_emit(
}
}
static void
barrier_emit(
const struct lp_build_tgsi_action * action,
struct lp_build_tgsi_context * bld_base,
struct lp_build_emit_data * emit_data)
{
struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
struct gallivm_state * gallivm = bld_base->base.gallivm;
LLVMBasicBlockRef resume = lp_build_insert_new_block(gallivm, "resume");
lp_build_coro_suspend_switch(gallivm, bld->coro, resume, false);
LLVMPositionBuilderAtEnd(gallivm->builder, resume);
}
static void
membar_emit(
const struct lp_build_tgsi_action * action,
@ -4413,6 +4429,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.thread_data_ptr = params->thread_data_ptr;
bld.image = params->image;
bld.shared_ptr = params->shared_ptr;
bld.coro = params->coro;
/*
* If the number of temporaries is rather large then we just
@ -4513,6 +4530,8 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
bld.bld_base.op_actions[TGSI_OPCODE_ATOMIMAX].emit = atomic_emit;
bld.bld_base.op_actions[TGSI_OPCODE_MEMBAR].emit = membar_emit;
bld.bld_base.op_actions[TGSI_OPCODE_BARRIER].emit = barrier_emit;
if (params->gs_iface) {
/* There's no specific value for this because it should always
* be set, but apps using ext_geometry_shader4 quite often