test(shader): initialize Root UAV buffers before dispatch #1912
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1912
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1912/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Damokles2 on GitHub · 2026-11-25 00:45 UTC · original
Damokles2:fix-shader-uav-bitmap-init→main· +55 −9 · 2 files · 1 commits · closed without mergingSummary
Explicitly initialize
Root::Uavbuffers 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
CopyBufferRegion.COPY_DESTtoUNORDERED_ACCESSbefore dispatch.Regression evidence
The seeded regression was tested with initialization deliberately disabled as a negative control:
This confirms that the test host clears pre-existing bitmap contents before shader execution.
Verification
VICTORY_WARP=1: 3 passed.VICTORY_WARP=1: 14 passed.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 on GitHub · 2026-11-25 00:51 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
0ababf5:cargo test -p victory-shader --lockedgives 244 passed, 3 failed, 3 ignored. The newdirty_page_bitmap_is_zeroed_before_dispatchpasses. The 3 failures are #1744's NVIDIA ones onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware), so there is nothing new on this hardware.AI-assisted (Claude Code).
@Headache3318 on GitHub · 2026-11-25 02:06 UTC · original
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
0ababf5applied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass. The new UAV initialization test is GPU-specific (requires dxil.dll/WARP) and is skipped on Linux.cargo clippy -p victory-shader --all-targets -- -D warnings: 4 pre-existing errors in test code (fail identically on mainccfb029). The PR introduces no new clippy warnings.Not tested: Windows MSVC build, the title itself. AI-assisted.
@Marvisak on GitHub · 2026-11-25 08:16 UTC · original
Automated triage for the maintainers.
Needs work.
Host::dispatch(crates/victory-shader/src/emit/host.rs) the root UAV buffers come fromCreateCommittedResourcewithD3D12_HEAP_FLAG_NONE, and D3D12 zeroes committed resources unlessD3D12_HEAP_FLAG_CREATE_NOT_ZEROEDis passed. So onmainthese buffers already start at zero, which theRoot::Uavdoc comment says too. The extra zero copy does no harm, but the PR doesn't show a case where the buffers held anything else, and the body says itself that the link to #1882 is unconfirmed.dirty_page_bitmap_is_zeroed_before_dispatchwrites a seed with the newRoot::SeededUavand then checks that the host's own zero copy overwrote it. That only tests the test host against itself. It can't catch a real regression in shader lowering.title_memory_is_read_and_written_at_computed_addressesnow uses hard-coded[1360, 5200, 5201]in place of values derived fromfarandTITLE. They're numerically the same, but the derivation was the documentation. The test also leaves aneprintln!behind.checkfails insynthetic_tests(gathers_at_a_level_match_the_hardware,permutes_read_the_lane_named_and_zero_from_lanes_left_out). This PR doesn't touch those tests, so the failure doesn't look like it comes from this change.What would change the verdict: a run on
mainwhere a root UAV starts non-zero (for example the #1882 failure reproduced, then gone with this change). Without that evidence, consider dropping the seeded test and keeping the derived expected values.Generated by Claude Code
@Damokles2 on GitHub · 2026-11-25 09:28 UTC · original
Thanks for the detailed review. After reassessing the D3D12 allocation behavior and the regression test, I agree that the current patch does not establish a real initialization defect.
The seeded test demonstrates that the additional zero copy works, but it does not reproduce the original intermittent failure in #1882 or show that ordinary Root::Uav allocations contain stale data.
I'll close this PR in its current form and leave #1882 open for further investigation with a reproducible failure.
Thanks to everyone who reviewed and tested the change.
AI-assisted using OpenAI Codex.
Pull request closed