From: Dave Airlie Date: Tue, 27 Aug 2019 02:50:35 +0000 (+1000) Subject: gallivm: add barrier support for compute shaders. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83597ad3f2c157733f9a1bc81242b7e2b7026c9b;p=mesa.git 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 --- 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" @@ -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