summaryrefslogtreecommitdiffstats
path: root/tests/compute/texture-subscript.slang
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-06-26 09:37:18 -0400
committerGitHub <noreply@github.com>2024-06-26 09:37:18 -0400
commite1d0ef2002d7b0f459cf689ec1f8e37c4ff2afba (patch)
treeaf4ab4fdd522a26458b56d4e642962f086630b21 /tests/compute/texture-subscript.slang
parent969dd4cc7246bfe89103efcb00f399606e804e98 (diff)
Expand upon existing `ImageSubscript` support (Metal, GLSL, SPIRV) (#4408)
* Add additional `ImageSubscript` features: 1. Added ImageSubscript support for Metal & a test case * Merge GLSL/SPIRV/Metal `ImageSubscript` legalization pass 2. Added multisample support to glsl/spirv/metal for when using ImageSubscript * Added in this PR since the overhaul of the code merges together GLSL/SPIRV/Metal implementation 3. Fixed minor metal texture `Load`/`Read` bugs * [HLSL methods of access do not support subscript accessor for texture cube array](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texturecubearray) * removed swizzling of uint/int/float * other odd bugs which were causing compile errors note: Compute tests do not work due to what seems to be the GFX backend (causes crash without error report). The tests are disabled. * disable LOD with texture 1d seems that LOD for 1d textures need to be a compile time constant as per an error metal throws * syntax error in hlsl.meta * static_assert alone with intrinsic_asm error provides cleaner errors Note: `static_assert` seems to be unstable and not be fully respected (still require `intrinsic_asm` to avoid a stdlib compile error) * change comment to `// lod is not supported for 1D texture * add `static_assert` in related code gen paths * address review * address review * add asserts as per review comment, NOTE: unclear if these should be release 'asserts' as well
Diffstat (limited to 'tests/compute/texture-subscript.slang')
-rw-r--r--tests/compute/texture-subscript.slang58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/compute/texture-subscript.slang b/tests/compute/texture-subscript.slang
new file mode 100644
index 000000000..9251f49f1
--- /dev/null
+++ b/tests/compute/texture-subscript.slang
@@ -0,0 +1,58 @@
+//TEST:SIMPLE(filecheck=METAL): -target metal -entry computeMain -stage compute
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -entry computeMain -stage compute
+// Metal lacks RWTexture GFX backend support.
+// Due to this, Metal compute test is disabled
+//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -mtl
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk -glsl
+
+//METAL-NOT: error 41402
+//METALLIB: @computeMain
+
+//TEST_INPUT: RWTexture1D(format=R8G8B8A8_SINT, size=8, content = zero, mipMaps = 1):name outputTexture1D
+RWTexture1D<int4> outputTexture1D;
+
+//TEST_INPUT: RWTexture2D(format=R8G8B8A8_SINT, size=8, content = zero, mipMaps = 1):name outputTexture2D
+RWTexture2D<int4> outputTexture2D;
+
+//TEST_INPUT: RWTexture3D(format=R8G8B8A8_SINT, size=8, content = zero, mipMaps = 1):name outputTexture3D
+RWTexture3D<int4> outputTexture3D;
+
+//TEST_INPUT: RWTexture2D(format=R8G8B8A8_SINT, size=4, content = zero, arrayLength=2, mipMaps = 1):name outputTexture2DArray
+RWTexture2DArray<int4> outputTexture2DArray;
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ outputTexture1D[0].xz = int2(1,2).xx;
+ outputTexture1D[1].x = int2(3,4).y;
+
+ outputTexture2D[0].xz = int2(1,2).xx;
+ outputTexture2D[int2(0, 1)].x = int2(3,4).y;
+
+ outputTexture3D[0].xz = int2(1,2).xx;
+ outputTexture3D[int3(0, 0, 1)].x = int2(3,4).y;
+
+ outputTexture2DArray[0].xz = int2(1,2);
+ outputTexture2DArray[int3(0, 0, 1)].xz = int2(3,4);
+
+ outputBuffer[0] = uint(true
+ && all(outputTexture1D[0] == int4(1, 0, 1, 0)) == true
+ && all(outputTexture1D[1] == int4(4, 0, 0, 0)) == true
+
+ && all(outputTexture2D[0] == int4(1, 0, 1, 0)) == true
+ && all(outputTexture2D[int2(0, 1)] == int4(4, 0, 0, 0)) == true
+
+ && all(outputTexture3D[0] == int4(1, 0, 1, 0)) == true
+ && all(outputTexture3D[int3(0, 0, 1)] == int4(4, 0, 0, 0)) == true
+
+ && all(outputTexture2DArray[0] == int4(1, 0, 2, 0)) == true
+ && all(outputTexture2DArray[int3(0, 0, 1)] == int4(3, 0, 4, 0)) == true
+ );
+}
+
+//BUF: 1 \ No newline at end of file