From 0754abee603c1afa7803a444124acc9d268d2f0a Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 12 Nov 2024 21:01:47 -0800 Subject: Push buffer load to end of access chain. (#5544) * Push buffer load to end of access chain. * Update test. * Fix. * Fix. * Fix. * Make more robust. * Fix. --- tests/spirv/sb-load-2.slang | 23 +++++++++++++++++++++++ tests/spirv/sb-load.slang | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/spirv/sb-load-2.slang create mode 100644 tests/spirv/sb-load.slang (limited to 'tests') diff --git a/tests/spirv/sb-load-2.slang b/tests/spirv/sb-load-2.slang new file mode 100644 index 000000000..b4c10cb4a --- /dev/null +++ b/tests/spirv/sb-load-2.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry main -stage compute + +struct Test1 +{ + float2x3 a; // 24B + float3x4 b; // 48B + float16_t3x2 c; // 12B + float16_t2x4 d; // 16B +}; + +StructuredBuffer dp; +RWStructuredBuffer outputBuffer; + +// CHECK-COUNT-2: unpackStorage +// CHECK-NOT: unpackStorage +[numthreads(4, 4, 1)] +void main(uint3 GTid : SV_GroupThreadID, + uint GI : SV_GroupIndex) +{ + var tmp = dp[0]; + var rs = tmp.a[0][0] + tmp.a[0][1]; + outputBuffer[GI] = float4(rs); +} \ No newline at end of file diff --git a/tests/spirv/sb-load.slang b/tests/spirv/sb-load.slang new file mode 100644 index 000000000..1b0df0be8 --- /dev/null +++ b/tests/spirv/sb-load.slang @@ -0,0 +1,24 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +#define FILL_PATTERN_DIMENSIONS_X 16 +#define FILL_PATTERN_DIMENSIONS_Y 16 + +struct FillPatternBuffer +{ + float4 px[FILL_PATTERN_DIMENSIONS_Y][FILL_PATTERN_DIMENSIONS_X]; +}; + +StructuredBuffer dp; +RWStructuredBuffer outputBuffer; + +// CHECK-NOT: OpCompositeConstruct + +[numthreads(4, 4, 1)] +void main(uint3 GTid : SV_GroupThreadID, + uint GI : SV_GroupIndex) +{ + const uint ii = GTid.x; + const uint jj = GTid.y; + const float4 pmv = dp[0].px[ii][jj]; + outputBuffer[GI] = pmv; +} \ No newline at end of file -- cgit v1.2.3