diff options
| author | Mukund Keshava <mkeshava@nvidia.com> | 2025-04-30 16:07:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 10:37:02 +0000 |
| commit | b0e150511a6a536c8ad9e74910b30ae179a10ec9 (patch) | |
| tree | cb749d757e0e556d987d6a30020971ed5a6aa41d /tests | |
| parent | 41ac7a0d8b4e9c08eccc2153020900e0262cae84 (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')
3 files changed, 73 insertions, 11 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 diff --git a/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang index 946ba4470..ccf834167 100644 --- a/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang +++ b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang @@ -1,7 +1,7 @@ -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPRE -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPOST -//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPRE -//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPOST +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities // CHECK_IGNORE_CAPS-NOT: error 36107 // CHECK: error 36107 @@ -11,11 +11,5 @@ Texture2D<int> rw; [numthreads(1,1,1)] void computeMain() { -#ifdef PRE - rw.Load(0); -#endif - clip(0.0f); -#ifdef POST - rw.Load(0); -#endif + clip(0.0f); // clip is not supported in compute shader, so this throws an error. }
\ No newline at end of file |
