Placed buffer-to-texture copy reads stale data after a same-list GPU write #785

Open
opened 2026-11-26 04:13:58 +00:00 by github-bot · 6 comments
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 10:40 UTC · original

On ffe310e, the placed-buffer source of CopyTextureRegion is filled from CPU memory before the GPU list runs. When a GPU command writes the source buffer earlier in that same list, the texture receives the old bytes even though the source contains the new bytes after submission.

I reproduced this through the guest copy call with a synthetic 4×4 RGBA8 texture on RTX 5090 and WARP. Stock and main + #334 both read back 0/16 new pixels after a tracked same-list GPU copy. With the follow-up both read back 16/16. A tracked native UAV dispatch also passed with source offsets 512 and 516, including replay with changed inputs. CPU uploads recorded before a late CPU write, two ordered CPU snapshots, and the partial-write snapshot control all passed. The probes reported zero D3D12 debug-layer errors.

Source follow-up 517a2a5 is stacked on #334 at af2aecf. It uses the host buffer with #334's read transition when the latest tracked GPU write in that list covers the footprint. Other cases use the existing upload snapshot path. The unaligned offset is rebased with a GPU buffer copy.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 10:40 UTC · [original](https://github.com/Marvisak/VIctory/issues/785) On `ffe310e`, the placed-buffer source of `CopyTextureRegion` is filled from CPU memory before the GPU list runs. When a GPU command writes the source buffer earlier in that same list, the texture receives the old bytes even though the source contains the new bytes after submission. I reproduced this through the guest copy call with a synthetic 4×4 RGBA8 texture on RTX 5090 and WARP. Stock and main + #334 both read back **0/16** new pixels after a tracked same-list GPU copy. With the follow-up both read back **16/16**. A tracked native UAV dispatch also passed with source offsets 512 and 516, including replay with changed inputs. CPU uploads recorded before a late CPU write, two ordered CPU snapshots, and the partial-write snapshot control all passed. The probes reported zero D3D12 debug-layer errors. [Source follow-up `517a2a5`](https://github.com/fuzeofficlal/VIctory/commit/517a2a5dedfe890fff580bc0ba4c0509bf594d4b) is stacked on #334 at `af2aecf`. It uses the host buffer with #334's read transition when the latest tracked GPU write in that list covers the footprint. Other cases use the existing upload snapshot path. The unaligned offset is rebased with a GPU buffer copy.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:58 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-24 10:46 UTC · original

I tested a boxed-copy case on 517a2a5 with a 4×4 RGBA8 placed footprint, 256-byte row pitch, and source box [0, 0, 0, 2, 1, 1]. An earlier tracked CopyBufferRegion on the same list wrote the first 8 bytes, covering both pixels the box reads.

On both RTX 4070 Ti (621.01) and WARP, all 8 source bytes contained 0x6d after submission, but both destination pixels still contained the old 0x11 bytes. With the same box and a 1024-byte GPU write covering the full footprint, both destination pixels contained 0x6d on both adapters.

placed_copy_source checks write coverage against the full footprint, so the 8-byte case takes the CPU snapshot path even though the GPU produced every byte the box reads.

AI-assisted. Both tests ran locally on my machine using synthetic data.

**@⁠DrDarkDK** on GitHub · 2026-11-24 10:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7129237486) I tested a boxed-copy case on `517a2a5` with a 4×4 RGBA8 placed footprint, 256-byte row pitch, and source box `[0, 0, 0, 2, 1, 1]`. An earlier tracked `CopyBufferRegion` on the same list wrote the first 8 bytes, covering both pixels the box reads. On both RTX 4070 Ti (621.01) and WARP, all 8 source bytes contained `0x6d` after submission, but both destination pixels still contained the old `0x11` bytes. With the same box and a 1024-byte GPU write covering the full footprint, both destination pixels contained `0x6d` on both adapters. `placed_copy_source` checks write coverage against the full footprint, so the 8-byte case takes the CPU snapshot path even though the GPU produced every byte the box reads. *AI-assisted. Both tests ran locally on my machine using synthetic data.*
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 10:56 UTC · original

I reproduced DrDarkDK's two-pixel case on 517a2a5 and added two layout controls. RTX 5090 and WARP gave the same results.

Source box Matching GPU-written pixels on 517a2a5 With follow-up
First row, two pixels 0/2 2/2
Nonzero origin with placed offset 516 0/2 2/2
Two pitched rows 0/4 4/4

Follow-up e8e5f49 uses the byte span of the source box when choosing the tracked producer. It still checks that the backing buffer fits the full placed footprint and preserves the box-relative offsets if an unaligned source needs rebasing.

All 40 destination pixels outside the boxes kept their initial values. The original full-copy, CPU snapshot, and UAV replay probes also passed, with zero D3D12 errors on either adapter.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 10:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7129435487) I reproduced DrDarkDK's two-pixel case on `517a2a5` and added two layout controls. RTX 5090 and WARP gave the same results. | Source box | Matching GPU-written pixels on `517a2a5` | With follow-up | | --- | ---: | ---: | | First row, two pixels | 0/2 | 2/2 | | Nonzero origin with placed offset 516 | 0/2 | 2/2 | | Two pitched rows | 0/4 | 4/4 | [Follow-up `e8e5f49`](https://github.com/fuzeofficlal/VIctory/commit/e8e5f49c2c5099f73074abb3113c78f419e0ae83) uses the byte span of the source box when choosing the tracked producer. It still checks that the backing buffer fits the full placed footprint and preserves the box-relative offsets if an unaligned source needs rebasing. All 40 destination pixels outside the boxes kept their initial values. The original full-copy, CPU snapshot, and UAV replay probes also passed, with zero D3D12 errors on either adapter.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 11:17 UTC · original

One more case on e8e5f49: I used a 4-by-4 RGBA8 footprint with a 256-byte row pitch, a two-pixel box spanning two rows, and two separate tracked GPU copies. Each write covered exactly the eight bytes read from its row. The padding between the rows was left at its original value.

The guest CopyTextureRegion still read the old CPU bytes at placed offset 512, even though both source rows held the new values after submission. The enclosing span has a gap, so no single producer covers it.

The follow-up keeps the enclosing-span check first. When that misses, it checks the actual row ranges and uses the host copy if all selected rows have a covering write to the same shadow. Both offsets 512 and 516 read back all four expected pixels on WARP. The CPU-upload control and the BC1/3D footprint checks passed. The diagnostics suite passed 56 tests, and library Clippy passed with warnings denied.

AI-assisted. Verified with synthetic data on WARP. The D3D12 debug layer was unavailable in this run.

Incremental patch on e8e5f49
diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs
--- a/crates/victory-gpu/src/host.rs
+++ b/crates/victory-gpu/src/host.rs
@@ -1504,29 +1504,36 @@ impl HostList {
             .push(Step::GpuWrite(shadow.clone(), address, len));
     }
 
-    /// The latest producer of this range if it wrote a covering host
-    /// copy on the GPU. Deferred CPU writes keep their upload snapshots.
+    /// The host copy when each range's latest producer covered it on the GPU.
+    /// Deferred CPU writes keep their upload snapshots.
     pub(crate) fn written_shadow(
         &self,
-        address: usize,
-        len: usize,
+        mut ranges: impl Iterator<Item = std::ops::Range<usize>>,
     ) -> Option<std::sync::Arc<crate::shadow::Shadow>> {
-        let end = address.checked_add(len)?;
-        let overlaps = |at: usize, size: usize| size != 0 && at < end && address < at + size;
-        for step in self.deferred().copies.iter().rev() {
-            match step {
-                Step::GpuWrite(shadow, at, size) if overlaps(*at, *size) => {
-                    // A partial producer still needs the copy's CPU snapshot
-                    // for bytes that subsequent refreshes can overwrite.
-                    return (*at <= address && end <= at + size).then(|| shadow.clone());
+        let deferred = self.deferred();
+        let producer = |range: std::ops::Range<usize>| {
+            let overlaps = |at: usize, size: usize| {
+                size != 0 && at < range.end && range.start < at.saturating_add(size)
+            };
+            for step in deferred.copies.iter().rev() {
+                match step {
+                    Step::GpuWrite(shadow, at, size) if overlaps(*at, *size) => {
+                        // A partial producer still needs the copy's CPU snapshot.
+                        return (*at <= range.start && range.end <= at.saturating_add(*size))
+                            .then_some(shadow);
+                    }
+                    Step::Copy(dst, _, size) if overlaps(*dst, *size) => return None,
+                    // Raw deferred CPU work can write this range too.
+                    Step::Run(_) => return None,
+                    _ => {}
                 }
-                Step::Copy(dst, _, size) if overlaps(*dst, *size) => return None,
-                // Raw deferred CPU work can write this range too.
-                Step::Run(_) => return None,
-                _ => {}
             }
-        }
-        None
+            None
+        };
+        let shadow = producer(ranges.next()?)?;
+        ranges
+            .all(|range| producer(range).is_some_and(|other| std::sync::Arc::ptr_eq(shadow, other)))
+            .then(|| shadow.clone())
     }
 
     /// Stores `what` (`bytes` of it) at `dst` once the list has run.
diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs
--- a/crates/victory-gpu/src/list.rs
+++ b/crates/victory-gpu/src/list.rs
@@ -490,6 +490,7 @@ fn placed_copy_source(
     offset: u64,
     bytes: u64,
     read: &std::ops::Range<u64>,
+    rows: Option<impl Iterator<Item = std::ops::Range<u64>>>,
 ) -> Option<(windows::Win32::Graphics::Direct3D12::ID3D12Resource, u64)> {
     use windows::Win32::Graphics::Direct3D12::D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT;
 
@@ -497,8 +498,12 @@ fn placed_copy_source(
     let address = data as u64;
     let read_address = address + read.start;
     let read_bytes = read.end - read.start;
+    let absolute = |range: std::ops::Range<u64>| {
+        (address + range.start) as usize..(address + range.end) as usize
+    };
     let source = list
-        .written_shadow(read_address as usize, read_bytes as usize)
+        .written_shadow(std::iter::once(absolute(read.clone())))
+        .or_else(|| list.written_shadow(rows?.map(absolute)))
         .and_then(|shadow| {
             let offset = shadow.offset_for_range(address, bytes)?;
             Some((shadow, offset))
@@ -576,11 +581,10 @@ extern "system" fn copy_texture_region(
             let Some(bytes) = src.footprint.bytes() else {
                 return;
             };
-            let read_span = source_box
-                .and_then(|bounds| src.footprint.box_bytes(*bounds))
-                .unwrap_or(0..bytes);
+            let (read_span, rows) = src.footprint.box_reads(source_box.copied()).unzip();
+            let read_span = read_span.unwrap_or(0..bytes);
             let Some((buffer, offset)) =
-                placed_copy_source(list, src.resource, src.footprint.offset, bytes, &read_span)
+                placed_copy_source(list, src.resource, src.footprint.offset, bytes, &read_span, rows)
             else {
                 return;
             };
diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs
--- a/crates/victory-gpu/src/resource.rs
+++ b/crates/victory-gpu/src/resource.rs
@@ -329,14 +329,21 @@ impl PlacedFootprint {
         let (element, block) = element(self.format)?;
         let lines = u64::from(self.height).div_ceil(block) * u64::from(self.depth);
         let last = u64::from(self.width).div_ceil(block) * element;
-        Some(u64::from(self.row_pitch) * lines.saturating_sub(1) + last)
+        u64::from(self.row_pitch)
+            .checked_mul(lines.saturating_sub(1))?
+            .checked_add(last)
     }
 
-    /// The byte span enclosing the rows and slices read by a source box.
-    pub(crate) fn box_bytes(
+    /// The enclosing byte span and exact row ranges used by a copy.
+    pub(crate) fn box_reads(
         &self,
-        [left, top, front, right, bottom, back]: [u32; 6],
-    ) -> Option<std::ops::Range<u64>> {
+        source_box: Option<[u32; 6]>,
+    ) -> Option<(
+        std::ops::Range<u64>,
+        impl Iterator<Item = std::ops::Range<u64>>,
+    )> {
+        let [left, top, front, right, bottom, back] =
+            source_box.unwrap_or([0, 0, 0, self.width, self.height, self.depth]);
         if left >= right
             || top >= bottom
             || front >= back
@@ -347,15 +354,22 @@ impl PlacedFootprint {
             return None;
         }
         let (element, block) = element(self.format)?;
+        self.bytes()?;
         let pitch = u64::from(self.row_pitch);
         let slice = pitch * u64::from(self.height).div_ceil(block);
-        let start = u64::from(front) * slice
-            + u64::from(top) / block * pitch
-            + u64::from(left) / block * element;
-        let end = u64::from(back - 1) * slice
-            + (u64::from(bottom).div_ceil(block) - 1) * pitch
-            + u64::from(right).div_ceil(block) * element;
-        Some(start..end)
+        let first_row = u64::from(top) / block;
+        let end_row = u64::from(bottom).div_ceil(block);
+        let left_byte = u64::from(left) / block * element;
+        let right_byte = u64::from(right).div_ceil(block) * element;
+        let start = u64::from(front) * slice + first_row * pitch + left_byte;
+        let end = u64::from(back - 1) * slice + (end_row - 1) * pitch + right_byte;
+        let rows = (front..back).flat_map(move |z| {
+            (first_row..end_row).map(move |row| {
+                let at = u64::from(z) * slice + row * pitch;
+                at + left_byte..at + right_byte
+            })
+        });
+        Some((start..end, rows))
     }
 }
 const _: () = assert!(size_of::<PlacedFootprint>() == 32);
@@ -1596,7 +1610,9 @@ mod tests {
             depth: 1,
             row_pitch: 256,
         };
-        assert_eq!(compressed.box_bytes([4, 4, 0, 10, 9, 1]), Some(264..536));
+        let (span, rows) = compressed.box_reads(Some([4, 4, 0, 10, 9, 1])).unwrap();
+        assert_eq!(span, 264..536);
+        assert_eq!(rows.collect::<Vec<_>>(), [264..280, 520..536]);
 
         let volume = PlacedFootprint {
             offset: 512,
@@ -1606,7 +1622,12 @@ mod tests {
             depth: 3,
             row_pitch: 256,
         };
-        assert_eq!(volume.box_bytes([1, 1, 1, 3, 3, 3]), Some(1028..2060));
+        let (span, rows) = volume.box_reads(Some([1, 1, 1, 3, 3, 3])).unwrap();
+        assert_eq!(span, 1028..2060);
+        assert_eq!(
+            rows.collect::<Vec<_>>(),
+            [1028..1036, 1284..1292, 1796..1804, 2052..2060]
+        );
     }
 
     #[test]
**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 11:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7129914427) One more case on `e8e5f49`: I used a 4-by-4 RGBA8 footprint with a 256-byte row pitch, a two-pixel box spanning two rows, and two separate tracked GPU copies. Each write covered exactly the eight bytes read from its row. The padding between the rows was left at its original value. The guest `CopyTextureRegion` still read the old CPU bytes at placed offset 512, even though both source rows held the new values after submission. The enclosing span has a gap, so no single producer covers it. The follow-up keeps the enclosing-span check first. When that misses, it checks the actual row ranges and uses the host copy if all selected rows have a covering write to the same shadow. Both offsets 512 and 516 read back all four expected pixels on WARP. The CPU-upload control and the BC1/3D footprint checks passed. The diagnostics suite passed 56 tests, and library Clippy passed with warnings denied. AI-assisted. Verified with synthetic data on WARP. The D3D12 debug layer was unavailable in this run. <details> <summary>Incremental patch on e8e5f49</summary> ```diff diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -1504,29 +1504,36 @@ impl HostList { .push(Step::GpuWrite(shadow.clone(), address, len)); } - /// The latest producer of this range if it wrote a covering host - /// copy on the GPU. Deferred CPU writes keep their upload snapshots. + /// The host copy when each range's latest producer covered it on the GPU. + /// Deferred CPU writes keep their upload snapshots. pub(crate) fn written_shadow( &self, - address: usize, - len: usize, + mut ranges: impl Iterator<Item = std::ops::Range<usize>>, ) -> Option<std::sync::Arc<crate::shadow::Shadow>> { - let end = address.checked_add(len)?; - let overlaps = |at: usize, size: usize| size != 0 && at < end && address < at + size; - for step in self.deferred().copies.iter().rev() { - match step { - Step::GpuWrite(shadow, at, size) if overlaps(*at, *size) => { - // A partial producer still needs the copy's CPU snapshot - // for bytes that subsequent refreshes can overwrite. - return (*at <= address && end <= at + size).then(|| shadow.clone()); + let deferred = self.deferred(); + let producer = |range: std::ops::Range<usize>| { + let overlaps = |at: usize, size: usize| { + size != 0 && at < range.end && range.start < at.saturating_add(size) + }; + for step in deferred.copies.iter().rev() { + match step { + Step::GpuWrite(shadow, at, size) if overlaps(*at, *size) => { + // A partial producer still needs the copy's CPU snapshot. + return (*at <= range.start && range.end <= at.saturating_add(*size)) + .then_some(shadow); + } + Step::Copy(dst, _, size) if overlaps(*dst, *size) => return None, + // Raw deferred CPU work can write this range too. + Step::Run(_) => return None, + _ => {} } - Step::Copy(dst, _, size) if overlaps(*dst, *size) => return None, - // Raw deferred CPU work can write this range too. - Step::Run(_) => return None, - _ => {} } - } - None + None + }; + let shadow = producer(ranges.next()?)?; + ranges + .all(|range| producer(range).is_some_and(|other| std::sync::Arc::ptr_eq(shadow, other))) + .then(|| shadow.clone()) } /// Stores `what` (`bytes` of it) at `dst` once the list has run. diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs --- a/crates/victory-gpu/src/list.rs +++ b/crates/victory-gpu/src/list.rs @@ -490,6 +490,7 @@ fn placed_copy_source( offset: u64, bytes: u64, read: &std::ops::Range<u64>, + rows: Option<impl Iterator<Item = std::ops::Range<u64>>>, ) -> Option<(windows::Win32::Graphics::Direct3D12::ID3D12Resource, u64)> { use windows::Win32::Graphics::Direct3D12::D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT; @@ -497,8 +498,12 @@ fn placed_copy_source( let address = data as u64; let read_address = address + read.start; let read_bytes = read.end - read.start; + let absolute = |range: std::ops::Range<u64>| { + (address + range.start) as usize..(address + range.end) as usize + }; let source = list - .written_shadow(read_address as usize, read_bytes as usize) + .written_shadow(std::iter::once(absolute(read.clone()))) + .or_else(|| list.written_shadow(rows?.map(absolute))) .and_then(|shadow| { let offset = shadow.offset_for_range(address, bytes)?; Some((shadow, offset)) @@ -576,11 +581,10 @@ extern "system" fn copy_texture_region( let Some(bytes) = src.footprint.bytes() else { return; }; - let read_span = source_box - .and_then(|bounds| src.footprint.box_bytes(*bounds)) - .unwrap_or(0..bytes); + let (read_span, rows) = src.footprint.box_reads(source_box.copied()).unzip(); + let read_span = read_span.unwrap_or(0..bytes); let Some((buffer, offset)) = - placed_copy_source(list, src.resource, src.footprint.offset, bytes, &read_span) + placed_copy_source(list, src.resource, src.footprint.offset, bytes, &read_span, rows) else { return; }; diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs --- a/crates/victory-gpu/src/resource.rs +++ b/crates/victory-gpu/src/resource.rs @@ -329,14 +329,21 @@ impl PlacedFootprint { let (element, block) = element(self.format)?; let lines = u64::from(self.height).div_ceil(block) * u64::from(self.depth); let last = u64::from(self.width).div_ceil(block) * element; - Some(u64::from(self.row_pitch) * lines.saturating_sub(1) + last) + u64::from(self.row_pitch) + .checked_mul(lines.saturating_sub(1))? + .checked_add(last) } - /// The byte span enclosing the rows and slices read by a source box. - pub(crate) fn box_bytes( + /// The enclosing byte span and exact row ranges used by a copy. + pub(crate) fn box_reads( &self, - [left, top, front, right, bottom, back]: [u32; 6], - ) -> Option<std::ops::Range<u64>> { + source_box: Option<[u32; 6]>, + ) -> Option<( + std::ops::Range<u64>, + impl Iterator<Item = std::ops::Range<u64>>, + )> { + let [left, top, front, right, bottom, back] = + source_box.unwrap_or([0, 0, 0, self.width, self.height, self.depth]); if left >= right || top >= bottom || front >= back @@ -347,15 +354,22 @@ impl PlacedFootprint { return None; } let (element, block) = element(self.format)?; + self.bytes()?; let pitch = u64::from(self.row_pitch); let slice = pitch * u64::from(self.height).div_ceil(block); - let start = u64::from(front) * slice - + u64::from(top) / block * pitch - + u64::from(left) / block * element; - let end = u64::from(back - 1) * slice - + (u64::from(bottom).div_ceil(block) - 1) * pitch - + u64::from(right).div_ceil(block) * element; - Some(start..end) + let first_row = u64::from(top) / block; + let end_row = u64::from(bottom).div_ceil(block); + let left_byte = u64::from(left) / block * element; + let right_byte = u64::from(right).div_ceil(block) * element; + let start = u64::from(front) * slice + first_row * pitch + left_byte; + let end = u64::from(back - 1) * slice + (end_row - 1) * pitch + right_byte; + let rows = (front..back).flat_map(move |z| { + (first_row..end_row).map(move |row| { + let at = u64::from(z) * slice + row * pitch; + at + left_byte..at + right_byte + }) + }); + Some((start..end, rows)) } } const _: () = assert!(size_of::<PlacedFootprint>() == 32); @@ -1596,7 +1610,9 @@ mod tests { depth: 1, row_pitch: 256, }; - assert_eq!(compressed.box_bytes([4, 4, 0, 10, 9, 1]), Some(264..536)); + let (span, rows) = compressed.box_reads(Some([4, 4, 0, 10, 9, 1])).unwrap(); + assert_eq!(span, 264..536); + assert_eq!(rows.collect::<Vec<_>>(), [264..280, 520..536]); let volume = PlacedFootprint { offset: 512, @@ -1606,7 +1622,12 @@ mod tests { depth: 3, row_pitch: 256, }; - assert_eq!(volume.box_bytes([1, 1, 1, 3, 3, 3]), Some(1028..2060)); + let (span, rows) = volume.box_reads(Some([1, 1, 1, 3, 3, 3])).unwrap(); + assert_eq!(span, 1028..2060); + assert_eq!( + rows.collect::<Vec<_>>(), + [1028..1036, 1284..1292, 1796..1804, 2052..2060] + ); } #[test] ``` </details>
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 11:24 UTC · original

Verified and integrated with BufferStates on our integration branch (PR https://github.com/LAKSHYA-cmd-tech/VIctory/pull/16). Resolves stale texture uploads when placed copies read from buffers modified earlier in the same command list, and correctly bounds read spans for boxed copies.

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 11:24 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7130048820) Verified and integrated with BufferStates on our integration branch (PR https://github.com/LAKSHYA-cmd-tech/VIctory/pull/16). Resolves stale texture uploads when placed copies read from buffers modified earlier in the same command list, and correctly bounds read spans for boxed copies.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 11:23 UTC · original · edited 2026-11-24 11:34 UTC

One more ordering case for the boxed-source change, complementary to the two-row example above. Melissa tested a single row containing two pixels, both backed by the same host buffer. On one guest command list, an earlier GPU clear writes both pixels, a later clear overwrites one, then a boxed copy reads both.

We applied the e8e5f49 box change to a branch with resource-backed typed buffer clears. A single covering clear produced [31, 31] as expected. With the partial overwrite, both destination pixels instead retained their old CPU values. In the backwards scan, the most recent overlapping producer covered only part of the row.

Continuing the scan across partial writes to the same host buffer finds the earlier covering producer. With that change the copy returned [17, 31] and all eight resource tests passed on RTX 4090 under Wine/GE 3.2. The scan still stops at a different backing buffer or an intervening CPU write. The linked commit contains the change and regression on the typed-clear comparison branch. Game use remains unmeasured. Comparison commit and test

We also combined andrewpozdnakov7-jpg’s pitched-row fallback with the partial-overwrite check. In one command list, separate GPU writes supplied two rows and a third write replaced only one pixel of the first row. With row fallback disabled, the destination retained its CPU markers. With both changes, the rows read back as [17, 31] and [43, 43] on RTX 4090 under Wine/GE 3.2. All eight resource tests passed. Combined patch and two-row test

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 11:23 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7130038573) · edited 2026-11-24 11:34 UTC One more ordering case for the boxed-source change, complementary to the two-row example above. Melissa tested a single row containing two pixels, both backed by the same host buffer. On one guest command list, an earlier GPU clear writes both pixels, a later clear overwrites one, then a boxed copy reads both. We applied the `e8e5f49` box change to a branch with resource-backed typed buffer clears. A single covering clear produced `[31, 31]` as expected. With the partial overwrite, both destination pixels instead retained their old CPU values. In the backwards scan, the most recent overlapping producer covered only part of the row. Continuing the scan across partial writes to the same host buffer finds the earlier covering producer. With that change the copy returned `[17, 31]` and all eight resource tests passed on RTX 4090 under Wine/GE 3.2. The scan still stops at a different backing buffer or an intervening CPU write. The linked commit contains the change and regression on the typed-clear comparison branch. Game use remains unmeasured. [Comparison commit and test](https://github.com/MichaelSmithAI/VIctory/commit/c255bfa632cd6a3fbcb5dc26c5d4fd94e020b786) We also combined andrewpozdnakov7-jpg’s pitched-row fallback with the partial-overwrite check. In one command list, separate GPU writes supplied two rows and a third write replaced only one pixel of the first row. With row fallback disabled, the destination retained its CPU markers. With both changes, the rows read back as `[17, 31]` and `[43, 43]` on RTX 4090 under Wine/GE 3.2. All eight resource tests passed. [Combined patch and two-row test](https://github.com/MichaelSmithAI/VIctory/commit/83fd0cef19fee1f2a67973ae5af367aeb4ded521)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:52 UTC · original

Automated triage for the maintainers. Confirmed on main: for a placed-footprint source, copy_texture_region in crates/victory-gpu/src/list.rs copies the source bytes from title memory into a new upload buffer (list.defer_fill) and copies the texture from that buffer. A GPU write to the source earlier in the same list is not in title memory yet when that fill runs, so the texture gets the old bytes.

Open PR #1374 (read same-list GPU writes in placed buffer-to-texture copies) addresses this. The boxed, pitched-row and partial-overwrite cases in the comments should be checked against it there.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/785#issuecomment-7152322583) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T11:24:06Z at=2026-11-25T03:52:38Z --> Automated triage for the maintainers. Confirmed on `main`: for a placed-footprint source, `copy_texture_region` in `crates/victory-gpu/src/list.rs` copies the source bytes from title memory into a new upload buffer (`list.defer_fill`) and copies the texture from that buffer. A GPU write to the source earlier in the same list is not in title memory yet when that fill runs, so the texture gets the old bytes. Open PR #1374 (read same-list GPU writes in placed buffer-to-texture copies) addresses this. The boxed, pitched-row and partial-overwrite cases in the comments should be checked against it there. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#785
No description provided.