GPU: read UAV MipSlice from offset 8 in image_words #2597
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2599"
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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T16:33:50Z.
Summary
image_wordsincrates/victory-gpu/src/descriptor/host.rsreadd[4]for both SRV and UAV texture views.D3D12_SHADER_RESOURCE_VIEW_DESChasFormat(d[0]),ViewDimension(d[1]),Shader4ComponentMapping(d[2]), and 4 bytes of union alignment padding (d[3]), placingMostDetailedMipat offset 16 (d[4]).D3D12_UNORDERED_ACCESS_VIEW_DESChasFormat(d[0]) andViewDimension(d[1]), with the view union starting directly at offset 8 (d[2]), soMipSlicelives atd[2]acrossTexture1D,Texture1DArray,Texture2D,Texture2DArray, andTexture3DUAVs.Reading
d[4]for UAVs read0for a 2D UAV (PlaneSliceis atd[3],d[4]is unused/zero), and readArraySize/WSizefor 2D array and 3D UAVs, corrupting thefirst/lastmip fields encoded into the RDNA image descriptor words.Changes
crates/victory-gpu/src/descriptor/host.rs: readd[2]instead ofd[4]inimage_wordsfor unordered (unordered == true) non-MSAA texture views.a_texture_view_gives_its_image_descriptor_size_fieldsto build descriptor word arrays from actualD3D12_SHADER_RESOURCE_VIEW_DESCandD3D12_UNORDERED_ACCESS_VIEW_DESCstructs (Texture2D,Texture2DArray, andTexture3DUAVs with distinctMipSlicevsd[4]values).Verification
cargo test -p victory-gpu --lib descriptor::host::tests::a_texture_view_gives_its_image_descriptor_size_fields -- --exact— passcargo clippy -p victory-gpu --all-targets -- -D warningsand--features diagnostics— pass (0 warnings)cargo xtask policy— pass (184 files ok)Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T16:47:55Z.
Review: CHANGES_REQUESTED
as_wordscopies the whole descriptor into a[u32; 10]. The zeroed destination does not help here becausecopy_nonoverlappingpreserves the source’s initialization state. TheTexture2Dunion member initializes onlyMipSliceandPlaneSlice. Theuav2d[4]assertion reads past both fields and can read uninitialized bytes as au32.Could we use fully initialized word arrays with distinct values at
d[2]andd[4], and check the ABI offsets separately withoffset_of!? That would still catch the original mip-selection bug without reading inactive union bytes.Static review only.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T17:22:56Z.
Review: APPROVED
No description provided.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T17:22:05Z.
Good catch @DrDarkDK — reading inactive union bytes through
copy_nonoverlappingis indeed UB.Updated (
bf34b7a) to removeas_words/unsafecompletely: the test now verifies allD3D12_SHADER_RESOURCE_VIEW_DESCandD3D12_UNORDERED_ACCESS_VIEW_DESC(1D/1DArray/2D/2DArray/3D) field offsets with compile-timestd::mem::offset_of!assertions and passes fully initialized[u32; 10]arrays with distinctd[2]vsd[4]values. Re-verified tests, clippy (default + diagnostics), andcargo xtask policy.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:18:09Z.
Automated triage for the maintainers.
In
crates/victory-gpu/src/descriptor/host.rs,image_wordsreadd[4]as the first mip for unordered texture views. The view words use the host D3D12 layout (uav_desccasts them directly toD3D12_UNORDERED_ACCESS_VIEW_DESC), and that union starts at byte 8, soMipSliceisd[2].d[4]holdsMipSliceonly in the SRV layout. The one-word fix is correct by the public D3D12 struct layout. The updated testa_texture_view_gives_its_image_descriptor_size_fieldspins the offsets withoffset_of!and covers 2D, 2D-array and 3D UAVs, using values that would catch the old read. The branch merges cleanly with currentmain. CI: passing (check). This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Kajanos on 2026-11-26T00:07:13Z.
Windows 11 / NVIDIA test run, head
bf34b7a1eamerged ontomain63bcca43c6.Setup: Windows 11 Home build 26300, RTX 5080, NVIDIA 621.40, rustc 1.98.1 MSVC, VS 2022 Build Tools, Windows SDK 10.0.26100 (
dxil.dllfrom the SDK).cargo test --locked -p victory-gpu: 231 passed, 0 failed, 1 ignored (same asmain).Not run: the retail title, clippy, and other crates.
AI-assisted (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.