Resource-backed texture UAV clears are missing from command lists #771
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#771
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@fuzeofficlal on GitHub · 2026-11-24 10:08 UTC · original
The guest command list at
ffe310eskips theClearUnorderedAccessViewUintandClearUnorderedAccessViewFloatentries. A synthetic test on that commit stops at the missing slot check before creating a D3D12 device.Source commit
d359499wires both entries for resource-backed textures. It uses a matching descriptor pair in the CPU-only and bound shader-visible heaps and uses the existing texture state tracker for the transition to UAV state.I recorded a whole clear followed by a centered 2×2 clear for each of two 4×4 textures,
R32_UINTandR32_FLOAT, on the same guest list. RTX 5090 and WARP both read back all 32 expected values, including the unchanged pixels outside the rectangles, with zero D3D12 debug-layer errors. Each diagnostics suite passed 53 tests with one benchmark ignored.Buffer UAV clears need their own state handoff and are outside this patch.
@MichaelSmithAI on GitHub · 2026-11-24 10:54 UTC · original
For the buffer state handoff you called out, Melissa put together a tested follow-up branch on your texture-clear commit
d359499and #334’s buffer-state tracking. The two follow-up commits are9978134(typed buffer clears) and1cac714(same-list GPU copy regression).A guest command list issued overlapping integer and float clears to resource-backed R32 buffer views. With only the texture implementation the integer buffer retained its original data. With the follow-up, the five intended words in each buffer changed and their neighbors retained their sentinels. A GPU copy recorded immediately after the clears returned all 128 expected words; the guest CPU readback agreed. This ran on RTX 4090 with Wine/vkd3d-proton 3.2.
The comparison covers typed resource-backed buffers and a subsequent copy. Shader consumers, other buffer view types and in-game use are still open.
@geiyiliyabumo on GitHub · 2026-11-24 11:08 UTC · original
Following up on the buffer-UAV gap noted in the OP ("Buffer UAV clears need their own state handoff and are outside this patch"): I prepared and verified a branch on
main(ffe310e) that wires slots53(ClearUnorderedAccessViewUint) and54(ClearUnorderedAccessViewFloat) on both older and newer command-list layouts for both buffer UAVs (resource-backed + placed) and resource-backed texture UAVs:github.com/geiyiliyabumo/VIctory@12e9c6aSummary
D3D12_BUFFER_UAV_FLAG_RAW), structured (uint), and typed DXGI buffer formats (R32/R16/R8, float/f16/int/unorm/snorm, BGRA swizzle), clamps 1Drectsintervals safely to the view and allocation, writes title memory at submission viadefer, and keeps overlapping host GPU shadows (includingLOOSEaddress views) ordered against GPU draws/dispatches viaID3D12GraphicsCommandList7::Barrier+CopyBufferRegion(falling back to deferred shadow refresh when enhanced barriers are unavailable) andShadow::expect_cleared.descriptor::host::texture_uav_descfor matching CPU-only and shader-visible UAV descriptors, temporarily binds/restores the host shader-visible view heap and root signatures when needed, transitions the texture toUNORDERED_ACCESS, and callstexture::host_written.R32_UINT+R32_FLOATtexture readback.Verification (Windows 11 Pro 26100, AMD Radeon RX 9060 XT driver
32.0.32029.2010, Rust1.98.1)cargo xtask policy: PASS (154 files ok)cargo clippy --workspace --all-targets --locked -- -D warnings: PASScargo clippy --workspace --all-targets --features diagnostics --locked -- -D warnings: PASScargo test -p victory-gpu --locked -- uav: 9/9 PASS on RX 9060 XT and 9/9 PASS on WARP (VICTORY_D3D12_WARP=1)cargo test -p victory-gpu --features diagnostics --locked -- uav: 9/9 PASS on RX 9060 XT and 9/9 PASS on WARP (VICTORY_D3D12_WARP=1)cargo test --workspace --locked: PASS (0 failed)(Note: this machine does not have the optional Windows Graphics Tools package installed, so
ID3D12InfoQueuewas unavailable; D3D12 debug-layer checks run automatically when Graphics Tools is present. Placed texture UAVs remain outside scope.)AI-assisted; synthetic tests only, no game files.
@MartinIndra02 on GitHub · 2026-11-24 11:23 UTC · original
Implemented the buffer + texture UAV clear follow-up on a branch based on
main(ffe310e):d31c482)Summary of changes
crates/victory-gpu/src/host.rs: Added paired non-shader-visible (clear_uavs_cpu) and shader-visible (clear_uavs_gpu)CBV_SRV_UAVdescriptor rings (1024slots) andHost::clear_uav(...)to supply both handles required by D3D12ClearUnorderedAccessViewUint/Float.crates/victory-gpu/src/descriptor/host.rs: AddedClearTarget(Buffer/Texture) andclear_uav_target(view, resource).D3D12_BUFFER_UAV_FLAG_RAW), reinterprets the clear view as typedDXGI_FORMAT_R32_UINT(D3D12_BUFFER_UAV_FLAG_NONE) so clears work cleanly at any 4-byteFirstElementwithout hitting D3D12's 16-byte raw alignment restriction.StructureByteStride > 0, disallowed by D3D12ClearUnorderedAccessView*) with a one-time diagnostic.crates/victory-gpu/src/draw.rs: AddedState::invalidate_heaps()to reset cached host descriptor heaps and root bindings after temporarily binding the internal clear heap.crates/victory-gpu/src/list.rs:0x1a8,ClearUnorderedAccessViewUint) and 54 (0x1b0,ClearUnorderedAccessViewFloat).shadow.refresh+shadow.gpu_writes+UAV_BARRIERbefore/after) and resource-backed texture UAVs (transition toUNORDERED_ACCESS,texture::host_written,UAV_BARRIER), invalidating host heaps afterwards.list::tests::buffer_uav_clears_write_back_to_title_memorycovering a raw bufferUintclear atFirstElement = 2and a typedR32_FLOATbufferFloatclear atFirstElement = 1, verifying title memory write-back and untouched neighboring elements.Verification (Windows 11, RTX 3080 driver
621.24, Rust1.98.1)cargo test -p victory-gpu --lib -- --test-threads=1(RTX 3080): 51 passed, 0 failed, 1 ignoredVICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib buffer_uav_clears -- --test-threads=1(WARP): 1 passed, 0 failedVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib buffer_uav_clears -- --test-threads=1 --nocapture(D3D12 Debug Layer): 1 passed, 0 failedcargo clippy -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): 0 warningscargo xtask policy: 154 files okReady to open as a PR whenever PRs reopen.
No game data used. AI-assisted; all builds and GPU tests executed on my machine.
@Gruzzberry on GitHub · 2026-11-24 11:37 UTC · original
Stacked on d359499: buffer UAV clears are on a fork branch (two commits on top of it): https://github.com/Gruzzberry/VIctory/tree/gpu/buffer-uav-clears
A title buffer is title memory with a host shadow copy, so the clear is recorded on the shadow after a refresh from title memory, and the words it changed are copied back like a shader's writes. Typed and raw views clear as they are. A structured view with a whole-word stride becomes a raw
R32_TYPELESSview over the same bytes (an integer clear writes the first value into every word), and the title's rectangles are scaled with it. Float clears of raw and structured views are refused and logged once.Six host tests cover a raw view, a structured view, a structured view with a rectangle, a typed view with a rectangle over a middle range, a float clear and the refused case; each checks that the words outside the clear keep their sentinel.
cargo test -p victory-gpupasses 56 tests on an RTX 4070. With--features diagnostics, 59 pass on the RTX 4070 and on WARP, also withVICTORY_D3D12_DEBUG=1, and the debug layer reports nothing for the new tests. Workspace tests (348), both clippy runs and the asset policy are clean.I have no write access, so this is a branch rather than a PR; I'd be glad to open one if you would add me as a collaborator.
AI use: written with Claude; tests run on an RTX 4070 and WARP.
@fuzeofficlal on GitHub · 2026-11-24 11:40 UTC · original
I checked
12e9c6aon native Windows D3D12 with an RTX 5090. I kept the same-list GPU copy from the existing synthetic test and changed the second operation to a regional RAW clear. The view held eight DWORDs and the second clear covered the interval [2, 6).[12, 12, 12, 12, 12, 12, 12, 12][12, 12, 23, 23, 23, 23, 12, 12]Both snapshots were copied into a native readback buffer by the same command list. The test asserted a physical adapter and enhanced-barrier support, then passed with all four neighboring values preserved.
@Gruzzberry on GitHub · 2026-11-24 17:39 UTC · original
Update to the buffer UAV clear branch (force-pushed, two commits on top of d359499): https://github.com/Gruzzberry/VIctory/tree/gpu/buffer-uav-clears (now at 9107c7a)
What changed. Testing a raw view that starts on an odd word, and an 8-byte structured view that starts on an odd element, stopped the process with
STATUS_STACK_BUFFER_OVERRUN: the host's raw buffer clear has to begin on 16 bytes, and the first version cleared raw views, and structured views as raw views, at whatever word the title chose. The branch now clears a raw view, and a structured view whose stride is whole words, as anR32_UINTview of the same words, which begins on any word. An integer clear still writes the first value into every word, as on the console. The first push also multiplied a structured view's first element without a check, which is now checked.What it does.
ClearUnorderedAccessViewUint/Floaton a title buffer were dropped (clear_texture_uavreturns early because a buffer has no host resource). The clear now runs on the buffer's host copy after a refresh from title memory, and the words it changed are copied back like a shader's writes. Typed views clear as they are; the title's rectangles are scaled with the structured-to-word view. Float clears of raw and structured views, and structured views whose stride is not whole words, are refused and logged once.Tested (RTX 4070 12 GB, Windows 11 26200, Rust 1.98.1, branch rebased on
ffe310e):cargo test -p victory-gpu --locked: 59 passed, 1 ignored.cargo test -p victory-gpu --locked --features diagnostics: 62 passed, 1 ignored on the RTX 4070, and the same on WARP (VICTORY_D3D12_WARP=1), each also withVICTORY_D3D12_DEBUG=1.cargo test --workspace --locked: 351 passed, 0 failed, 6 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings, the same with--all-features, andcargo xtask policy: clean.R32_UINTview with a rectangle over a middle range, typedR32_FLOATview cleared with 1.5, and float clears of a raw and of a structured view (refused, memory untouched). Each checks that the words outside the clear keep their sentinel. With the list hook removed, the seven tests that expect a change fail; the two odd-offset tests crashed the process before theR32_UINTview.Not tested. In-game use: this was not run against the title's real buffer clears. Placed buffer views and a buffer with no host copy have no test. I did not compare it against the other buffer-clear branches on this issue.
AI use. Written and tested with Claude Code (Claude Sonnet 5.5). I have no write access, so this is a branch rather than a PR.
@Marvisak on GitHub · 2026-11-25 03:51 UTC · original
Automated triage for the maintainers.
Fixed on
mainafter this report: commit0b35b7fwires slots 53 and 54 (ClearUnorderedAccessViewUint/Float) in both list layouts (crates/victory-gpu/src/list.rs, testunordered_access_clears_have_the_same_slots_in_both_layouts). It also addsState::clear_unorderedincrates/victory-gpu/src/draw.rs, which makes the host view throughdescriptor::host::make_viewin a dynamic slot of the bound heap and marks the cleared resource as written.If one of the fork branches here covers a case
mainstill gets wrong (for example raw or structured buffer views starting at offsets the host clear does not accept, or float clears of raw views), please open a pull request for it. Pull requests are open to everyone. This issue will be closed in 48 hours unless the reporter replies or a maintainer removes thetriage: proposed closelabel.Generated by Claude Code