GPU: check a sampled texture once per submission, not once per list
A title texture's staging refresh ran as a host step of every list that sampled it. When several lists in one submission sampled the same texture, it was checked again for each of them. In physical-page memory, which cannot be write-watched, each check is a VirtualQuery walk and a blake3 hash of the whole texture. Every list's GPU copy reads the same staging buffer after all submission-time steps have run, so checks after the first one in a submission did nothing unless title memory had been written in between. Texture refreshes are now their own step. The submission's Batch, which already merges buffer refreshes, records the staging buffers it has refreshed. A Copy into title memory or a Run step (work that may write title memory) clears that record, so a texture is checked again after any such write, as buffer refreshes are. A synthetic benchmark (ignored test, release build, 12 lists sampling 48 textures of 4 MiB): 576 hashes in ~690 ms before, 48 in ~60 ms after (~11x). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
35b054ec03
commit
73d776b9c9
2 files changed
+125
-9
No files matched your search
@@ -32,7 +32,7 @@ macro_rules! once {
|
||||
|
||||
/// A texture's upload state: the staging buffer laid out as the host
|
||||
/// texture's subresources, and what was last detiled.
|
||||
struct Staging {
|
||||
pub(crate) struct Staging {
|
||||
buffer: ID3D12Resource,
|
||||
/// Its bytes.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
@@ -165,13 +165,14 @@ pub(crate) fn upload(list: &HostList, resource: This, texture: &ID3D12Resource)
|
||||
// SAFETY: an open list; both locations name live resources.
|
||||
unsafe { list.list.CopyTextureRegion(&to, 0, 0, 0, &from, None) };
|
||||
}
|
||||
list.defer_host(move || staging.refresh());
|
||||
// Once per submission however many of its lists sample the texture.
|
||||
list.defer_texture(staging);
|
||||
}
|
||||
|
||||
impl Staging {
|
||||
/// Detiles the texture memory into the staging buffer if it changed
|
||||
/// since the last time (and is mapped at all).
|
||||
fn refresh(&self) {
|
||||
pub(crate) fn refresh(&self) {
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
let started = std::time::Instant::now();
|
||||
let read = self.refresh_now();
|
||||
|
||||
Reference in new issue
Block a user