From dd25e37363dee6edf1a80df7d983872e14a67110 Mon Sep 17 00:00:00 2001 From: LICObr Date: Tue, 24 Nov 2026 20:20:07 -0300 Subject: [PATCH] Shader tests: heap buffer views are raw, as the host makes them The shader reads a heap buffer by element as the hardware does: element times the view's stride (the host's table) plus the offset, as a raw byte-address load. `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` bound a structured view there instead (stride 12 and 16). A raw load through a structured view is outside what DXIL defines: WARP and AMD read the byte address, NVIDIA applies the view's stride on top and reads the wrong elements (#1835). The host makes every heap buffer view raw (`descriptor/host.rs`), so the tests now bind raw views, and check what runs in the game. --- crates/victory-shader/src/emit/stride_tests.rs | 4 +++- crates/victory-shader/src/emit/synthetic_tests.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/victory-shader/src/emit/stride_tests.rs b/crates/victory-shader/src/emit/stride_tests.rs index fc160f5f98..3ca62bd4a0 100644 --- a/crates/victory-shader/src/emit/stride_tests.rs +++ b/crates/victory-shader/src/emit/stride_tests.rs @@ -240,11 +240,13 @@ fn a_heap_buffer_read_by_element_takes_the_views_stride() { assert_eq!(shader.root_srvs, [VIEW_STRIDES]); // 32 elements of 12 bytes: (100 + e, 200 + e, 300 + e). let data: Vec = (0..32).flat_map(|e| [100 + e, 200 + e, 300 + e]).collect(); + // A raw view, as the host makes every heap buffer view: the shader + // reads it by byte address, the stride coming from the table alone. let views = [ View::RawUav(32), View::Buffer { data: &data, - stride: Stride::Structured(12), + stride: Stride::Raw, }, ]; let _one = super::valu_tests::ONE_AT_A_TIME diff --git a/crates/victory-shader/src/emit/synthetic_tests.rs b/crates/victory-shader/src/emit/synthetic_tests.rs index 990a3e5942..799d1ed25c 100644 --- a/crates/victory-shader/src/emit/synthetic_tests.rs +++ b/crates/victory-shader/src/emit/synthetic_tests.rs @@ -207,9 +207,10 @@ fn gathers_at_a_level_match_the_hardware() { } let views = [ View::Mipped(24, 16, 4, &texels), + // Read by byte address (`offen`): a raw view, as the host makes. View::Buffer { data: &input, - stride: Stride::Structured(16), + stride: Stride::Raw, }, View::RawUav(32 * 12), ];