diff options
author | Dave Airlie <[email protected]> | 2019-08-27 12:50:35 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-09-04 15:22:20 +1000 |
commit | 83597ad3f2c157733f9a1bc81242b7e2b7026c9b (patch) | |
tree | 03f214c50c6b6b20abcc5fa5178b66f4b460c7d6 /src | |
parent | 1b24e3ba756ba4951086d0b1b351364acbd3af1d (diff) |
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 5 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index ce042a1c708..9d6dfaa390c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -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; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index ef711b48d66..1f42c4ef549 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -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" @@ -3896,6 +3897,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, struct lp_build_tgsi_context * bld_base, @@ -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 |