From ebfb8d0428b12d3a6cd6de8ebeb13297004cfbe8 Mon Sep 17 00:00:00 2001 From: "James Helferty (NVIDIA)" Date: Thu, 3 Jul 2025 17:06:53 -0400 Subject: Fix for mixed block/embedded usage of structs in SPIRV (#7608) * Add test for mixed use of uniform/ParameterBlock Adds a test that uses the same struct as a parameter and as a ParameterBlock. * Fix for SPIRV block declaration issue Fixes #7431 * Fix formatting * Collect struct param usage in first pass Reduces number of iterations over the entire program. * more formatting fixes * formatting * Remove unused variable --- tests/bugs/gh-7431.slang | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/bugs/gh-7431.slang (limited to 'tests/bugs') diff --git a/tests/bugs/gh-7431.slang b/tests/bugs/gh-7431.slang new file mode 100644 index 000000000..d6c8ff342 --- /dev/null +++ b/tests/bugs/gh-7431.slang @@ -0,0 +1,37 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECKOUT):-vk -compute -output-using-type + +// CHECKOUT: 10 +// CHECKOUT-NEXT: 20 +// CHECKOUT-NEXT: 30 +// CHECKOUT-NEXT: 40 + +struct Test { + int f_int; +}; + +ParameterBlock pb_struct; +uniform Test u_struct; +uniform Test u_struct_array[2]; + +RWStructuredBuffer results; + +//TEST_INPUT: set pb_struct = new Test{10}; +//TEST_INPUT: uniform(data=[20 0 0 0]):name=u_struct.f_int +//TEST_INPUT: uniform(data=[30 0 0 0]):name=u_struct_array[0].f_int +//TEST_INPUT: uniform(data=[40 0 0 0]):name=u_struct_array[1].f_int + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=results + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain(uint3 tid: SV_DispatchThreadID) +{ + if (any(tid != uint3(0))) + return; + + results[0] = pb_struct.f_int; + results[1] = u_struct.f_int; + results[2] = u_struct_array[0].f_int; + results[3] = u_struct_array[1].f_int; +} + -- cgit v1.2.3