From 1dcd814f5038229703e52841b1b0304c22bffb73 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 10 May 2024 09:41:31 -0700 Subject: More Metal Intrinsics. (#4143) --- tests/glsl-intrinsic/intrinsic-basic.slang | 2 -- tests/metal/barrier.slang | 18 ++++++++++++++++++ tests/metal/discard.slang | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/metal/barrier.slang create mode 100644 tests/metal/discard.slang (limited to 'tests') diff --git a/tests/glsl-intrinsic/intrinsic-basic.slang b/tests/glsl-intrinsic/intrinsic-basic.slang index d374f0f84..6bd4e7fe0 100644 --- a/tests/glsl-intrinsic/intrinsic-basic.slang +++ b/tests/glsl-intrinsic/intrinsic-basic.slang @@ -2,8 +2,6 @@ //TEST:SIMPLE(filecheck=CHECK_GLSL_SPIRV): -allow-glsl -stage compute -entry computeMain -target spirv //TEST:SIMPLE(filecheck=CHECK_SPIR): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly //TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DTARGET_CUDA -//TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-via-glsl //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-directly diff --git a/tests/metal/barrier.slang b/tests/metal/barrier.slang new file mode 100644 index 000000000..86e4265be --- /dev/null +++ b/tests/metal/barrier.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHECK): -target metal +//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib + +// CHECK: threadgroup_barrier + +// CHECK-ASM: define void @computeMain + +RWStructuredBuffer outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + outputBuffer[0] = 1; + GroupMemoryBarrierWithGroupSync(); + outputBuffer[1] = 2; + AllMemoryBarrierWithGroupSync(); + outputBuffer[2] = 3; +} \ No newline at end of file diff --git a/tests/metal/discard.slang b/tests/metal/discard.slang new file mode 100644 index 000000000..7c2622561 --- /dev/null +++ b/tests/metal/discard.slang @@ -0,0 +1,22 @@ +//TEST:SIMPLE(filecheck=CHECK): -target metal +//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib + +// CHECK: discard_fragment(); + +// CHECK-ASM: define {{.*}} @main_fragment1 + +struct VOut +{ + float4 position : SV_Position; + float4 vertexColor; + float2 vertexUV; + float3 vertexNormal : NORMAL; +} + +[shader("fragment")] +float4 main_fragment1(VOut fragmentIn) +{ + if (fragmentIn.vertexColor.x == 0.0) + discard; + return fragmentIn.vertexColor; +} \ No newline at end of file -- cgit v1.2.3