Skip to content

[Upstream #1939/#3351] Align scalar loads and bound code-table reads - #221

Open
vanya890 wants to merge 8 commits into
devfrom
agent/gpt6-smem-code-table-218
Open

vanya890 wants to merge 8 commits into
devfrom
agent/gpt6-smem-code-table-218

Conversation

@vanya890

@vanya890 vanya890 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Port the scalar-memory correctness work from upstream Marvisak#1939 and Marvisak#3351 as one coherent change to Lower::smem.

  • Independently DWORD-align the immediate OFFSET and SGPR SOFFSET before adding them, matching the RDNA2 SMEM address-component rules and upstream hardware readback.
  • Enforce code-table descriptor NUM_RECORDS * max(stride, 1) bounds for every dword of s_buffer_load_dword*, returning zero for each out-of-range element, including wide loads.
  • Include the dynamic PC-relative term returned by built_offset(src) in the bounds predicate. When combining it with SOFFSET, detect unsigned addition overflow and treat it as out-of-range. This addresses the P1 review finding on upstream Shaders: scalar code-table buffer loads keep NUM_RECORDS Marvisak/VIctory#3351 rather than copying that hunk verbatim.
  • Preserve the combined constant base offset in the non-code-table constant-read path.
  • Add readback cases for unaligned SOFFSET=0xe + immediate 2, dynamic descriptor extra 0/4/20, extra-only bounds, and an unsigned-overflowing dynamic extra.

Upstream provenance

Regression coverage

  • s_buffer_load_truncates_terms_independently: hardware/WARP readback for unaligned immediate and SGPR offsets.
  • scalar_buffer_loads_of_a_code_table_read_zero_past_num_records: stride 0/1/4, static bounds and wide-load per-dword zeroing.
  • scalar_buffer_loads_of_a_code_table_keep_num_records_with_stride_and_soffset: unaligned terms, dynamic descriptor extra 0/4/20, extra-only bound, and overflow rejection.

The GPU readback tests require WARP: they explicitly construct Host::new(true) and panic if the WARP adapter is unavailable. Hardware execution is also tested when a hardware adapter is present; it is not required for CI success.

Integration and validation

  • Base: dev 539687eaaeebced7cdce26a62d92a732adc5c963.
  • Branch: agent/gpt6-smem-code-table-218.
  • Exact head: 8653fce3a17c6c34891398eb527d87e37f3de30f.
  • lower.rs: 523,465 UTF-8 bytes, 823 bytes under the 524,288-byte repository policy cap; exact-head repository_passes_policy passed.
  • Exact-head Windows CI 45890346557 passed: coordination checks, default Clippy, diagnostics Clippy/build, and full workspace tests.
  • victory-shader: 320 passed / 0 failed / 3 ignored. victory-gpu: 297 passed / 0 failed / 1 ignored.
  • All three targeted shader regressions passed. The test code requires successful Host::new(true), so WARP was actually exercised; the run also reports emit::host::tests::parallel_warp_pipelines_and_draws passing.
  • No local hardware result or retail-game compatibility claim is made.

Ready for maintainer review. No merge performed.

@vanya890
vanya890 marked this pull request as ready for review November 26, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant