fix(gpu): bind ambient depth only to a matching SRV
Only the resolve pass uses depth. Require the correct descriptor type and matching dimensions to prevent D3D12 error 646.
This commit is contained in:
1 parent
033be27f33
commit
c05b44b34a
2 files changed
+24
-12
No files matched your search
@@ -430,7 +430,7 @@ pub(crate) struct Views {
|
|||||||
/// The image the title's program just wrote.
|
/// The image the title's program just wrote.
|
||||||
pub(crate) image: D3D12_GPU_DESCRIPTOR_HANDLE,
|
pub(crate) image: D3D12_GPU_DESCRIPTOR_HANDLE,
|
||||||
/// The scene's depth, for [`Role::Resolve`].
|
/// The scene's depth, for [`Role::Resolve`].
|
||||||
pub(crate) depth: D3D12_GPU_DESCRIPTOR_HANDLE,
|
pub(crate) depth: Option<D3D12_GPU_DESCRIPTOR_HANDLE>,
|
||||||
/// The size of the image, and how many slices it has.
|
/// The size of the image, and how many slices it has.
|
||||||
pub(crate) size: [u32; 2],
|
pub(crate) size: [u32; 2],
|
||||||
pub(crate) slices: u32,
|
pub(crate) slices: u32,
|
||||||
@@ -484,7 +484,9 @@ pub(crate) fn after(list: &HostList, role: Role, views: &Views) -> bool {
|
|||||||
uav_barrier(l);
|
uav_barrier(l);
|
||||||
l.SetComputeRootSignature(&pass.root);
|
l.SetComputeRootSignature(&pass.root);
|
||||||
l.SetComputeRoot32BitConstants(0, 12, words.as_ptr().cast(), 0);
|
l.SetComputeRoot32BitConstants(0, 12, words.as_ptr().cast(), 0);
|
||||||
l.SetComputeRootDescriptorTable(1, views.depth);
|
if let Some(depth) = views.depth {
|
||||||
|
l.SetComputeRootDescriptorTable(1, depth);
|
||||||
|
}
|
||||||
l.SetComputeRootDescriptorTable(2, views.image);
|
l.SetComputeRootDescriptorTable(2, views.image);
|
||||||
l.SetComputeRootUnorderedAccessView(3, pass.cells.GetGPUVirtualAddress());
|
l.SetComputeRootUnorderedAccessView(3, pass.cells.GetGPUVirtualAddress());
|
||||||
l.SetComputeRootUnorderedAccessView(4, pass.points.GetGPUVirtualAddress());
|
l.SetComputeRootUnorderedAccessView(4, pass.points.GetGPUVirtualAddress());
|
||||||
|
|||||||
@@ -2735,8 +2735,9 @@ impl State {
|
|||||||
let Some(Root::Table(table)) = self.roots_ref(true).get(usize::from(slot)) else {
|
let Some(Root::Table(table)) = self.roots_ref(true).get(usize::from(slot)) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let resource = match crate::descriptor::view(table + u64::from(offset) * 4)? {
|
let resource = match (kind, crate::descriptor::view(table + u64::from(offset) * 4)?) {
|
||||||
View::Shader(r, _) | View::Unordered(r, ..) => r,
|
(ResourceType::Srv, View::Shader(r, _))
|
||||||
|
| (ResourceType::Uav, View::Unordered(r, ..)) => r,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
let start = match self.ambient_tables.iter().find(|m| m.0 == slot) {
|
let start = match self.ambient_tables.iter().find(|m| m.0 == slot) {
|
||||||
@@ -2753,19 +2754,28 @@ impl State {
|
|||||||
Role::Radiance => RADIANCE,
|
Role::Radiance => RADIANCE,
|
||||||
Role::Air => AIR,
|
Role::Air => AIR,
|
||||||
};
|
};
|
||||||
let image = entry(ResourceType::Uav, at);
|
let Some((of, image)) = entry(ResourceType::Uav, at) else {
|
||||||
let depth = match role {
|
once!(?role, "no stand-in for the indirect light: missing image UAV");
|
||||||
Role::Resolve => entry(ResourceType::Srv, DEPTH),
|
|
||||||
Role::Radiance | Role::Air => image,
|
|
||||||
};
|
|
||||||
let (Some((of, image)), Some((seen, depth))) = (image, depth) else {
|
|
||||||
once!(?role, "no stand-in for the indirect light: other tables");
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
let depth = match role {
|
||||||
|
Role::Resolve => {
|
||||||
|
let Some((seen, depth)) = entry(ResourceType::Srv, DEPTH) else {
|
||||||
|
once!(?role, "no stand-in for the indirect light: missing depth SRV");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (seen.Width, seen.Height) != (of.Width, of.Height) {
|
||||||
|
once!(?role, "no stand-in for the indirect light: depth dimensions differ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Some(depth)
|
||||||
|
}
|
||||||
|
Role::Radiance | Role::Air => None,
|
||||||
|
};
|
||||||
// (R32_UINT holding R9G9B9E5; R11G11B10_FLOAT.)
|
// (R32_UINT holding R9G9B9E5; R11G11B10_FLOAT.)
|
||||||
let format = if role == Role::Resolve { 42 } else { 26 };
|
let format = if role == Role::Resolve { 42 } else { 26 };
|
||||||
let volume = of.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D;
|
let volume = of.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D;
|
||||||
if of.Format.0 != format || (seen.Width, seen.Height) != (of.Width, of.Height) || volume != (role == Role::Air) {
|
if of.Format.0 != format || volume != (role == Role::Air) {
|
||||||
once!(?role, format = of.Format.0, "no stand-in for the indirect light: another image");
|
once!(?role, format = of.Format.0, "no stand-in for the indirect light: another image");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user