spirv: Add output memory semantics to OpControlBarrier in TCS

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
This commit is contained in:
Jason Ekstrand 2020-01-07 12:01:13 -06:00 committed by Marge Bot
parent 2365520c9d
commit a4125b4d26
1 changed files with 21 additions and 3 deletions

View File

@ -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)