List: title copies name a held host copy's levels, and are fitted to the host's textures #3062
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3062
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3062"
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?
@Adriwin06 on GitHub · 2026-11-29 19:52 UTC · original
Adriwin06:held-copies→main· +457 −4 · 2 files · 2 commits · closed without mergingWhat it changes
A host copy made of only the levels a placed texture's views show
(resource::held_only, on by default on cards over 8 GB) begins at the
title's level
base, but copy_texture_region, its read backs andcopy_resource handed the title's subresource index to the host as it
was, so a copy from the title's level 0 read the host copy's first
level, which is a smaller one, with the title's box.
held_sub maps the title's index to the host copy's. A copy naming a
level the host copy lacks first asks for one with every level
(want_level, as the placed twins' copies do), and is left out with a
warning only if the host copy is kept (one the host wrote). Whole copies
ask the same of both sides and are left out if they still begin at
other levels. The placed twins and bakes still read the title's indices.
Every region copy (and read back, and copy into a placed twin) is also
fitted to the host's subresources before it is recorded (fit_copy: the
source box cut to the source, the copy to the destination's room from
its corner, blocks counted for block-compressed formats). A copy that is
cut or left out is logged with both textures as the title and the host
have them, instead of recording a CopyTextureRegion the debug layer
calls invalid (which leaves the list unclosable with E_INVALIDARG).
Whole copies between host textures of two shapes are left out the
same way.
Tests: resource::a_copy_names_the_levels_a_held_copy_has, list::fit_tests.
How it was tested
cargo testpassed for the crates it touches:cargo test -p victory-gpu --lib -- list:: resource::: 67 passedcargo clippy --workspace --all-targets --locked: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself).cargo xtask policy: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs).cargo clippyalso with--all-featuresadds no finding, andcargo test --workspace --lockedfails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test).Checked for overlap
None found for held copies or copy fitting (searched "held", "CopyTextureRegion", "fit_copy").
🤖 Generated with Claude Code
@ -1411,0 +1442,4 @@"a whole texture copy between host textures of two shapes: left out");}return;@Copilot on GitHub · 2026-11-29 19:58 UTC · original
A rejected whole copy still calls
host_writtenandhost_write_listedbefore returning, so an unwritten destination can lose subsequent title-memory uploads and held-copy growth without receiving the copy. The same issue occurs forFit::Nothingincrates/victory-gpu/src/list.rs:1883. Validate shape compatibility and nonempty regions before destination initialization, tile-write preparation, and write bookkeeping, so omitted copies leave content ownership unchanged.@ -1494,0 +1685,4 @@held_sub(l.resource, l.footprint.offset as u32).map(u64::from)}};let (Some(src_at), Some(dst_at)) = (host_at(&src), host_at(&dst)) else {@Copilot on GitHub · 2026-11-29 19:58 UTC · original
For a copy within one unwritten texture held from mip 2, source mip 2 maps to host mip 0 before destination mip 0 grows the texture to a full host copy. Both recorded indices then become 0 instead of copying mip 2 to mip 0, and the title-index self-copy check misses this. Finish growth on both sides before calculating either host index.
@ -1780,0 +2049,4 @@}let cut_box = match fitted {Fit::AsAsked => None,Fit::Cut(b) => Some(D3D12_BOX { left: b[0], top: b[1], front: b[2], right: b[3], bottom: b[4], back: b[5] }),@Copilot on GitHub · 2026-11-29 19:58 UTC · original
When a read-back is clipped, the GPU writes only the fitted region, but
defer_read_backstill passes the original footprint's row width and row count tohost::read_backs. The CPU copy then overwrites title memory with unwritten bytes from the pooled buffer. Carry the fitted byte width and row/depth counts through deferred read-back handling while preserving the original host row/slice strides and title destination pitch.@ -1411,0 +1427,4 @@// SAFETY: live textures.let (a, b) = unsafe { (to.GetDesc(), from.GetDesc()) };if (a.Dimension, a.Width, a.Height, a.DepthOrArraySize, a.MipLevels)!= (b.Dimension, b.Width, b.Height, b.DepthOrArraySize, b.MipLevels)@Copilot on GitHub · 2026-11-29 19:58 UTC · original
Comparing raw width and height rejects valid block-compressed reinterpret copies, such as a 256×256
R32G32B32A32_UINTtexture copied to a 1024×1024BC5_UNORMtexture. D3D12 CopyResource supports this, with one uncompressed texel representing one compressed block. Validate dimensions using the supported reinterpret-format pairs and their block sizes rather than requiring raw dimensions to match.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-29 19:58 UTC · original · reviewed
🟡 Changes recommended
Critical copy and read-back defects can select the wrong mip, overwrite title memory with unwritten bytes, and incorrectly change destination ownership when copies are omitted.
4 open issues
What changed in this PR
This PR updates the GPU command-list copy paths to account for host textures that retain only selected mip levels, aiming to prevent invalid D3D12 copies from leaving command lists unclosable.
Changes:
crates/victory-gpu/src/resource.rscrates/victory-gpu/src/list.rsReview effort: Balanced
@dyshay on GitHub · 2026-11-29 20:46 UTC · original
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Fixed in
1e02966d: the whole copy's shape check now runs before the source upload, the twins,card_writes,host_writtenandhost_write_listed. For region copies, the fit (Fit::Nothing) is decided before the destination is uploaded into or marked, so a copy left out leaves ownership unchanged.@ -1494,0 +1742,4 @@held_sub(l.resource, l.footprint.offset as u32).map(u64::from)}};let (Some(src_at), Some(dst_at)) = (host_at(&src), host_at(&dst)) else {@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Fixed in
1e02966d: both locations grow before either host index is taken. Any side naming a level below its held base callswant_level(.., 0)first, so a copy of mip 2 into mip 0 within one held texture is recorded as 2 into 0.@ -1780,0 +2108,4 @@}let cut_box = match fitted {Fit::AsAsked => None,Fit::Cut(b) => Some(D3D12_BOX { left: b[0], top: b[1], front: b[2], right: b[3], bottom: b[4], back: b[5] }),@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Fixed in
1e02966d: the deferred read back now gets the rows and bytes of the region actually written, at the buffer's start. That is the fitted cut, or the title's own box when there is one (read_back_rows). Host row pitch and title pitch are unchanged. A volume cut within each slice's height is refused before recording. Regression test:fit_tests::a_cut_read_back_returns_only_what_the_copy_wrote.@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Fixed in
1e02966d:whole_copy_fitscompares dimension, slices and levels, then the size in blocks of the same bytes, so 256x256R32G32B32A32_UINTand 1024x1024BC5_UNORMmatch. Formats whose blocks are unknown fall back to raw sizes. Regression test:fit_tests::a_whole_copy_compares_sizes_in_blocks.@tyr0nsur on GitHub · 2026-11-30 09:03 UTC · original
I tested the read-back follow-up at
1e02966on an RTX 4060 and found two cases that still fail. The test uploads distinct rows to a 256×256 R32_FLOAT texture and reads it back into a wider and taller footprint with a 1,280-byte GPU pitch and a 1,536-byte title pitch.Fit::AsAskedleaves the effective region unset and the CPU copies the unwritten tail of the wider destination footprint into title memory.Follow-up commit
cb3f59dcarries the actual GPU pitch and uses the source extent when there is no box. The regression verifies each copied row and the sentinel bytes outside the region. Both cases fail on the PR head with only the test added and pass with the patch.The targeted Windows suite passed 74 tests (one ignored). With the existing diagnostics build repair from
41adb551applied locally, 95 passed (two ignored), and the new regression also passed on WARP. The staged asset-policy check passed. Review assisted by Claude Opus 5.5.Pull request closed