victory-gpu: implement ClearUnorderedAccessViewUint/Float and DiscardResource #948
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!948
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/948/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?
@Sakura-Byte on GitHub · 2026-11-24 14:25 UTC · original
Sakura-Byte:pr/clear-uav-discard→main· +1362 −48 · 6 files · 2 commits · closed without mergingSummary
ClearUnorderedAccessViewUint,ClearUnorderedAccessViewFloat, andDiscardResourceacrosscrates/victory-gpu/src/{descriptor.rs, descriptor/host.rs, draw.rs, host.rs, list.rs, texture.rs}.DXGI_FORMAT_R32_UINT/FLAG_NONEfor 4-byte-alignedClearUnorderedAccessViewUint, rejecting float clears on raw/structured views) and deferredtexture::host_writtentracking on submission.Verification
cargo xtask policyandcargo clippy --workspace --all-targets (--all-features) --locked -- -D warnings: cleanAI-assisted; synthetic tests only, zero game assets.
@MartinIndra02 on GitHub · 2026-11-24 14:30 UTC · original
Nice clean implementation (and good addition of
DiscardResource). Two D3D12 edge cases we hit underVICTORY_D3D12_DEBUG=1on RTX 3080 when testing raw/structured buffer UAV clears:D3D12_BUFFER_UAV_FLAG_RAW(R32_TYPELESS):resolve_buffer_uavchecksbyte_offset.is_multiple_of(4)and creates anR32_TYPELESS | D3D12_BUFFER_UAV_FLAG_RAWUAV withFirstElement = byte_offset / 4. In D3D12,FLAG_RAWrequiresFirstElementto be a multiple of 4 (16-byte aligned) — passing a 4-byte-aligned non-16-byte-aligned offset (e.g.FirstElement = 2, byte offset8) triggers a D3D12 Debug Layer error and device removal. Reinterpreting raw/converted buffer views as typedDXGI_FORMAT_R32_UINTwithD3D12_BUFFER_UAV_FLAG_NONEforClearUnorderedAccessViewUintclears every dword identically at any 4-byteFirstElementwith zero Debug Layer errors.ClearUnorderedAccessViewFloatonR32_TYPELESS | RAW: D3D12 forbidsClearUnorderedAccessViewFloatonR32_TYPELESS(raw) views; refusing float clears on raw/structured views (or reinterpreting asR32_FLOATonly if intended) avoids an invalid command.Code review note; no game data. AI-assisted.
@MichaelSmithAI on GitHub · 2026-11-24 14:40 UTC · original
The resource-backed texture path passed an isolated readback on
78f74a6under Wine/vkd3d-proton 3.2 on an RTX 4090. Using the PR’s float-clear sequence on a 4×4 RGBA8 texture, we cleared the full texture red, then the center 2×2 green. After submission, all four inner texels were green and all twelve outer texels remained red.Two integration details remain outside that test. In
clear_uav, the texture branch callshost_writtenduring recording. A list reset before submission therefore needs separate coverage for subsequent texture reads (see #758). The buffer branch requests refresh and writeback, but has no explicit transition of the shadow to UAV state before the clear. #785 also has same-list producer tracking for a later placed upload. This run exercised only the submitted texture clears.@Sakura-Byte on GitHub · 2026-11-24 15:09 UTC · original
Thank you @MartinIndra02 and @MichaelSmithAI for the detailed review and hardware/Wine verification!
Addressed in commit
35802af69d54797159e785ecfa2e60817107d647(35802af):ClearUnorderedAccessViewUintvia typedR32_UINT(FLAG_NONE) (crates/victory-gpu/src/descriptor/host.rs):resolve_buffer_uavnow translates both raw (R32_TYPELESS/D3D12_BUFFER_UAV_FLAG_RAW) and structured buffer UAVs toDXGI_FORMAT_R32_UINTwithD3D12_BUFFER_UAV_FLAG_NONEforClearKind::Uint, avoiding the 16-byteFirstElementalignment requirement on raw UAVs.ClearUnorderedAccessViewFloaton raw/structured buffer views (crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/list.rs):ClearKind::Floatnow returnsNoneon raw or structured views instead of emitting an invalid clear.texture::host_writtenuntil submission (crates/victory-gpu/src/list.rs): the texture branch now useslist.defer_hostto callcrate::texture::host_written, so resetting an unsubmitted command list does not mark the texture host-written.descriptor::host::tests::structured_uav_converts_to_raw_for_clear_when_4_byte_aligned(checksR32_UINT+D3D12_BUFFER_UAV_FLAG_NONEat non-16B-aligned offsets andClearKind::Floatrefusal)list::tests::uav_tests::clear_uav_uint_handles_non_16b_aligned_offsets_and_refuses_float_raw(end-to-end WARP clear/readback at non-16B-aligned raw and structured offsets, plus ignored float clears)list::tests::uav_tests::clear_uav_defers_texture_host_written_until_submit(checks reset-without-submit leavesis_host_writtenfalse, and submit marks it true with expected texels)Note on buffer UAV state tracking:
Shadowbuffer state tracking (buffer_state) is not onmainyet (matchingdraw.rs, which callsshadow.refreshandshadow.gpu_writes), soclear_uavmatchesdraw.rsonmain.Verified on WARP (
VICTORY_D3D12_WARP=1,VICTORY_WARP=1):cargo xtask policy,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, andcargo test -p victory-gpu --features diagnostics --locked -- --test-threads=1(58 passed, 0 failed, 1 benchmark ignored).@shortselow-byte on GitHub · 2026-11-24 15:24 UTC · original
Tested at head
35802af, merged locally onto currentmain(ffe310e, the branch is based on8e79c80), on AMD, since the runs above are NVIDIA (native and vkd3d-proton): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2, driver 32.0.21045.16010).clear_uav*tests pass on the AMD device (default adapter) and on WARP (--features diagnostics,VICTORY_D3D12_WARP=1), including the newclear_uav_uint_handles_non_16b_aligned_offsets_and_refuses_float_raw. A temporary print confirmed that test reached its last assertion on both, so theFirstElement = 2/3raw-buffer clears throughR32_UINThit exactly their dwords and the device was not removed.cargo test --locked -p victory-gpu --lib -- --test-threads=1: 55 passed on AMD, 58 on WARP withdiagnostics. Whole workspace on the merged tree: 347 passed, 0 failed.cargo clippy --workspace --all-targets --locked -- -D warnings, and with--all-features: clean.Not covered: no D3D12 debug layer on this machine, and no in-title run.
@Zipettte on GitHub · 2026-11-24 15:40 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
35802af:cargo test -p victory-gpupasses, 55 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:28 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.ClearUnorderedAccessViewUint/Float is already served in main (list.rs slots 0x1a8/0x1b0 -> draw.rs State::clear_unordered); main ignores DiscardResource (0x1b8) on purpose. 1,362 lines against code that no longer exists.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed