From f89b79db0cc47a613a7a84dd57bbe47344aafe51 Mon Sep 17 00:00:00 2001 From: readmet3xt-lab <238408149+readmet3xt-lab@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:51:40 +0530 Subject: [PATCH] Reflections stand-in: the rays' image and depth found by kind where a miss variant binds them elsewhere Run final-1 (2026-11-27 01:44, VICTORY_AMBIENT_SPECULAR=1): the stand-in ran in one 10-second window only (27 frames, 56 dispatches); 416 dispatches of CS_RayMiss were left as the title had them, the log saying "other tables": variants of the miss program bind the rays' image and the depth at other places of their tables than 06bb6e728c7c99bf's (1,104) and (0,1000). Where the usual place has nothing, the first table entry of that kind that fits is taken: a 2D R11G11B10 image; a 2D 32-bit depth (typeless or D32, with or without stencil) at least the image's size and at most four times its width. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/draw.rs | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 3fa0183..fafc1a8 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -3820,10 +3820,46 @@ impl State { Role::Air => AIR, Role::Miss => MISS_LIGHT, }; - let image = entry(ResourceType::Uav, at); + // Variants of the miss program bind the rays' image and the depth at + // other places of their tables than the one found first (run + // final-1: 416 of 472 dispatches had "other tables"): where the + // usual place has none, the first table entry of that kind that + // fits (a 2D R11G11B10 image; a 2D 32-bit depth at least its size). + let scan = |kind: ResourceType, fits: &dyn Fn(&D3D12_RESOURCE_DESC) -> bool| { + t.used + .iter() + .filter(|u| u.kind == kind && u.root == RootType::Table) + .filter_map(|u| entry(kind, (u.slot, u.table_offset_dwords))) + .find(|(desc, _)| fits(desc)) + }; + let image = match role { + Role::Miss => entry(ResourceType::Uav, at).or_else(|| { + scan(ResourceType::Uav, &|d| { + d.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && d.Format.0 == 26 + }) + }), + _ => entry(ResourceType::Uav, at), + }; let depth = match role { Role::Resolve => entry(ResourceType::Srv, DEPTH), - Role::Miss => entry(ResourceType::Srv, MISS_DEPTH), + Role::Miss => entry(ResourceType::Srv, MISS_DEPTH).or_else(|| { + let half = image.as_ref().map(|(d, _)| (d.Width, d.Height)); + scan(ResourceType::Srv, &|d| { + use windows::Win32::Graphics::Dxgi::Common::{ + DXGI_FORMAT_D32_FLOAT, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, DXGI_FORMAT_R32_TYPELESS, + DXGI_FORMAT_R32G8X24_TYPELESS, + }; + d.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D + && matches!( + d.Format, + DXGI_FORMAT_R32_TYPELESS + | DXGI_FORMAT_D32_FLOAT + | DXGI_FORMAT_R32G8X24_TYPELESS + | DXGI_FORMAT_D32_FLOAT_S8X24_UINT + ) + && half.is_some_and(|(w, h)| d.Width >= w && d.Height >= h && d.Width <= w * 4) + }) + }), Role::Radiance | Role::Air => image, }; let (Some((of, image)), Some((seen, depth))) = (image, depth) else {