Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/victory-gpu/src/ambient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ void place(uint3 at : SV_DispatchThreadID) {
float2 size = float2(width, height);
float3 p = seen(int2((float2(at.xy) + 0.5) * size / float2(CX, CY)), size);
float wz = min(p.z, 50.0);
cells[CELLS + 1 + at.y * CX + at.x] = float4(p, wz * wz);
float3 pc = p * (wz / max(p.z, 1e-6));
cells[CELLS + 1 + at.y * CX + at.x] = float4(pc, wz * wz);
}
#endif

Expand Down Expand Up @@ -464,7 +465,7 @@ pub(crate) struct Views {
/// The image the title's program just wrote.
pub(crate) image: D3D12_GPU_DESCRIPTOR_HANDLE,
/// 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, the size of the depth texture, and how many slices it has.
pub(crate) size: [u32; 2],
pub(crate) depth_size: [u32; 2],
Expand Down Expand Up @@ -522,7 +523,9 @@ pub(crate) fn after(list: &HostList, role: Role, views: &Views) -> bool {
uav_barrier(l);
l.SetComputeRootSignature(&pass.root);
l.SetComputeRoot32BitConstants(0, 16, 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.SetComputeRootUnorderedAccessView(3, pass.cells.GetGPUVirtualAddress());
l.SetComputeRootUnorderedAccessView(4, pass.points.GetGPUVirtualAddress());
Expand Down
20 changes: 12 additions & 8 deletions crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3234,27 +3234,31 @@ impl State {
Role::Radiance => RADIANCE,
Role::Air => AIR,
};
let image = entry(ResourceType::Uav, at);
let depth = match role {
Role::Resolve => entry(ResourceType::Srv, DEPTH),
Role::Radiance | Role::Air => image,
};
let (Some((of, image)), Some((seen, depth))) = (image, depth) else {
let Some((of, image)) = entry(ResourceType::Uav, at) else {
once!(?role, "no stand-in for the indirect light: other tables");
return false;
};
let (depth, depth_size) = if role == Role::Resolve {
let Some((seen, depth)) = entry(ResourceType::Srv, DEPTH) else {
once!(?role, "no stand-in for the indirect light: other tables");
return false;
};
(Some(depth), [seen.Width as u32, seen.Height])
} else {
(None, [of.Width as u32, of.Height])
};
// (R32_UINT holding R9G9B9E5; R11G11B10_FLOAT.)
let format = if role == Role::Resolve { 42 } else { 26 };
let volume = of.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D;
if of.Format.0 != format || seen.Width == 0 || seen.Height == 0 || volume != (role == Role::Air) {
if of.Format.0 != format || depth_size[0] == 0 || depth_size[1] == 0 || volume != (role == Role::Air) {
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],
depth_size: [seen.Width as u32, seen.Height],
depth_size,
slices: u32::from(of.DepthOrArraySize),
})
}
Expand Down
Loading