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 --- ...edbuffer-resource-struct-recursive-mutual.slang | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang (limited to 'tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang') diff --git a/tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang b/tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang new file mode 100644 index 000000000..ac9449965 --- /dev/null +++ b/tests/diagnostics/structuredbuffer-resource-struct-recursive-mutual.slang @@ -0,0 +1,34 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv + +struct MutualB +{ + //CHECK-DAG: ([[# @LINE+1]]): error 38205 + StructuredBuffer aBuffer; +} + +struct MutualA +{ + //CHECK-DAG: ([[# @LINE+1]]): error 38205 + StructuredBuffer bBuffer; +} + +StructuredBuffer mutualRoot; +RWStructuredBuffer output; + +// External function to force consumption of recursive types +float consumeMutual(MutualA a, MutualB b); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint i = dispatchThreadID.x; + + float result = 0; + // Force usage of mutual recursion + MutualA a = mutualRoot[i]; + MutualB b = a.bBuffer[0]; + result += consumeMutual(a, b); + + output[i] = result; +} + -- cgit v1.2.3