summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorMukund Keshava <mkeshava@nvidia.com>2025-04-30 16:07:02 +0530
committerGitHub <noreply@github.com>2025-04-30 10:37:02 +0000
commitb0e150511a6a536c8ad9e74910b30ae179a10ec9 (patch)
treecb749d757e0e556d987d6a30020971ed5a6aa41d /tests/compute
parent41ac7a0d8b4e9c08eccc2153020900e0262cae84 (diff)
Add subscript operator support in cuda (#6830)
* cuda: Add support for subscript operator This CL adds support for the subscript operator for Read Only textures in cuda. Also adds a test for this. Fixes #6781 * format code * fix review comments * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/texture-subscript-cuda.slang61
-rw-r--r--tests/compute/texture-subscript-cuda.slang.expected.txt7
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/compute/texture-subscript-cuda.slang b/tests/compute/texture-subscript-cuda.slang
new file mode 100644
index 000000000..e64f42b19
--- /dev/null
+++ b/tests/compute/texture-subscript-cuda.slang
@@ -0,0 +1,61 @@
+// Test for verifying subscript operator support in cuda.
+
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
+//TEST_INPUT: Texture1D(size=4, content = one):name cudaT1D
+Texture1D<float> cudaT1D;
+//TEST_INPUT: Texture2D(size=8, content = one):name cudaT2D
+Texture2D<float> cudaT2D;
+//TEST_INPUT: Texture3D(size=8, content = one):name cudaT3D
+Texture3D<float> cudaT3D;
+//TEST_INPUT: TextureCube(size=16, content = one):name cudaTCube
+TextureCube<float> cudaTCube;
+//TEST_INPUT: Texture2D(size=16, content = one, arrayLength=3):name cudaT2DArray
+Texture2DArray<float> cudaT2DArray;
+//TEST_INPUT: TextureCube(size=16, content = one, arrayLength=1):name cudaTCubeArray
+TextureCubeArray<float> cudaTCubeArray;
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0], stride=4):out,name cudaOutputBuffer
+RWStructuredBuffer<float> cudaOutputBuffer;
+
+[numthreads(7, 1, 1)]
+[shader("compute")]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ switch (idx)
+ {
+ case 1:
+ {
+ int var = 0;
+ float result = cudaT1D[0];
+ // This is not supported in PTX.
+ //cudaOutputBuffer[idx] = result;
+ }
+ break;
+
+ case 2:
+ {
+ int2 var = int2(1, 2);
+ float result = cudaT2D[var];
+ cudaOutputBuffer[idx] = result;
+ }
+ break;
+
+ case 3:
+ {
+ int3 var = int3(1, 1, 1);
+ float result = cudaT3D[var];
+ cudaOutputBuffer[idx] = result;
+ }
+ break;
+
+ case 4:
+ {
+ int3 var = int3(0, 0, 1);
+ float result = cudaT2DArray[var];
+ cudaOutputBuffer[idx] = result;
+ }
+ break;
+ }
+} \ No newline at end of file
diff --git a/tests/compute/texture-subscript-cuda.slang.expected.txt b/tests/compute/texture-subscript-cuda.slang.expected.txt
new file mode 100644
index 000000000..133a47e56
--- /dev/null
+++ b/tests/compute/texture-subscript-cuda.slang.expected.txt
@@ -0,0 +1,7 @@
+0
+0
+3F800000
+3F800000
+3F800000
+0
+0 \ No newline at end of file