summaryrefslogtreecommitdiff
path: root/tests/metal/texture-write.slang
diff options
context:
space:
mode:
authorJames Helferty (NVIDIA) <jhelferty@nvidia.com>2025-09-30 14:21:27 -0400
committerGitHub <noreply@github.com>2025-09-30 18:21:27 +0000
commit8086adc90b69f3199767c0617e2c429ce6b27f67 (patch)
treecbc54d5dbb3ad13329abc49f3aabf25ee199b7d6 /tests/metal/texture-write.slang
parentee5adb87050ae7c0b96056a67dddc5d48174e695 (diff)
Enable metal tests (#8446)
Enables all tests/metal/ tests that can be easily enabled. These tests were not originally designed as render tests; they are generally being enabled for pipecleaning purposes, and will not be rigorously testing the corresponding funcitonality. Where they cannot be enabled as render tests, and a metallib test wasn't already enabled, a metallib test was enabled instead (where possible). Fixes #7892
Diffstat (limited to 'tests/metal/texture-write.slang')
-rw-r--r--tests/metal/texture-write.slang63
1 files changed, 38 insertions, 25 deletions
diff --git a/tests/metal/texture-write.slang b/tests/metal/texture-write.slang
index 7967e1d16..48f5dfa6b 100644
--- a/tests/metal/texture-write.slang
+++ b/tests/metal/texture-write.slang
@@ -1,26 +1,32 @@
-//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE
-//TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib
+//DISABLE_TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE
+//DISABLE_TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib
+//DISABLE_TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type
+
+// Test framework has issues with RWTexture2D on Metal
+// TODO: github issue #8454
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float4> outputBuffer;
+
// for some reason, metal textures dont have an overload for less-than-four component
// writes, they need to be converted to 4-components in a legalize step, as the other components
// get discarded
+
+//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero):name pWrites.tex1
+//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero):name pWrites.tex2
+//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero):name pWrites.tex4
+//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero, arrayLength=2):name pWrites.tex1Array
+//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero, arrayLength=2):name pWrites.tex2Array
+//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero, arrayLength=2):name pWrites.tex4Array
struct TextureWrite
{
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32
RWTexture2D<float> tex1;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v2
RWTexture2D<float2> tex2;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v3
- RWTexture2D<float3> tex3;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v4
RWTexture2D<float4> tex4;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32
RWTexture2DArray<float> tex1Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v2
RWTexture2DArray<float2> tex2Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v3
- RWTexture2DArray<float3> tex3Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v4
RWTexture2DArray<float4> tex4Array;
}
ParameterBlock<TextureWrite> pWrites;
@@ -31,27 +37,34 @@ void computeMain()
// TODO: check for the type of first parameter to be a 4-component vector
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex1[uint2(1, 1)] = 1;
- // METALLIB: call {{.*}}.write_texture_2d.v4f32(
- // METAL: .write(
- pWrites.tex2[uint2(2, 2)] = float2(1, 2);
+ pWrites.tex1[uint2(0, 0)] = float(1);
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex3[uint2(3, 3)] = float3(1, 2, 3);
+ pWrites.tex2[uint2(1, 1)] = float2(1, 2);
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex4[uint2(4, 4)] = float4(1, 2, 3, 4);
+ pWrites.tex4[uint2(3, 3)] = float4(1, 2, 3, 4);
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex1Array[uint3(1, 1, 1)] = 1;
- // METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
- // METAL: .write(
- pWrites.tex2Array[uint3(2, 2, 2)] = float2(1, 2);
+ pWrites.tex1Array[uint3(0, 0, 0)] = 1;
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex3Array[uint3(3, 3, 3)] = float3(1, 2, 3);
+ pWrites.tex2Array[uint3(1, 1, 0)] = float2(1, 2);
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex4Array[uint3(4, 4, 4)] = float4(1, 2, 3, 4);
-} \ No newline at end of file
+ pWrites.tex4Array[uint3(3, 3, 0)] = float4(1, 2, 3, 4);
+
+ // BUF: 6.000000
+ // BUF: 8.000000
+ // BUF: 6.000000
+ // BUF: 8.000000
+ outputBuffer[0] = float4(0)
+ + float4(pWrites.tex1[uint2(0, 0)], 0, 0, 0)
+ + float4(pWrites.tex2[uint2(1, 1)], 0, 0)
+ + float4(pWrites.tex4[uint2(3, 3)])
+ + float4(pWrites.tex1Array[uint3(0, 0, 0)], 0, 0, 0)
+ + float4(pWrites.tex2Array[uint3(1, 1, 0)], 0, 0)
+ + float4(pWrites.tex4Array[uint3(3, 3, 0)])
+ ;
+}