From d161d97681937f0546eb8835cf9e497cb1b4369c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 3 Dec 2018 14:57:19 -0800 Subject: Add Vulkan translations for HLSL barrier operations (#737) Fixes #730 The most basic of these already had translations added, and the Slang approach to cross-compilation made adding the new ones almost trivial. I also took the time to confirm that using "operator comma" for the sequencing (since the single HLSL function call needs to expand to a sequence of GLSL function calls) works fine with glslang. I added a test case to confirm that all of these operations can compile down to SPIR-V. I am not personally confident that these translations are perfect, but they are based on what was [linked](https://anteru.net/blog/2016/mapping-between-hlsl-and-glsl/index.html) from #730. The one difference is where that blog post was listing `memoryBarrierImage, memoryBarrierImage` I assumed they meant `memoryBarrierImage, memoryBarrierBuffer`. --- tests/cross-compile/barriers.slang | 14 ++++++++++++++ tests/cross-compile/barriers.slang.glsl | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/cross-compile/barriers.slang create mode 100644 tests/cross-compile/barriers.slang.glsl (limited to 'tests') diff --git a/tests/cross-compile/barriers.slang b/tests/cross-compile/barriers.slang new file mode 100644 index 000000000..f6fb9ac3c --- /dev/null +++ b/tests/cross-compile/barriers.slang @@ -0,0 +1,14 @@ +//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage compute + +// Confirm that all HLSL barrier operations can be used when cross-compiling. + +[numthreads(1,1,1)] +void main() +{ + AllMemoryBarrier(); + AllMemoryBarrierWithGroupSync(); + DeviceMemoryBarrier(); + DeviceMemoryBarrierWithGroupSync(); + GroupMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); +} diff --git a/tests/cross-compile/barriers.slang.glsl b/tests/cross-compile/barriers.slang.glsl new file mode 100644 index 000000000..281e684db --- /dev/null +++ b/tests/cross-compile/barriers.slang.glsl @@ -0,0 +1,14 @@ +#version 450 + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() +{ + (memoryBarrier(), groupMemoryBarrier(), memoryBarrierImage(), memoryBarrierBuffer()); + (memoryBarrier(), groupMemoryBarrier(), memoryBarrierImage(), memoryBarrierBuffer(), barrier()); + (memoryBarrier(), memoryBarrierImage(), memoryBarrierBuffer()); + (memoryBarrier(), memoryBarrierImage(), memoryBarrierBuffer(), barrier()); + groupMemoryBarrier(); + (groupMemoryBarrier(), barrier()); + + return; +} -- cgit v1.2.3