Publish the pareto-residency Windows build and portable launcher
This commit is contained in:
1 parent
efeef1d65b
commit
545f89019e
20 files changed
+1671
-217
No files matched your search
+396
-73
@@ -217,12 +217,45 @@ const BAKE_AHEAD: [u64; 2] = [12, 2];
|
||||
/// until something is new, the next bakes of the frame need no pass.
|
||||
static BAKE_SERVED: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// Free-threaded wrapper around a reusable upload-only [`HostList`] protected
|
||||
/// by [`BAKE_UPLOAD`]. D3D12 command allocators, lists, and retained COM
|
||||
/// resources are free-threaded when externally synchronized.
|
||||
struct BakeList(HostList);
|
||||
// SAFETY: accessed exclusively under `BAKE_UPLOAD`'s mutex.
|
||||
unsafe impl Send for BakeList {}
|
||||
|
||||
/// Serializes synchronous one-shot ped/decoration bake uploads across
|
||||
/// concurrent `VICTORY_THIN=1` recording threads and owns the reusable
|
||||
/// upload-only host command list.
|
||||
static BAKE_UPLOAD: std::sync::Mutex<Option<BakeList>> = std::sync::Mutex::new(None);
|
||||
|
||||
/// Pending descriptor publications for a synchronous bake upload pass: slots
|
||||
/// stay on `neutral()` (or their previous compatible view) until the dedicated
|
||||
/// upload list has finished executing on the host GPU.
|
||||
struct BakeSync {
|
||||
publish: Vec<(u32, u64, u64)>,
|
||||
keep: Vec<std::sync::Arc<crate::resource::HostTexture>>,
|
||||
}
|
||||
|
||||
/// The pixel shaders of the title's decoration bake (the title:
|
||||
/// `PS_BakeDecorations_*`), by the first 16 hex digits of their hash as the
|
||||
/// frame listings print it. They draw into a 256x256 corner of 2048x2048
|
||||
/// targets and name no texture in a table.
|
||||
pub(crate) const BAKE_PIXEL_SHADERS: [&str; 4] =
|
||||
["c0a7fe77b1862e10", "0d1575a396dfe513", "b7cfd8dda91ebb6b", "280967ad158cee0b"];
|
||||
pub(crate) const BAKE_PIXEL_SHADERS: [&str; 7] = [
|
||||
"c0a7fe77b1862e10",
|
||||
"0d1575a396dfe513",
|
||||
"b7cfd8dda91ebb6b",
|
||||
"280967ad158cee0b",
|
||||
"fa455c8a3c32577b",
|
||||
"d126bcae5d5d8d26",
|
||||
"fcee612943c008e0",
|
||||
];
|
||||
|
||||
/// Geometry stages shared by every ped texture compositor / decoration bake
|
||||
/// permutation (`vertex 089d6271be6650ef` fullscreen-triangle ped baker and
|
||||
/// `mesh d4111a6e6ea49d91` decoration projection mesh), catching pixel-shader
|
||||
/// permutations beyond `BAKE_PIXEL_SHADERS`.
|
||||
const BAKE_GEOMETRY_SHADERS: [&str; 2] = ["089d6271be6650ef", "d4111a6e6ea49d91"];
|
||||
|
||||
/// Since the start: early runs of the texture pass, and those of them
|
||||
/// made for a bake draw.
|
||||
@@ -1714,6 +1747,24 @@ impl State {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if srv && slot == victory_shader::emit::SLOT_TABLE_STRIDES {
|
||||
// Ours: the shader inspects typed view kinds for its
|
||||
// descriptor tables only (already mirrored by `tables`),
|
||||
// so bind the strides buffer without sweeping the heap.
|
||||
match self.heap_strides(list) {
|
||||
// SAFETY: an open list; the table lives as long
|
||||
// as the heap the list holds.
|
||||
Some(gpu) => unsafe {
|
||||
if compute {
|
||||
l.SetComputeRootShaderResourceView(param, gpu);
|
||||
} else {
|
||||
l.SetGraphicsRootShaderResourceView(param, gpu);
|
||||
}
|
||||
},
|
||||
None => once!("a shader inspects table view kinds without a view heap set"),
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let tabled = srv && crate::pipeline::host::bounded_root_srvs();
|
||||
let Some(&Root::View(address)) = self.roots_ref(compute).get(usize::from(slot))
|
||||
else {
|
||||
@@ -1872,7 +1923,10 @@ impl State {
|
||||
Some((index, shadow)) => (*index, address.zip(shadow.clone())),
|
||||
None => {
|
||||
let shadow = address.and_then(|a| find(a).map(|s| (a, s)));
|
||||
let Some(index) = host.dynamic(1) else {
|
||||
let Some(index) = host.dynamic(1).or_else(|| {
|
||||
crate::host::settle_for_fence();
|
||||
host.dynamic(1)
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
self.dynamic.push((key.0, index, 1));
|
||||
@@ -1943,7 +1997,10 @@ impl State {
|
||||
Some((index, shadow)) => (*index, address.zip(shadow.clone())),
|
||||
None => {
|
||||
let shadow = address.and_then(|a| crate::shadow::find(a, 1).map(|s| (a, s)));
|
||||
let Some(index) = host.dynamic(1) else {
|
||||
let Some(index) = host.dynamic(1).or_else(|| {
|
||||
crate::host::settle_for_fence();
|
||||
host.dynamic(1)
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
self.dynamic.push((key.0, index, 1));
|
||||
@@ -2053,7 +2110,7 @@ impl State {
|
||||
#[cfg(feature = "diagnostics")]
|
||||
let refreshed = std::time::Instant::now();
|
||||
stage.next("the heap pass: textures");
|
||||
self.heap_textures(list, heap, host);
|
||||
let _ = self.heap_textures(list, heap, host, None);
|
||||
stage.end();
|
||||
#[cfg(feature = "diagnostics")]
|
||||
HEAP_SPLIT[2].fetch_add(refreshed.elapsed().as_nanos() as u64, Ordering::Relaxed);
|
||||
@@ -2062,20 +2119,179 @@ impl State {
|
||||
Some(gpu)
|
||||
}
|
||||
|
||||
/// The GPU address of the bound view heap's stride/kind table without
|
||||
/// running the bindless heap buffer/texture sweep (for shaders that only
|
||||
/// inspect descriptors already mirrored via their descriptor tables).
|
||||
fn heap_strides(&self, list: &HostList) -> Option<u64> {
|
||||
let heap = self
|
||||
.heaps
|
||||
.iter()
|
||||
.filter(|&&h| h != 0)
|
||||
.map(|&h| crate::descriptor::heap(h as This))
|
||||
.find(|h| !h.samplers())?;
|
||||
let host = heap.host()?;
|
||||
let gpu = host.strides_gpu()?;
|
||||
// Tag bit 1 (distinct from `heap_buffers`'s `| 1` and aligned guest pointers).
|
||||
if list.first_use(gpu as usize | 2)
|
||||
&& let Some(buffer) = host.strides_buffer()
|
||||
{
|
||||
list.keep(buffer);
|
||||
}
|
||||
Some(gpu)
|
||||
}
|
||||
|
||||
/// Ensures textures claimed by background copy-queue uploads
|
||||
/// (`VICTORY_UPLOAD_AHEAD=1`) or deferred behind the `neutral()` gray
|
||||
/// stand-in (`VICTORY_SHOW_AFTER=1` / `shows_other`) have finished
|
||||
/// uploading and flipped to their real descriptors before a one-shot
|
||||
/// decoration bake draw samples them.
|
||||
fn flush_for_bake(
|
||||
&self,
|
||||
list: &HostList,
|
||||
host: &crate::descriptor::host::HostHeap,
|
||||
mut sync: Option<&mut BakeSync>,
|
||||
) {
|
||||
static RESCUED: [AtomicU64; 4] = [const { AtomicU64::new(0) }; 4];
|
||||
let drained = crate::texture::ahead::drain();
|
||||
let mut settled = false;
|
||||
let mut flipped = 0usize;
|
||||
for _ in 0..4 {
|
||||
let need_settle = host.needs_gpu_settle_for_bake();
|
||||
if need_settle {
|
||||
settled = true;
|
||||
crate::host::settle_for_fence();
|
||||
}
|
||||
flipped += host.texture_views_remade();
|
||||
flipped += host.texture_slots_flip();
|
||||
if !need_settle || !host.needs_gpu_settle_for_bake() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let pending = host.take_pending_list_flips();
|
||||
let mut promoted = 0usize;
|
||||
if !pending.is_empty() {
|
||||
let this_list = (std::ptr::from_ref(list) as usize, list.epoch());
|
||||
let sampled = UsedResource {
|
||||
kind: ResourceType::Srv,
|
||||
root: RootType::Table,
|
||||
table_offset_dwords: 0,
|
||||
lower_bound: 0,
|
||||
stride: 0,
|
||||
dwords: 8,
|
||||
user_data: 0,
|
||||
slot: 0,
|
||||
};
|
||||
for item in pending {
|
||||
let (origin, index, handle, key) = (item.origin, item.index(), item.handle(), item.key());
|
||||
if !host.slot_still_at(handle, key) {
|
||||
continue;
|
||||
}
|
||||
let Some(view) = crate::descriptor::view(handle) else {
|
||||
continue;
|
||||
};
|
||||
if let View::Placed(_, resource, desc) = &view {
|
||||
let address = u64::from(desc[10]) | u64::from(desc[11]) << 32;
|
||||
let len = crate::resource::placed_bytes(resource).unwrap_or(1);
|
||||
if crate::texture::mapped_bytes(address as *const u8, len as usize) == 0 {
|
||||
host.restore_pending_list_flip(item);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if sync.is_some() || origin != this_list {
|
||||
let placed = crate::descriptor::host::placed_texture(&view);
|
||||
if let Some(&View::Shader(resource, _)) = placed.as_ref().or(Some(&view)) {
|
||||
let resource = resource as This;
|
||||
let texture = crate::resource::host_resource(resource);
|
||||
let title_fills = texture.is_some_and(crate::texture::title_written);
|
||||
let first = match (&placed, &view) {
|
||||
(Some(_), View::Placed(_, _, desc)) => crate::resource::first_mip(desc),
|
||||
_ => 0,
|
||||
};
|
||||
if let (Some(sync), Some(copy)) = (sync.as_deref_mut(), crate::resource::host_copy(resource)) {
|
||||
sync.keep.push(copy);
|
||||
}
|
||||
if title_fills
|
||||
&& !crate::texture::ahead::there(resource)
|
||||
&& (sync.is_some() || !crate::texture::unchanged(resource, first))
|
||||
{
|
||||
let was_staged = crate::texture::is_staged(resource);
|
||||
let _ = crate::residency::take_staging_deferred();
|
||||
readable(list, sampled.kind, &view);
|
||||
let failed = crate::residency::take_staging_deferred() || crate::residency::upload_refused();
|
||||
if !was_staged {
|
||||
crate::texture::unstage(resource);
|
||||
}
|
||||
if failed {
|
||||
host.restore_pending_list_flip(item);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(sync) = sync.as_deref_mut() {
|
||||
sync.publish.push((index, handle, key));
|
||||
} else {
|
||||
let _ = host.mirror(index, handle, true);
|
||||
}
|
||||
promoted += 1;
|
||||
}
|
||||
}
|
||||
if drained > 0 || settled || flipped > 0 || promoted > 0 {
|
||||
let n = RESCUED[0].fetch_add(1, Ordering::Relaxed) + 1;
|
||||
let all_drained = RESCUED[1].fetch_add(drained as u64, Ordering::Relaxed) + drained as u64;
|
||||
let all_flipped = RESCUED[2].fetch_add(flipped as u64, Ordering::Relaxed) + flipped as u64;
|
||||
let all_promoted = RESCUED[3].fetch_add(promoted as u64, Ordering::Relaxed) + promoted as u64;
|
||||
if n.is_power_of_two() {
|
||||
tracing::info!(
|
||||
frame = crate::frame::current(),
|
||||
flushes = n,
|
||||
drained_ahead = all_drained,
|
||||
flipped = all_flipped,
|
||||
promoted_from_lists = all_promoted,
|
||||
settled,
|
||||
"flushed deferred texture stand-ins before decoration bake"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a graphics draw is a one-shot texture compositor / decoration
|
||||
/// bake whose bindless texture inputs must be flushed and up to date
|
||||
/// before recording the draw. Matches known bake pixel/geometry shaders
|
||||
/// and structurally detects depth-less 4+ MRT square atlas bakes
|
||||
/// (`>= 512x512`) so unseen NPC/head/clothing shader permutations never
|
||||
/// bake `neutral()` or `null` stand-ins into permanent ped textures.
|
||||
fn is_bake_draw(&self, p: &HostPipeline) -> bool {
|
||||
if p.stages.iter().any(|s| {
|
||||
let h = s.shader.hash.as_str();
|
||||
BAKE_PIXEL_SHADERS.contains(&h) || BAKE_GEOMETRY_SHADERS.contains(&h)
|
||||
}) {
|
||||
return true;
|
||||
}
|
||||
self.depth == 0
|
||||
&& self.targets.len() >= 4
|
||||
&& self
|
||||
.targets
|
||||
.first()
|
||||
.and_then(|&t| crate::resource::texture_kind(t as This))
|
||||
.is_some_and(|(w, h, _)| w >= 512 && w == u64::from(h))
|
||||
}
|
||||
|
||||
/// Runs the pass that uploads textures picked by index
|
||||
/// ([`State::heap_textures`]) where nothing has asked for it yet
|
||||
/// ([`early_budgets`]): once a frame for a few milliseconds, at the
|
||||
/// frame's first draw with a view heap set, and with a larger budget
|
||||
/// of its own before every draw whose pixel shader is one of the
|
||||
/// title's bake programs. The uploads are recorded into `list` ahead
|
||||
/// of the draw being bound, as the world's pass records them.
|
||||
/// title's bake programs. For decoration bakes, uploads run synchronously
|
||||
/// on a dedicated internal command list and descriptors are published only
|
||||
/// after the GPU copy finishes so concurrent `VICTORY_THIN=1` lists can
|
||||
/// never submit a bake draw ahead of its texture uploads.
|
||||
fn early_textures(&self, list: &HostList, p: &HostPipeline, compute: bool) {
|
||||
let (early_ms, bake_ms) = early_budgets();
|
||||
if compute || (early_ms == 0 && bake_ms == 0) {
|
||||
return;
|
||||
}
|
||||
let bake = bake_ms > 0
|
||||
&& p.stages.iter().any(|s| BAKE_PIXEL_SHADERS.contains(&s.shader.hash.as_str()));
|
||||
let is_bake = bake_ms > 0 && self.is_bake_draw(p);
|
||||
static FRAME: AtomicU64 = AtomicU64::new(u64::MAX);
|
||||
// The milliseconds this frame's bake draws have taken so far: a
|
||||
// frame has several, and together they get `bake_ms`.
|
||||
@@ -2085,15 +2301,9 @@ impl State {
|
||||
if first {
|
||||
BAKED_MS.store(0, Ordering::Relaxed);
|
||||
}
|
||||
let left = bake_ms.saturating_sub(BAKED_MS.load(Ordering::Relaxed));
|
||||
let budget = if bake && left > 0 {
|
||||
// What a bake may read must be there now: up to 2 GiB.
|
||||
(left, 2 << 30)
|
||||
} else if first && early_ms > 0 {
|
||||
(early_ms, 64 << 20)
|
||||
} else {
|
||||
if !is_bake && !(first && early_ms > 0) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
let Some(heap) = self
|
||||
.heaps
|
||||
.iter()
|
||||
@@ -2106,34 +2316,102 @@ impl State {
|
||||
let Some(host) = heap.host() else {
|
||||
return;
|
||||
};
|
||||
let bake = bake && left > 0;
|
||||
if bake && !first && bake_exact() {
|
||||
let (writes, noted) = host.texture_news();
|
||||
if !noted && BAKE_SERVED.load(Ordering::Relaxed) == writes + 1 {
|
||||
if is_bake {
|
||||
let began = std::time::Instant::now();
|
||||
let mut bake_slot = BAKE_UPLOAD.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let gpu = crate::host::host();
|
||||
if bake_slot.is_none()
|
||||
&& let Some(gpu) = gpu
|
||||
{
|
||||
match gpu.new_list() {
|
||||
Ok(upload_list) => *bake_slot = Some(BakeList(upload_list)),
|
||||
Err(e) => tracing::warn!(error = %e, "no host list for synchronous bake uploads"),
|
||||
}
|
||||
}
|
||||
let exact = bake_exact();
|
||||
if let (Some(gpu), Some(BakeList(bake_list))) = (gpu, bake_slot.as_ref()) {
|
||||
let mut sync = BakeSync { publish: Vec::new(), keep: Vec::new() };
|
||||
crate::texture::BAKING.set(exact);
|
||||
self.flush_for_bake(bake_list, host, Some(&mut sync));
|
||||
let left = bake_ms.saturating_sub(BAKED_MS.load(Ordering::Relaxed));
|
||||
let run_pass = left > 0
|
||||
&& (first
|
||||
|| !exact
|
||||
|| {
|
||||
let (writes, noted) = host.texture_news();
|
||||
noted || BAKE_SERVED.load(Ordering::Relaxed) != writes + 1
|
||||
});
|
||||
let mut served = false;
|
||||
if run_pass {
|
||||
let n = EARLY_TEXTURE_PASSES[1].fetch_add(1, Ordering::Relaxed) + 1;
|
||||
if n.is_power_of_two() {
|
||||
let [slots, due, ..] = HEAP_TEXTURES_QUEUE.each_ref().map(|c| c.load(Ordering::Relaxed));
|
||||
tracing::info!(
|
||||
frame,
|
||||
bakes = n,
|
||||
queued_at_the_last_pass = slots,
|
||||
due_at_the_last_pass = due,
|
||||
uploaded_so_far = HEAP_TEXTURES.load(Ordering::Relaxed),
|
||||
"a draw of the title's decoration bake: textures picked by index are uploaded synchronously first (VICTORY_BAKE_TEXTURES_MS=0: not)"
|
||||
);
|
||||
}
|
||||
BAKE_SERVED.store(0, Ordering::Relaxed);
|
||||
PASS_BUDGET.set(Some((left, 2 << 30, true)));
|
||||
served = self.heap_textures(bake_list, heap, host, Some(&mut sync));
|
||||
PASS_BUDGET.set(None);
|
||||
}
|
||||
crate::texture::BAKING.set(false);
|
||||
if bake_list.has_recorded_work() {
|
||||
bake_list.close();
|
||||
gpu.execute_sync_internal(bake_list);
|
||||
bake_list.reset();
|
||||
} else if !sync.publish.is_empty() {
|
||||
crate::host::settle_for_fence();
|
||||
}
|
||||
for (index, handle, key) in sync.publish {
|
||||
let _ = host.publish_uploaded_slot(index, handle, key);
|
||||
}
|
||||
host.texture_views_remade();
|
||||
host.texture_slots_flip();
|
||||
drop(sync.keep);
|
||||
if run_pass && served && exact {
|
||||
BAKE_SERVED.store(host.texture_news().0 + 1, Ordering::Relaxed);
|
||||
}
|
||||
BAKED_MS.fetch_add(began.elapsed().as_millis() as u64, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
let n = EARLY_TEXTURE_PASSES[usize::from(bake)].fetch_add(1, Ordering::Relaxed) + 1;
|
||||
if bake && n.is_power_of_two() {
|
||||
let [slots, due, ..] = HEAP_TEXTURES_QUEUE.each_ref().map(|c| c.load(Ordering::Relaxed));
|
||||
tracing::info!(
|
||||
frame,
|
||||
bakes = n,
|
||||
queued_at_the_last_pass = slots,
|
||||
due_at_the_last_pass = due,
|
||||
uploaded_so_far = HEAP_TEXTURES.load(Ordering::Relaxed),
|
||||
"a draw of the title's decoration bake: textures picked by index are uploaded first (VICTORY_BAKE_TEXTURES_MS=0: not)"
|
||||
);
|
||||
}
|
||||
let began = std::time::Instant::now();
|
||||
PASS_BUDGET.set(Some((budget.0, budget.1, bake)));
|
||||
crate::texture::BAKING.set(bake && bake_exact());
|
||||
self.heap_textures(list, heap, host);
|
||||
crate::texture::BAKING.set(false);
|
||||
PASS_BUDGET.set(None);
|
||||
if bake {
|
||||
// Fallback when no host GPU list can be created (e.g. headless tests).
|
||||
crate::texture::BAKING.set(exact);
|
||||
self.flush_for_bake(list, host, None);
|
||||
crate::texture::BAKING.set(false);
|
||||
let left = bake_ms.saturating_sub(BAKED_MS.load(Ordering::Relaxed));
|
||||
if left == 0 {
|
||||
return;
|
||||
}
|
||||
if !first && exact {
|
||||
let (writes, noted) = host.texture_news();
|
||||
if !noted && BAKE_SERVED.load(Ordering::Relaxed) == writes + 1 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
EARLY_TEXTURE_PASSES[1].fetch_add(1, Ordering::Relaxed);
|
||||
PASS_BUDGET.set(Some((left, 2 << 30, true)));
|
||||
crate::texture::BAKING.set(exact);
|
||||
let _ = self.heap_textures(list, heap, host, None);
|
||||
crate::texture::BAKING.set(false);
|
||||
PASS_BUDGET.set(None);
|
||||
BAKED_MS.fetch_add(began.elapsed().as_millis() as u64, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
let budget = if first && early_ms > 0 {
|
||||
(early_ms, 64 << 20)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
EARLY_TEXTURE_PASSES[0].fetch_add(1, Ordering::Relaxed);
|
||||
PASS_BUDGET.set(Some((budget.0, budget.1, false)));
|
||||
let _ = self.heap_textures(list, heap, host, None);
|
||||
PASS_BUDGET.set(None);
|
||||
}
|
||||
|
||||
/// The queue's side of the card accounting line
|
||||
@@ -2230,10 +2508,11 @@ impl State {
|
||||
list: &HostList,
|
||||
heap: &crate::descriptor::Heap,
|
||||
host: &crate::descriptor::host::HostHeap,
|
||||
) {
|
||||
mut sync: Option<&mut BakeSync>,
|
||||
) -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
if !*ON.get_or_init(|| std::env::var_os("VICTORY_HEAP_TEXTURES").is_none_or(|v| v != "0")) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
let memory = crate::host::host().and_then(|h| h.video_memory());
|
||||
// `VICTORY_TEXTURE_STAGE_MB` sets it: a backlog of tens of thousands of
|
||||
@@ -2285,6 +2564,10 @@ impl State {
|
||||
// Slots whose texture's memory the runtime mapped, unmapped or
|
||||
// wrote since the last pass are due again.
|
||||
host.texture_slots_remapped(frame);
|
||||
let baking = crate::texture::BAKING.get();
|
||||
if baking {
|
||||
host.texture_slots_bake_written(frame);
|
||||
}
|
||||
host.texture_slots_short(frame);
|
||||
// The slots of textures whose first level with memory (levels on
|
||||
// demand), or whose host copy for one with more levels, changed since
|
||||
@@ -2298,11 +2581,6 @@ impl State {
|
||||
host.texture_slots_waiting(frame);
|
||||
}
|
||||
let required = PASS_BUDGET.get().is_some_and(|(_, _, bake)| bake);
|
||||
if !crate::residency::admit_texture_pass(required) {
|
||||
BAKE_SERVED.store(0, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
let baking = crate::texture::BAKING.get();
|
||||
let (mut due, census) = host.texture_slots_due(frame, if baking { 1 << 16 } else { 4096 });
|
||||
// (Those that are due later after all that are due.)
|
||||
let on_time = due.len();
|
||||
@@ -2370,17 +2648,22 @@ impl State {
|
||||
let bytes_at_most = if required || asked.is_some() {
|
||||
bytes_at_most
|
||||
} else {
|
||||
crate::residency::prefetch_limit(bytes_at_most, crate::residency::pressured(),
|
||||
crate::residency::limited_host_ram(), crate::texture::live_staging_bytes())
|
||||
crate::residency::prefetch_limit(
|
||||
bytes_at_most,
|
||||
crate::residency::pressured(),
|
||||
crate::residency::critical_commit(),
|
||||
crate::residency::limited_host_ram(),
|
||||
crate::texture::live_staging_bytes(),
|
||||
)
|
||||
};
|
||||
|
||||
let began = std::time::Instant::now();
|
||||
BAKE_SERVED.store(0, Ordering::Relaxed);
|
||||
if sync.is_none() {
|
||||
BAKE_SERVED.store(0, Ordering::Relaxed);
|
||||
}
|
||||
let mut served = true;
|
||||
for (index, write) in due {
|
||||
if SPENT.load(Ordering::Relaxed) >= bytes_at_most || began.elapsed() > span
|
||||
|| !crate::residency::admit_texture_pass(required)
|
||||
{
|
||||
if SPENT.load(Ordering::Relaxed) >= bytes_at_most || began.elapsed() > span {
|
||||
served = false;
|
||||
break;
|
||||
}
|
||||
@@ -2524,23 +2807,41 @@ impl State {
|
||||
);
|
||||
}
|
||||
}
|
||||
// Gate new host texture creation / staging on commit reserve after
|
||||
// `mapped == 0` reclamation (`texture_slot_gone`) has run, and
|
||||
// before mirroring a slot to an unuploaded texture.
|
||||
if !crate::residency::admit_texture_pass(required) {
|
||||
served = false;
|
||||
break;
|
||||
}
|
||||
// A slot that shows the texture by an earlier view of it (one
|
||||
// from another level) goes on doing so until the upload of what
|
||||
// the new one shows has run.
|
||||
let sync_bake = sync.is_some();
|
||||
let shows_other = !baking
|
||||
&& !sync_bake
|
||||
&& crate::resource::held_only()
|
||||
&& heap.handle(index).is_some_and(|handle| host.texture_slot_shows_other(index, handle));
|
||||
// A slot that shows nothing of it yet, or something else, shows it
|
||||
// when the upload has run too.
|
||||
let late = !shows_other
|
||||
&& !baking
|
||||
&& !sync_bake
|
||||
&& crate::descriptor::host::show_after()
|
||||
&& heap.handle(index).is_some_and(|handle| !host.texture_slot_made_from(index, handle));
|
||||
let view = heap.handle(index).and_then(|handle| {
|
||||
if shows_other || late { crate::descriptor::view(handle) } else { host.mirror(index, handle, true) }
|
||||
});
|
||||
let (view, bake_key) = if sync_bake {
|
||||
match heap.handle(index).and_then(|handle| host.prepare_bake_slot(index, handle)) {
|
||||
Some((view, key)) => (Some(view), Some(key)),
|
||||
None => (None, None),
|
||||
}
|
||||
} else {
|
||||
let view = heap.handle(index).and_then(|handle| {
|
||||
if shows_other || late { crate::descriptor::view(handle) } else { host.mirror(index, handle, true) }
|
||||
});
|
||||
(view, None)
|
||||
};
|
||||
let at_once = || {
|
||||
if late && let Some(handle) = heap.handle(index) {
|
||||
if (late || bake_key.is_some()) && let Some(handle) = heap.handle(index) {
|
||||
let _ = host.mirror(index, handle, true);
|
||||
}
|
||||
};
|
||||
@@ -2581,16 +2882,23 @@ impl State {
|
||||
let same = !tabled && crate::texture::unchanged(resource, first);
|
||||
if same {
|
||||
HEAP_TEXTURES_SAME.fetch_add(1, Ordering::Relaxed);
|
||||
if shows_other && let Some(handle) = heap.handle(index) {
|
||||
let _ = host.mirror(index, handle, true);
|
||||
}
|
||||
// Its bytes are in, or on the way there in a list before.
|
||||
if late && texture.is_some_and(crate::pool::fresh) && !crate::texture::ahead::there(resource) {
|
||||
if let Some(handle) = heap.handle(index) {
|
||||
host.texture_slot_show_after(list, index, handle);
|
||||
if let (Some(sync), Some(key), Some(handle)) = (sync.as_deref_mut(), bake_key, heap.handle(index)) {
|
||||
if let Some(copy) = crate::resource::host_copy(resource) {
|
||||
sync.keep.push(copy);
|
||||
}
|
||||
sync.publish.push((index, handle, key));
|
||||
} else {
|
||||
at_once();
|
||||
if shows_other && let Some(handle) = heap.handle(index) {
|
||||
let _ = host.mirror(index, handle, true);
|
||||
}
|
||||
// Its bytes are in, or on the way there in a list before.
|
||||
if late && texture.is_some_and(crate::pool::fresh) && !crate::texture::ahead::there(resource) {
|
||||
if let Some(handle) = heap.handle(index) {
|
||||
host.texture_slot_show_after(list, index, handle);
|
||||
}
|
||||
} else {
|
||||
at_once();
|
||||
}
|
||||
}
|
||||
let again = partly.map(|mapped| (frame + 1, mapped));
|
||||
let memory = if again.is_none() && heap_recheck() { crate::texture::title_span(resource, first) } else { None };
|
||||
@@ -2625,6 +2933,7 @@ impl State {
|
||||
break;
|
||||
}
|
||||
let late = late && ahead.is_none();
|
||||
let _ = crate::residency::take_staging_deferred();
|
||||
if let Some(view) = &view
|
||||
&& ahead.is_none()
|
||||
{
|
||||
@@ -2634,12 +2943,21 @@ impl State {
|
||||
readable(list, sampled.kind, view);
|
||||
crate::texture::PICKING.set(None);
|
||||
}
|
||||
// A failed allocation leaves this slot due. Publishing it or
|
||||
// marking it served would lose the only retry for some materials.
|
||||
if ahead.is_none() && crate::residency::upload_refused() {
|
||||
// A failed or deferred staging allocation leaves this slot due.
|
||||
// Publishing it or marking it served would lose the only retry for
|
||||
// some materials.
|
||||
if ahead.is_none()
|
||||
&& (crate::residency::take_staging_deferred() || crate::residency::upload_refused())
|
||||
{
|
||||
served = false;
|
||||
break;
|
||||
}
|
||||
if let (Some(sync), Some(key), Some(handle)) = (sync.as_deref_mut(), bake_key, heap.handle(index)) {
|
||||
if let Some(copy) = crate::resource::host_copy(resource) {
|
||||
sync.keep.push(copy);
|
||||
}
|
||||
sync.publish.push((index, handle, key));
|
||||
}
|
||||
if shows_other && let Some(handle) = heap.handle(index) {
|
||||
host.texture_slot_flip(list, index, handle);
|
||||
}
|
||||
@@ -2672,7 +2990,7 @@ impl State {
|
||||
let text: String = format!("{view:?}").chars().take(300).collect();
|
||||
tracing::error!(why, slot = index, "the host device went while textures picked by index were made ready; last: {text}");
|
||||
crate::host::log_removal_context();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
let (bytes, whole) = crate::texture::staged(resource, there.is_none()).unwrap_or((0, true));
|
||||
// Not all of it there: looked at again next frame, and from
|
||||
@@ -2723,9 +3041,10 @@ impl State {
|
||||
None => host.texture_slot_done(index, write, again),
|
||||
}
|
||||
}
|
||||
if baking && served {
|
||||
if sync.is_none() && baking && served {
|
||||
BAKE_SERVED.store(host.texture_news().0 + 1, Ordering::Relaxed);
|
||||
}
|
||||
served
|
||||
}
|
||||
|
||||
/// For the frame listing, after a dropped dispatch's line: its group
|
||||
@@ -3440,7 +3759,10 @@ impl State {
|
||||
made.push((slot, first * 32));
|
||||
continue;
|
||||
}
|
||||
let Some(first) = host.dynamic(n) else {
|
||||
let Some(first) = host.dynamic(n).or_else(|| {
|
||||
crate::host::settle_for_fence();
|
||||
host.dynamic(n)
|
||||
}) else {
|
||||
// No room: the draw must not run with the title's own
|
||||
// offsets (slots never made for it); `bind` drops it.
|
||||
made.push((slot, u32::MAX));
|
||||
@@ -3488,11 +3810,12 @@ impl State {
|
||||
TESTED_DEPTH.set((tested.0, true));
|
||||
}
|
||||
} else if let Some(view) = crate::descriptor::host::listed_view(recording, words) {
|
||||
let _ = crate::residency::take_staging_deferred();
|
||||
TESTED_DEPTH.set((tested.0, false));
|
||||
readable(list, kind, &view);
|
||||
let depth = TESTED_DEPTH.get().1;
|
||||
TESTED_DEPTH.set((tested.0, tested.1 || depth));
|
||||
if kind == ResourceType::Srv {
|
||||
if kind == ResourceType::Srv && !crate::residency::take_staging_deferred() {
|
||||
listed.ready = (list.epoch(), tested.0, depth);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user