From b3b6c44cb8b8ebc413d41f9ca3833d8242f3c805 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 21 Feb 2024 12:22:31 -0800 Subject: Fix SPIRV lowering issue. (#3608) * Fix SPIRV pointer lowering issue. Fixes #3605. * Add another pointer test. Fixes #3601. * Fixes #3600. * Fix #3595. --- tests/spirv/namespace-texture-array.slang | 20 ++++++++++++++++++++ tests/spirv/pointer-bug.slang | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/spirv/namespace-texture-array.slang create mode 100644 tests/spirv/pointer-bug.slang (limited to 'tests/spirv') diff --git a/tests/spirv/namespace-texture-array.slang b/tests/spirv/namespace-texture-array.slang new file mode 100644 index 000000000..b9dff510f --- /dev/null +++ b/tests/spirv/namespace-texture-array.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly +struct ComputePush +{ + uint image_id; +}; +[[vk::push_constant]] ComputePush p; + +namespace test_namespace +{ + [[vk::binding(0, 0)]] RWTexture2D textureTable[]; +} + +// CHECK: OpEntryPoint + +[shader("compute")] +[numthreads(8, 8, 1)] +void main(uint3 pixel_i : SV_DispatchThreadID) +{ + test_namespace.textureTable[p.image_id][pixel_i.xy] = float4(0,1,0,0); +} \ No newline at end of file diff --git a/tests/spirv/pointer-bug.slang b/tests/spirv/pointer-bug.slang new file mode 100644 index 000000000..1668cec13 --- /dev/null +++ b/tests/spirv/pointer-bug.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly +struct Foo { + float4 *positions; +}; + +struct Params { + Foo *foo; +}; + +// CHECK: %_ptr_PhysicalStorageBuffer_Foo = OpTypePointer PhysicalStorageBuffer %Foo + +[[vk::push_constant]] Params params; + +[shader("compute")] +[numthreads(1,1,1)] +void main() { + params.foo.positions[10] += float4(1, 1, 1, 1); +} \ No newline at end of file -- cgit v1.2.3