From: Jason Ekstrand Date: Tue, 7 Jan 2020 18:01:13 +0000 (-0600) Subject: spirv: Add output memory semantics to OpControlBarrier in TCS X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a4125b4d261df39189f67dffaa5c90c0f6f66fe6;p=mesa.git spirv: Add output memory semantics to OpControlBarrier in TCS Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 42895b542ff..2ed2bf34875 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2106,9 +2106,6 @@ vtn_emit_scoped_memory_barrier(struct vtn_builder *b, SpvScope scope, if (semantics & SpvMemorySemanticsWorkgroupMemoryMask) modes |= nir_var_mem_shared; if (semantics & SpvMemorySemanticsOutputMemoryMask) { - vtn_fail_if(!b->options->caps.vk_memory_model, - "To use Output memory semantics, the VulkanMemoryModel " - "capability must be declared."); modes |= nir_var_shader_out; } @@ -3619,6 +3616,10 @@ vtn_emit_memory_barrier(struct vtn_builder *b, SpvScope scope, case SpvMemorySemanticsImageMemoryMask: vtn_emit_barrier(b, nir_intrinsic_memory_barrier_image); break; + case SpvMemorySemanticsOutputMemoryMask: + if (b->nb.shader->info.stage == MESA_SHADER_TESS_CTRL) + vtn_emit_barrier(b, nir_intrinsic_memory_barrier_tcs_patch); + break; default: break;; } @@ -3691,6 +3692,23 @@ vtn_handle_barrier(struct vtn_builder *b, SpvOp opcode, SpvMemorySemanticsWorkgroupMemoryMask; } + /* From the SPIR-V spec: + * + * "When used with the TessellationControl execution model, it also + * implicitly synchronizes the Output Storage Class: Writes to Output + * variables performed by any invocation executed prior to a + * OpControlBarrier will be visible to any other invocation after + * return from that OpControlBarrier." + */ + if (b->nb.shader->info.stage == MESA_SHADER_TESS_CTRL) { + memory_semantics &= ~(SpvMemorySemanticsAcquireMask | + SpvMemorySemanticsReleaseMask | + SpvMemorySemanticsAcquireReleaseMask | + SpvMemorySemanticsSequentiallyConsistentMask); + memory_semantics |= SpvMemorySemanticsAcquireReleaseMask | + SpvMemorySemanticsOutputMemoryMask; + } + vtn_emit_memory_barrier(b, memory_scope, memory_semantics); if (execution_scope == SpvScopeWorkgroup)