From a766d27447aa0fcf69334c0467d9b1124892e180 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 4 Sep 2025 04:05:26 +0800 Subject: Diagnose on structured buffers containing resources (#8222) closes https://github.com/shader-slang/slang/issues/3313 --- .../structuredbuffer-resource-struct-array.slang | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/diagnostics/structuredbuffer-resource-struct-array.slang (limited to 'tests/diagnostics/structuredbuffer-resource-struct-array.slang') diff --git a/tests/diagnostics/structuredbuffer-resource-struct-array.slang b/tests/diagnostics/structuredbuffer-resource-struct-array.slang new file mode 100644 index 000000000..891a63b07 --- /dev/null +++ b/tests/diagnostics/structuredbuffer-resource-struct-array.slang @@ -0,0 +1,27 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv + +struct HasResource +{ + Texture2D tex; +} + +//CHECK-DAG: ([[# @LINE+1]]): error 38204 +StructuredBuffer bufferArray[4]; + +//CHECK-DAG: ([[# @LINE+1]]): error 38204 +RWStructuredBuffer rwBufferArray[2]; + +SamplerState sampler; +RWStructuredBuffer output; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint i = dispatchThreadID.x; + + // Force usage of all array elements and struct members + float result = bufferArray[i % 4][i].tex.Sample(sampler, float2(0, 0)).x; + rwBufferArray[i % 2][i] = bufferArray[0][i].tex; + output[i] = result; +} + -- cgit v1.2.3