Mesa (master): spirv: Add output memory semantics to OpControlBarrier in TCS
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jan 13 17:51:20 UTC 2020
Module: Mesa
Branch: master
Commit: a4125b4d261df39189f67dffaa5c90c0f6f66fe6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a4125b4d261df39189f67dffaa5c90c0f6f66fe6
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Tue Jan 7 12:01:13 2020 -0600
spirv: Add output memory semantics to OpControlBarrier in TCS
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
---
src/compiler/spirv/spirv_to_nir.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
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)
More information about the mesa-commit
mailing list