From 4412a8365525e300e639df877339e4d0a2c2a316 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 10 Apr 2025 20:31:25 +0200 Subject: [PATCH] tests: Create structured buffers with the appropriate stride. The stride didn't match the structure size used in the shader. This didn't seem to be a problem on AMD and WARP, but it was on NVIDIA on Windows. Specifically, it seems that the buffer is read using the shader structure size (so most tests pass), but bounds are checked using the buffer stride, so a test returned zero simply because an out-of-bounds read was detected. --- tests/hlsl/srv-structuredbuffer.shader_test | 55 ++++++++++++--------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/tests/hlsl/srv-structuredbuffer.shader_test b/tests/hlsl/srv-structuredbuffer.shader_test index bf815123f..2225a0ee4 100644 --- a/tests/hlsl/srv-structuredbuffer.shader_test +++ b/tests/hlsl/srv-structuredbuffer.shader_test @@ -21,6 +21,38 @@ float4 main() : sv_target todo(sm<6) draw quad probe (0, 0) rgba(0.0, 1.0, 2.0, 3.0) +[pixel shader todo] +struct banana +{ + float2 x; + float2 y; +}; + +uniform uint idx; +StructuredBuffer buffer; + +float4 main() : sv_target +{ + return float4(buffer[idx].x, buffer[idx].y); +} + +[test] +uniform 0 uint 0 +todo(sm<6) draw quad +probe (0, 0) rgba(0.0, 1.0, 2.0, 3.0) +uniform 0 uint 1 +todo(sm<6) draw quad +probe (0, 0) rgba(4.0, 5.0, 6.0, 7.0) + +[srv 0] +stride 12 +size (buffer, 5) +0.0 1.0 2.0 +3.0 4.0 5.0 +6.0 7.0 8.0 +9.0 10.0 11.0 +12.0 13.0 14.0 + % Structured buffers are tightly packed. [pixel shader todo] uniform uint idx; @@ -67,29 +99,6 @@ uniform 0 uint 4 todo(sm<6) draw quad probe (0, 0) rgba(12.0, 13.0, 14.0, 4.0) -[pixel shader todo] -struct banana -{ - float2 x; - float2 y; -}; - -uniform uint idx; -StructuredBuffer buffer; - -float4 main() : sv_target -{ - return float4(buffer[idx].x, buffer[idx].y); -} - -[test] -uniform 0 uint 0 -todo(sm<6) draw quad -probe (0, 0) rgba(0.0, 1.0, 2.0, 3.0) -uniform 0 uint 1 -todo(sm<6) draw quad -probe (0, 0) rgba(4.0, 5.0, 6.0, 7.0) - % Matrices [srv 0]