Skip to content

test(shader): initialize Root UAV buffers before dispatch - #1912

Open
Damokles2 wants to merge 1 commit into
Marvisak:mainfrom
Damokles2:fix-shader-uav-bitmap-init
Open

Damokles2 wants to merge 1 commit into
Marvisak:mainfrom
Damokles2:fix-shader-uav-bitmap-init

Conversation

@Damokles2

Copy link
Copy Markdown

Summary

Explicitly initialize Root::Uav buffers in the shader test host before dispatch, ensuring deterministic contents for shaders that update page bitmaps using atomic OR.

The change is limited to the shader test host and a synthetic regression test. Production shader lowering and GPU runtime behavior are unchanged.

Changes

  • Initialize DEFAULT-heap UAV buffers to zero using an upload buffer and CopyBufferRegion.
  • Transition resources from COPY_DEST to UNORDERED_ACCESS before dispatch.
  • Preserve existing readback synchronization and retain upload resources through fence completion.
  • Add a synthetic regression that pre-fills the same 256-dword bitmap with nonzero values and verifies that only the three expected pages remain marked after dispatch.

Regression evidence

The seeded regression was tested with initialization deliberately disabled as a negative control:

  • Without initialization: 259 marked pages instead of 3 on both the default D3D12 device and WARP.
  • With initialization: exactly 3 expected pages on both paths.

This confirms that the test host clears pre-existing bitmap contents before shader execution.

Verification

  • Memory tests: 3 passed with default adapter selection.
  • Memory tests with VICTORY_WARP=1: 3 passed.
  • BVH tests with VICTORY_WARP=1: 14 passed.
  • BVH tests with default adapter selection: 11 passed, 3 failed. The three failures reproduce existing baseline 1-ULP floating-point mismatches and are unchanged by this patch.
  • Strict Clippy: passed on retry.
  • git diff --check: passed.
  • cargo fmt -p victory-shader -- --check: reports pre-existing formatting differences; no new formatter differences were introduced in the modified files.

The default D3D12 adapter model was not independently verified. An initial build attempt was blocked by Windows Application Control (OS error 4551), but the subsequent regular build and test runs succeeded without security-policy changes.

Related issue

Related to #1882.

This patch establishes deterministic UAV initialization and prevents stale bitmap bits from surviving into shader execution. Whether uninitialized contents caused the original intermittent failure reported in #1882 remains unconfirmed.

AI-assisted using OpenAI Codex.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 0ababf5: cargo test -p victory-shader --locked gives 244 passed, 3 failed, 3 ignored. The new dirty_page_bitmap_is_zeroed_before_dispatch passes. The 3 failures are #1744's NVIDIA ones on main (the two stride_tests heap-buffer reads and gathers_at_a_level_match_the_hardware), so there is nothing new on this hardware.

AI-assisted (Claude Code).

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.

2 participants