A stand-in for the title's traced indirect light (VICTORY_AMBIENT, off): estimated from the light visible surfaces send out
After beloooo's constant (VIctory-Belobug-AMD 06031237, 4f45ab88, cd9f78ce). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c2d559893b
commit
1316d0819d
4 files changed
+548
No files matched your search
@@ -321,6 +321,10 @@ pub(crate) struct State {
|
||||
/// report of a removed device, `crate::host::indirects`).
|
||||
#[cfg(feature = "diagnostics")]
|
||||
user: Vec<u32>,
|
||||
/// The tables the last bind made afresh for a program the stand-in for
|
||||
/// the indirect light follows (`crate::ambient`): root parameter, bytes
|
||||
/// into the view heap.
|
||||
ambient_tables: Vec<(u8, u32)>,
|
||||
/// What the host list has: pipeline, root signature, heaps.
|
||||
host_pipeline: usize,
|
||||
/// Graphics, compute.
|
||||
@@ -1449,6 +1453,10 @@ impl State {
|
||||
once!("a draw whose descriptor table found no free slots is dropped");
|
||||
return false;
|
||||
}
|
||||
if stage.shader.ambient.is_some() {
|
||||
self.ambient_tables.clear();
|
||||
self.ambient_tables.extend(made.iter().copied());
|
||||
}
|
||||
// What the shader stores through root views and raw addresses is
|
||||
// copied back into title memory afterwards.
|
||||
let writes = (t.stores || !write_skip())
|
||||
@@ -2603,6 +2611,62 @@ impl State {
|
||||
unsafe { list.list.Dispatch(x, y, z) };
|
||||
self.buffers_written();
|
||||
DISPATCHED.fetch_add(1, Ordering::Relaxed);
|
||||
if let Some(role) = p.stages.first().and_then(|s| s.shader.ambient)
|
||||
&& crate::ambient::on()
|
||||
&& self.ambient(list, p, role)
|
||||
{
|
||||
self.host_pipeline = 0;
|
||||
self.host_roots[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// The stand-in for the indirect light after a dispatch of `p`
|
||||
/// (`crate::ambient`). Whether it recorded anything.
|
||||
fn ambient(&self, list: &HostList, p: &HostPipeline, role: crate::ambient::Role) -> bool {
|
||||
use crate::ambient::{DEPTH, LIGHT, RADIANCE, Role, Views};
|
||||
let Some(t) = p.stages.first().map(|s| s.translated()) else {
|
||||
return false;
|
||||
};
|
||||
let Some(heap) = (self.heaps[0] != 0).then(|| crate::descriptor::heap(self.heaps[0] as This).host()).flatten()
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
let entry = |kind: ResourceType, (slot, offset): (u8, u32)| {
|
||||
t.used.iter().find(|u| {
|
||||
u.kind == kind && u.root == RootType::Table && (u.slot, u.table_offset_dwords) == (slot, offset)
|
||||
})?;
|
||||
let Some(Root::Table(table)) = self.roots_ref(true).get(usize::from(slot)) else {
|
||||
return None;
|
||||
};
|
||||
let resource = match crate::descriptor::view(table + u64::from(offset) * 4)? {
|
||||
View::Shader(r, _) | View::Unordered(r, ..) => r,
|
||||
_ => return None,
|
||||
};
|
||||
let start = match self.ambient_tables.iter().find(|m| m.0 == slot) {
|
||||
Some(m) => m.1,
|
||||
None => self.user_value(true, slot, RootType::Table, 0),
|
||||
};
|
||||
let host = crate::resource::host_resource(resource as This)?;
|
||||
// SAFETY: a live resource.
|
||||
let desc = unsafe { host.GetDesc() };
|
||||
Some((desc, heap.gpu_handle((start + offset * 4) / 32)))
|
||||
};
|
||||
let image = entry(ResourceType::Uav, if role == Role::Resolve { LIGHT } else { RADIANCE });
|
||||
let depth = match role {
|
||||
Role::Resolve => entry(ResourceType::Srv, DEPTH),
|
||||
Role::Radiance => image,
|
||||
};
|
||||
let (Some((of, image)), Some((seen, depth))) = (image, depth) else {
|
||||
once!(?role, "no stand-in for the indirect light: other tables");
|
||||
return false;
|
||||
};
|
||||
// (R32_UINT holding R9G9B9E5; R11G11B10_FLOAT.)
|
||||
let format = if role == Role::Resolve { 42 } else { 26 };
|
||||
if of.Format.0 != format || (seen.Width, seen.Height) != (of.Width, of.Height) {
|
||||
once!(?role, format = of.Format.0, "no stand-in for the indirect light: another image");
|
||||
return false;
|
||||
}
|
||||
crate::ambient::after(list, role, &Views { image, depth, size: [of.Width as u32, of.Height] })
|
||||
}
|
||||
|
||||
/// What a draw or dispatch runs, for the device-removed report
|
||||
|
||||
Reference in new issue
Block a user