D3D12.X: native top-level table for XCL_HW_RT_TRAVERSE #3704

Open
Kalmarv wants to merge 5 commits from upstream-pr/3704 into main
Kalmarv commented 2026-12-02 15:46:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:46:04Z.


Add the GPU-visible native top-level acceleration-structure table (hle::d3d12x::hw_rt_table), Shader::native_tlas lookup helper, and hw_rt::traverse_enabled() gating for XCL_HW_RT_TRAVERSE=1. Off by default (no shaders read the table yet; Caller: #3705, direct-DXIL GPURT traversal loop swap).

Part of #1751. Stacked on #3700 and #3659: its commit 70c8c51f3 is #3659's 5bfb22746; only 0e42eb3f8 belongs here.
Related: #2184, #2185, #2186, #2187, #2188, #2189.

Shared descriptor heap shift: Reserves 9 fixed descriptors in the shared view heap (MEM_HW_RT_TABLE = MEM_NULL_STORE + 1, followed by 8 MEM_HW_RT_TLAS slots), shifting MEM_FIXED_END (the first dynamically allocated console descriptor heap slice) from MEM_NULL_STORE + 1 to MEM_NULL_STORE + 10 (+9 descriptors). When XCL_HW_RT_TRAVERSE is off, init_views returns early so no upload buffer is created and those 9 slots keep fill_nulls' Texture2D null views, which nothing reads because no shader is swapped.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs: reserve MEM_HW_RT_TABLE and MEM_HW_RT_SLOTS (8) MEM_HW_RT_TLAS descriptors, advancing MEM_FIXED_END.
  • crates/xcl/src/hle/d3d12x/console_heap.rs: call hw_rt_table::init_views only for the heap that wins GLOBAL (after releasing GLOBAL so descriptor hooks cannot deadlock on it; fill_nulls already wrote valid null views into those slots before publication), and start dynamic slice allocation at MEM_FIXED_END.
  • crates/xcl/src/hle/d3d12x/hw_rt_table.rs & mod.rs: Table state machine + mapped upload buffer and descriptor writer.
    • Complete native TLASes are published only after STABLE_FRAMES (4) presents in the same native buffer, taken out immediately when relocated/invalidated/incomplete, and freed slots are quarantined for STABLE_FRAMES presents.
    • init_views / init_views_in is idempotent and checks/installs under GPU so concurrent first callers can never overwrite Gpu.cpu with a losing heap or drop a live upload buffer; covered by WARP FL12_0 regression test init_views_is_idempotent_and_safe_under_concurrent_first_init.
    • Empty slots keep their own fixed TLAS descriptor index (MEM_HW_RT_TLAS + k, never 0) and (u32::MAX, u32::MAX) VA sentinels so any torn concurrent GPU read never matches a real console VA or reads descriptor 0 (_mm_sfence orders CPU write-combining stores; word 0 is written once as a diagnostic-only count since Shader::native_tlas scans all 8 slots directly).
    • If CreateCommittedResource or Map fails in init_views, writes a null raw-buffer SRV at MEM_HW_RT_TABLE and 8 null AS SRVs (tlas_view(0)) at MEM_HW_RT_TLAS + k so swapped shaders read zeros and fall back cleanly to the console BVH.
  • crates/xcl/src/hle/d3d12x/hw_rt.rs: add traverse_enabled() (caches only XCL_HW_RT_TRAVERSE env parsing and dynamically checks enabled() so XCL_RAYTRACING=0 is respected) and mutex+Drop-guarded with_traverse_for_tests, wire hw_rt_table::sync from build, rehydrate, copy, and periodic summary paths, and add direct-DXIL RayQuery copy-trace verification to warp_rehydrated_and_copied_blas_are_native.
  • crates/xcl/src/gpu/dxil/ray_query.rs: add Shader::native_tlas, TLAS_TABLE_* layout constants, and WARP swap_kernel lookup + trace cases covering instance masks and table misses.

Tested
Hardware: Windows 11 x64 (10.0.26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074 / 610.74, 15995 MiB VRAM, DXR Tier 1.1), AMD Ryzen 9 9950X, rustc 1.99.0, DXC 1.9.2609.5 (XCL_DXC_DIR).

  • cargo build --release -p xcl (commit 0e42eb3f876009db0576a68c69bd043d426e4c6a): succeeded, 39 warnings (0 new vs main).
  • Targeted unit & WARP DXR 1.1 tests on 0e42eb3f876009db0576a68c69bd043d426e4c6a (all ran, 0 skipped):
    • cargo test -p xcl --lib hw_rt_table::tests -- --nocapture: 3 passed, 0 failed, 0 skipped (including init_views_is_idempotent_and_safe_under_concurrent_first_init on WARP FL12_0).
    • cargo test -p xcl --lib hw_rt::tests -- --nocapture: 9 passed, 0 failed, 0 skipped — warp_rehydrated_and_copied_blas_are_native ran (not skipped): hw_rt: WARP rehydrated + copied bottom levels native, top level complete, RayQuery hits both copies.
    • cargo test -p xcl --lib ray_query:: -- --nocapture: 4 passed, 0 failed, 0 skipped — warp_ray_query_matches_console_bvh_walk ran (not skipped): ray_query: WARP traversal swap: table lookup and first-hit trace match the console BVH walk; [misses, hits] by case (mask 0x40, mask 0x80, moved + mask 0x80, VA not in the table): [[16, 48], [64, 0], [16, 48], [64, 0]].
  • Full .\scripts\test.ps1 at the top of this stack (1f287a928352ac71dcb238a3a5d3d4dd4741c3e0, containing 0e42eb3f8): 3006 passed, 0 failed, 52 ignored across 43 test suites; 24 GPU tests skipped on this adapter (22 no wave64, 2 no heap windows).

Regression run

Base (main):

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1658 (PresentX 1658)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16763 MB

PR (pr/hw-rt-table):

xcl-smoke v1
commit: 0e42eb3f876009db0576a68c69bd043d426e4c6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16276 MB

Not tested

  • Live XCL_HW_RT_TRAVERSE=1 shader execution on this PR alone (no shaders emit Shader::native_tlas until stacked PR #3705).
  • AMD/Intel GPUs and native wave64 GPU tests (22 skipped on RTX 5070 Ti).
  • Opt-in XCL_HEAP_WINDOWS=1 tests (2 skipped) and sample-gated tests (XCL_SAMPLE_* unset).

AI use

  • Claude Code (Claude Opus 5.5): architecture, write-combining / concurrent-reader race audit (B3), dynamic env-gating review (B4), and console_heap.rs / init_views failure-path review.
  • Antigravity (Gemini 4 Neon): implementation, rebase onto updated #3662/#3700, winning-heap init_views UAF fix and idempotent init_views_in + concurrent regression test, concurrency comment & w[0] cleanup, mutex+Drop with_traverse_for_tests, WARP DXR 1.1 tests, release build, full test suite, regression smoke, and PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5609859948 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:46:04Z. --- Add the GPU-visible native top-level acceleration-structure table (`hle::d3d12x::hw_rt_table`), `Shader::native_tlas` lookup helper, and `hw_rt::traverse_enabled()` gating for `XCL_HW_RT_TRAVERSE=1`. Off by default (no shaders read the table yet; Caller: #3705, direct-DXIL GPURT traversal loop swap). Part of #1751. Stacked on #3700 and #3659: its commit `70c8c51f3` is #3659's `5bfb22746`; only `0e42eb3f8` belongs here. Related: #2184, #2185, #2186, #2187, #2188, #2189. **Shared descriptor heap shift:** Reserves 9 fixed descriptors in the shared view heap (`MEM_HW_RT_TABLE = MEM_NULL_STORE + 1`, followed by 8 `MEM_HW_RT_TLAS` slots), shifting `MEM_FIXED_END` (the first dynamically allocated console descriptor heap slice) from `MEM_NULL_STORE + 1` to `MEM_NULL_STORE + 10` (+9 descriptors). When `XCL_HW_RT_TRAVERSE` is off, `init_views` returns early so no upload buffer is created and those 9 slots keep `fill_nulls`' Texture2D null views, which nothing reads because no shader is swapped. **What is in it** - `crates/xcl/src/gpu/recomp/mod.rs`: reserve `MEM_HW_RT_TABLE` and `MEM_HW_RT_SLOTS` (8) `MEM_HW_RT_TLAS` descriptors, advancing `MEM_FIXED_END`. - `crates/xcl/src/hle/d3d12x/console_heap.rs`: call `hw_rt_table::init_views` only for the heap that wins `GLOBAL` (after releasing `GLOBAL` so descriptor hooks cannot deadlock on it; `fill_nulls` already wrote valid null views into those slots before publication), and start dynamic slice allocation at `MEM_FIXED_END`. - `crates/xcl/src/hle/d3d12x/hw_rt_table.rs` & `mod.rs`: `Table` state machine + mapped upload buffer and descriptor writer. - Complete native TLASes are published only after `STABLE_FRAMES` (4) presents in the same native buffer, taken out immediately when relocated/invalidated/incomplete, and freed slots are quarantined for `STABLE_FRAMES` presents. - `init_views` / `init_views_in` is idempotent and checks/installs under `GPU` so concurrent first callers can never overwrite `Gpu.cpu` with a losing heap or drop a live upload buffer; covered by WARP FL12_0 regression test `init_views_is_idempotent_and_safe_under_concurrent_first_init`. - Empty slots keep their own fixed TLAS descriptor index (`MEM_HW_RT_TLAS + k`, never 0) and `(u32::MAX, u32::MAX)` VA sentinels so any torn concurrent GPU read never matches a real console VA or reads descriptor 0 (`_mm_sfence` orders CPU write-combining stores; word 0 is written once as a diagnostic-only count since `Shader::native_tlas` scans all 8 slots directly). - If `CreateCommittedResource` or `Map` fails in `init_views`, writes a null raw-buffer SRV at `MEM_HW_RT_TABLE` and 8 null AS SRVs (`tlas_view(0)`) at `MEM_HW_RT_TLAS + k` so swapped shaders read zeros and fall back cleanly to the console BVH. - `crates/xcl/src/hle/d3d12x/hw_rt.rs`: add `traverse_enabled()` (caches only `XCL_HW_RT_TRAVERSE` env parsing and dynamically checks `enabled()` so `XCL_RAYTRACING=0` is respected) and mutex+`Drop`-guarded `with_traverse_for_tests`, wire `hw_rt_table::sync` from build, rehydrate, copy, and periodic summary paths, and add direct-DXIL `RayQuery` copy-trace verification to `warp_rehydrated_and_copied_blas_are_native`. - `crates/xcl/src/gpu/dxil/ray_query.rs`: add `Shader::native_tlas`, `TLAS_TABLE_*` layout constants, and WARP `swap_kernel` lookup + trace cases covering instance masks and table misses. **Tested** Hardware: Windows 11 x64 (10.0.26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074 / 610.74, 15995 MiB VRAM, DXR Tier 1.1), AMD Ryzen 9 9950X, `rustc 1.99.0`, DXC `1.9.2609.5` (`XCL_DXC_DIR`). - `cargo build --release -p xcl` (commit `0e42eb3f876009db0576a68c69bd043d426e4c6a`): succeeded, 39 warnings (0 new vs `main`). - Targeted unit & WARP DXR 1.1 tests on `0e42eb3f876009db0576a68c69bd043d426e4c6a` (all ran, **0 skipped**): - `cargo test -p xcl --lib hw_rt_table::tests -- --nocapture`: **3 passed, 0 failed, 0 skipped** (including `init_views_is_idempotent_and_safe_under_concurrent_first_init` on WARP FL12_0). - `cargo test -p xcl --lib hw_rt::tests -- --nocapture`: **9 passed, 0 failed, 0 skipped** — `warp_rehydrated_and_copied_blas_are_native` ran (not skipped): `hw_rt: WARP rehydrated + copied bottom levels native, top level complete, RayQuery hits both copies`. - `cargo test -p xcl --lib ray_query:: -- --nocapture`: **4 passed, 0 failed, 0 skipped** — `warp_ray_query_matches_console_bvh_walk` ran (not skipped): `ray_query: WARP traversal swap: table lookup and first-hit trace match the console BVH walk; [misses, hits] by case (mask 0x40, mask 0x80, moved + mask 0x80, VA not in the table): [[16, 48], [64, 0], [16, 48], [64, 0]]`. - Full `.\scripts\test.ps1` at the top of this stack (`1f287a928352ac71dcb238a3a5d3d4dd4741c3e0`, containing `0e42eb3f8`): **3006 passed, 0 failed, 52 ignored** across 43 test suites; **24 GPU tests skipped** on this adapter (22 `no wave64`, 2 `no heap windows`). **Regression run** Base (`main`): ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1658 (PresentX 1658) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16763 MB ``` PR (`pr/hw-rt-table`): ``` xcl-smoke v1 commit: 0e42eb3f876009db0576a68c69bd043d426e4c6a gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16276 MB ``` **Not tested** - Live `XCL_HW_RT_TRAVERSE=1` shader execution on this PR alone (no shaders emit `Shader::native_tlas` until stacked PR #3705). - AMD/Intel GPUs and native wave64 GPU tests (22 skipped on RTX 5070 Ti). - Opt-in `XCL_HEAP_WINDOWS=1` tests (2 skipped) and sample-gated tests (`XCL_SAMPLE_*` unset). **AI use** - Claude Code (`Claude Opus 5.5`): architecture, write-combining / concurrent-reader race audit (B3), dynamic env-gating review (B4), and `console_heap.rs` / `init_views` failure-path review. - Antigravity (`Gemini 4 Neon`): implementation, rebase onto updated #3662/#3700, winning-heap `init_views` UAF fix and idempotent `init_views_in` + concurrent regression test, concurrency comment & `w[0]` cleanup, mutex+`Drop` `with_traverse_for_tests`, WARP DXR 1.1 tests, release build, full test suite, regression smoke, and PR description.
gut0to commented 2026-12-02 15:52:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T15:52:36Z.

Review: COMMENTED


AI-assisted review (model: GPT-6). I traced the two-caller shared-heap initialization path.

<!-- greyfinch-sync:ivall/xcl:review:6154303932 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#pullrequestreview-6154303932). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T15:52:36Z. **Review:** COMMENTED --- AI-assisted review (model: GPT-6). I traced the two-caller shared-heap initialization path.
gut0to commented 2026-12-02 15:52:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T15:52:36Z.

Code review location: crates/xcl/src/hle/d3d12x/hw_rt_table.rs; line 201

@@ -0,0 +1,315 @@
+//! The table of native top levels the traversal swap reads (`XCL_HW_RT_TRAVERSE=1`): a raw
+//! buffer SRV at `MEM_HW_RT_TABLE` of the shared heap, and the SRVs of the native top levels it
+//! names at `MEM_HW_RT_TLAS + k`. A translated shader finds its console top level's VA there;
+//! when it does not, it walks the console BVH as before.
+//!
+//! What the table names is decided when commands are recorded and read when they run, so an
+//! entry is made safe for both: a complete native top level (`NativeAsSnapshot::is_complete_tlas`)
+//! is published only once its buffer has been the same for `STABLE_FRAMES` presents (a dispatch
+//! that runs before its first build never finds it), and taken out as soon as it is rebuilt into
+//! another buffer, invalidated or incomplete (a dispatch then walks the console BVH). A freed
+//! slot is not given to another top level for `STABLE_FRAMES` presents: a dispatch that read the
+//! old entry still finds the old view there.
+
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::Mutex;
+
+use windows::Win32::Graphics::Direct3D12::*;
+use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_UNKNOWN};
+
+use crate::gpu::dxil::ray_query::{TLAS_TABLE_BYTES, TLAS_TABLE_ENTRIES, TLAS_TABLE_HEADER, TLAS_TABLE_STRIDE};
+use crate::gpu::recomp::{MEM_HW_RT_TABLE, MEM_HW_RT_TLAS};
+
+/// Presents an entry's native buffer must have been the same before it is published, and a
+/// freed slot stays unused (`hw_rt::RETIRE_FRAMES`: what in-flight work is given).
+pub const STABLE_FRAMES: u64 = super::hw_rt::RETIRE_FRAMES;
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum Slot {
+    /// Never used.
+    Never,
+    /// Free since that present.
+    Free(u64),
+    /// Console VA, native GPU VA.
+    Used(u64, u64),
+}
+
+/// The table's contents, without the GPU.
+#[derive(Debug)]
+pub struct Table {
+    slots: [Slot; TLAS_TABLE_ENTRIES as usize],
+    /// Each complete top level's (console VA, native GPU VA) and the present it was first seen.
+    seen: Vec<(u64, u64, u64)>,
+}
+
+impl Default for Table {
+    fn default() -> Self {
+        Table { slots: [Slot::Never; TLAS_TABLE_ENTRIES as usize], seen: Vec::new() }
+    }
+}
+
+/// A slot whose view changes: its native GPU VA (`None`: it is free now).
+pub type Change = (u32, Option<u64>);
+
+impl Table {
+    /// Brings the table in line with the complete native top levels `(console VA, native GPU
+    /// VA)` at present `frame`: the changed slots, whose views are written before the table's
+    /// words (`words`). A top level counts from the first present it is seen in its buffer.
+    pub fn sync(&mut self, tops: &[(u64, u64)], frame: u64) -> Vec<Change> {
+        self.seen.retain(|&(c, g, _)| tops.contains(&(c, g)));
+        for &(c, g) in tops {
+            if !self.seen.iter().any(|&(sc, sg, _)| (sc, sg) == (c, g)) {
+                self.seen.push((c, g, frame));
+            }
+        }
+        let tops = self.seen.clone();
+        let mut out = Vec::new();
+        for (k, s) in self.slots.iter_mut().enumerate() {
+            if let Slot::Used(console, gpu) = *s {
+                if !tops.iter().any(|&(c, g, _)| c == console && g == gpu) {
+                    *s = Slot::Free(frame);
+                    out.push((k as u32, None));
+                }
+            }
+        }
+        for (console, gpu, since) in tops {
+            if frame < since.saturating_add(STABLE_FRAMES) || self.slots.iter().any(|s| matches!(*s, Slot::Used(c, _) if c == console)) {
+                continue;
+            }
+            let free = self.slots.iter().position(|s| match *s {
+                Slot::Never => true,
+                Slot::Free(f) => frame >= f.saturating_add(STABLE_FRAMES),
+                Slot::Used(..) => false,
+            });
+            let Some(k) = free else { break };
+            self.slots[k] = Slot::Used(console, gpu);
+            out.push((k as u32, Some(gpu)));
+        }
+        out
+    }
+
+    /// The table as the shader reads it (`ray_query::Shader::native_tlas`). Every slot keeps its
+    /// own TLAS descriptor index (`MEM_HW_RT_TLAS + k`) even when empty, so a concurrent GPU
+    /// reader can never observe descriptor index 0.
+    pub fn words(&self) -> Vec<u32> {
+        let mut w = vec![0u32; (TLAS_TABLE_BYTES / 4) as usize];
+        let used = self.slots.iter().filter(|s| matches!(s, Slot::Used(..))).count();
+        w[0] = used as u32;
+        for (k, s) in self.slots.iter().enumerate() {
+            let at = ((TLAS_TABLE_HEADER + TLAS_TABLE_STRIDE * k as u32) / 4) as usize;
+            let idx = MEM_HW_RT_TLAS + k as u32;
+            w[at..at + 4].copy_from_slice(&match *s {
+                Slot::Used(console, _) => [console as u32, (console >> 32) as u32, idx, 0],
+                Slot::Never | Slot::Free(_) => [u32::MAX, u32::MAX, idx, 0],
+            });
+        }
+        w
+    }
+}
+
+/// The table on the GPU: its contents, the mapped upload buffer and where the views go.
+struct Gpu {
+    table: Table,
+    dev: ID3D12Device,
+    _buffer: ID3D12Resource,
+    mapped: *mut u32,
+    /// Shared heap's CPU start and increment.
+    cpu: u64,
+    inc: u32,
+    used: u32,
+}
+
+// The device and buffer are free-threaded; `mapped` is only written under `GPU`.
+unsafe impl Send for Gpu {}
+
+static ACTIVE: AtomicBool = AtomicBool::new(false);
+static GPU: Mutex<Option<Gpu>> = Mutex::new(None);
+
+#[inline]
+unsafe fn wc_sfence() {
+    #[cfg(target_arch = "x86_64")]
+    std::arch::x86_64::_mm_sfence();
+    #[cfg(not(target_arch = "x86_64"))]
+    std::sync::atomic::fence(Ordering::Release);
+}
+
+/// The view of a native top level at `gpu_va` (0: a null one, which no entry names).
+fn tlas_view(gpu_va: u64) -> D3D12_SHADER_RESOURCE_VIEW_DESC {
+    D3D12_SHADER_RESOURCE_VIEW_DESC {
+        Format: DXGI_FORMAT_UNKNOWN,
+        ViewDimension: D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE,
+        Shader4ComponentMapping: D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
+        Anonymous: D3D12_SHADER_RESOURCE_VIEW_DESC_0 { RaytracingAccelerationStructure: D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV { Location: gpu_va } },
+    }
+}
+
+fn at(cpu: u64, inc: u32, index: u32) -> D3D12_CPU_DESCRIPTOR_HANDLE {
+    D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + index as u64 * inc as u64) as usize }
+}
+
+/// With the shared heap made (`console_heap::shared_heap`, after its null views): the table (no
+/// entries) and null top-level views in their descriptors. Only with the swap on: no shader
+/// reads them otherwise. False: the table could not be made (the swap's shaders must not run).
+pub unsafe fn init_views(dev: &ID3D12Device, cpu: u64, inc: u32) -> bool {
+    if !super::hw_rt::traverse_enabled() {
+        return true;
+    }
+    let desc = D3D12_RESOURCE_DESC {
+        Dimension: D3D12_RESOURCE_DIMENSION_BUFFER,
+        Width: TLAS_TABLE_BYTES as u64,
+        Height: 1,
+        DepthOrArraySize: 1,
+        MipLevels: 1,
+        SampleDesc: windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
+        Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
+        ..Default::default()
+    };
+    let raw = D3D12_SHADER_RESOURCE_VIEW_DESC {
+        Format: DXGI_FORMAT_R32_TYPELESS,
+        ViewDimension: D3D12_SRV_DIMENSION_BUFFER,
+        Shader4ComponentMapping: D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
+        Anonymous: D3D12_SHADER_RESOURCE_VIEW_DESC_0 { Buffer: D3D12_BUFFER_SRV { FirstElement: 0, NumElements: TLAS_TABLE_BYTES / 4, StructureByteStride: 0, Flags: D3D12_BUFFER_SRV_FLAG_RAW } },
+    };
+    let write_null_views = || {
+        for k in 0..TLAS_TABLE_ENTRIES {
+            dev.CreateShaderResourceView(None, Some(&tlas_view(0)), at(cpu, inc, MEM_HW_RT_TLAS + k));
+        }
+        dev.CreateShaderResourceView(None, Some(&raw), at(cpu, inc, MEM_HW_RT_TABLE));
+    };
+    let mut buffer: Option<ID3D12Resource> = None;
+    let heap = D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_UPLOAD, ..Default::default() };
+    if dev.CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, None, &mut buffer).is_err() {
+        write_null_views();
+        crate::xlog_warn!("D3D12.X: XCL_HW_RT_TRAVERSE: the native top-level table could not be made");
+        return false;
+    }
+    let buffer = buffer.unwrap();
+    let mut mapped = std::ptr::null_mut();
+    if buffer.Map(0, None, Some(&mut mapped)).is_err() || mapped.is_null() {
+        write_null_views();
+        crate::xlog_warn!("D3D12.X: XCL_HW_RT_TRAVERSE: the native top-level table could not be mapped");
+        return false;
+    }
+    let table = Table::default();
+    let words = table.words();
+    std::ptr::copy_nonoverlapping(words.as_ptr(), mapped as *mut u32, words.len());
+    wc_sfence();
+    for k in 0..TLAS_TABLE_ENTRIES {
+        dev.CreateShaderResourceView(None, Some(&tlas_view(0)), at(cpu, inc, MEM_HW_RT_TLAS + k));
+    }
+    dev.CreateShaderResourceView(&buffer, Some(&raw), at(cpu, inc, MEM_HW_RT_TABLE));
+    *GPU.lock().unwrap() = Some(Gpu { table, dev: dev.clone(), _buffer: buffer, mapped: mapped as *mut u32, cpu, inc, used: 0 });

console_heap::shared_heap explicitly allows concurrent first callers to build outside GLOBAL, and it calls init_views before choosing which heap wins publication. This global assignment can therefore retain the losing caller's device, mapped table, and descriptor handles. If that caller loses GLOBAL, shaders bind the winning heap while sync updates the other heap; the bound heap's native-TLAS table stays empty and lookups fall back to the console BVH. Could the table state be tied to the heap that wins publication, with a concurrent-first-initialization regression test?

<!-- greyfinch-sync:ivall/xcl:review-comment:4772309405 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#discussion_r4772309405). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T15:52:36Z. **Code review location:** `crates/xcl/src/hle/d3d12x/hw_rt_table.rs`; line 201 ~~~~diff @@ -0,0 +1,315 @@ +//! The table of native top levels the traversal swap reads (`XCL_HW_RT_TRAVERSE=1`): a raw +//! buffer SRV at `MEM_HW_RT_TABLE` of the shared heap, and the SRVs of the native top levels it +//! names at `MEM_HW_RT_TLAS + k`. A translated shader finds its console top level's VA there; +//! when it does not, it walks the console BVH as before. +//! +//! What the table names is decided when commands are recorded and read when they run, so an +//! entry is made safe for both: a complete native top level (`NativeAsSnapshot::is_complete_tlas`) +//! is published only once its buffer has been the same for `STABLE_FRAMES` presents (a dispatch +//! that runs before its first build never finds it), and taken out as soon as it is rebuilt into +//! another buffer, invalidated or incomplete (a dispatch then walks the console BVH). A freed +//! slot is not given to another top level for `STABLE_FRAMES` presents: a dispatch that read the +//! old entry still finds the old view there. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Mutex; + +use windows::Win32::Graphics::Direct3D12::*; +use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_UNKNOWN}; + +use crate::gpu::dxil::ray_query::{TLAS_TABLE_BYTES, TLAS_TABLE_ENTRIES, TLAS_TABLE_HEADER, TLAS_TABLE_STRIDE}; +use crate::gpu::recomp::{MEM_HW_RT_TABLE, MEM_HW_RT_TLAS}; + +/// Presents an entry's native buffer must have been the same before it is published, and a +/// freed slot stays unused (`hw_rt::RETIRE_FRAMES`: what in-flight work is given). +pub const STABLE_FRAMES: u64 = super::hw_rt::RETIRE_FRAMES; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Slot { + /// Never used. + Never, + /// Free since that present. + Free(u64), + /// Console VA, native GPU VA. + Used(u64, u64), +} + +/// The table's contents, without the GPU. +#[derive(Debug)] +pub struct Table { + slots: [Slot; TLAS_TABLE_ENTRIES as usize], + /// Each complete top level's (console VA, native GPU VA) and the present it was first seen. + seen: Vec<(u64, u64, u64)>, +} + +impl Default for Table { + fn default() -> Self { + Table { slots: [Slot::Never; TLAS_TABLE_ENTRIES as usize], seen: Vec::new() } + } +} + +/// A slot whose view changes: its native GPU VA (`None`: it is free now). +pub type Change = (u32, Option<u64>); + +impl Table { + /// Brings the table in line with the complete native top levels `(console VA, native GPU + /// VA)` at present `frame`: the changed slots, whose views are written before the table's + /// words (`words`). A top level counts from the first present it is seen in its buffer. + pub fn sync(&mut self, tops: &[(u64, u64)], frame: u64) -> Vec<Change> { + self.seen.retain(|&(c, g, _)| tops.contains(&(c, g))); + for &(c, g) in tops { + if !self.seen.iter().any(|&(sc, sg, _)| (sc, sg) == (c, g)) { + self.seen.push((c, g, frame)); + } + } + let tops = self.seen.clone(); + let mut out = Vec::new(); + for (k, s) in self.slots.iter_mut().enumerate() { + if let Slot::Used(console, gpu) = *s { + if !tops.iter().any(|&(c, g, _)| c == console && g == gpu) { + *s = Slot::Free(frame); + out.push((k as u32, None)); + } + } + } + for (console, gpu, since) in tops { + if frame < since.saturating_add(STABLE_FRAMES) || self.slots.iter().any(|s| matches!(*s, Slot::Used(c, _) if c == console)) { + continue; + } + let free = self.slots.iter().position(|s| match *s { + Slot::Never => true, + Slot::Free(f) => frame >= f.saturating_add(STABLE_FRAMES), + Slot::Used(..) => false, + }); + let Some(k) = free else { break }; + self.slots[k] = Slot::Used(console, gpu); + out.push((k as u32, Some(gpu))); + } + out + } + + /// The table as the shader reads it (`ray_query::Shader::native_tlas`). Every slot keeps its + /// own TLAS descriptor index (`MEM_HW_RT_TLAS + k`) even when empty, so a concurrent GPU + /// reader can never observe descriptor index 0. + pub fn words(&self) -> Vec<u32> { + let mut w = vec![0u32; (TLAS_TABLE_BYTES / 4) as usize]; + let used = self.slots.iter().filter(|s| matches!(s, Slot::Used(..))).count(); + w[0] = used as u32; + for (k, s) in self.slots.iter().enumerate() { + let at = ((TLAS_TABLE_HEADER + TLAS_TABLE_STRIDE * k as u32) / 4) as usize; + let idx = MEM_HW_RT_TLAS + k as u32; + w[at..at + 4].copy_from_slice(&match *s { + Slot::Used(console, _) => [console as u32, (console >> 32) as u32, idx, 0], + Slot::Never | Slot::Free(_) => [u32::MAX, u32::MAX, idx, 0], + }); + } + w + } +} + +/// The table on the GPU: its contents, the mapped upload buffer and where the views go. +struct Gpu { + table: Table, + dev: ID3D12Device, + _buffer: ID3D12Resource, + mapped: *mut u32, + /// Shared heap's CPU start and increment. + cpu: u64, + inc: u32, + used: u32, +} + +// The device and buffer are free-threaded; `mapped` is only written under `GPU`. +unsafe impl Send for Gpu {} + +static ACTIVE: AtomicBool = AtomicBool::new(false); +static GPU: Mutex<Option<Gpu>> = Mutex::new(None); + +#[inline] +unsafe fn wc_sfence() { + #[cfg(target_arch = "x86_64")] + std::arch::x86_64::_mm_sfence(); + #[cfg(not(target_arch = "x86_64"))] + std::sync::atomic::fence(Ordering::Release); +} + +/// The view of a native top level at `gpu_va` (0: a null one, which no entry names). +fn tlas_view(gpu_va: u64) -> D3D12_SHADER_RESOURCE_VIEW_DESC { + D3D12_SHADER_RESOURCE_VIEW_DESC { + Format: DXGI_FORMAT_UNKNOWN, + ViewDimension: D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE, + Shader4ComponentMapping: D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, + Anonymous: D3D12_SHADER_RESOURCE_VIEW_DESC_0 { RaytracingAccelerationStructure: D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV { Location: gpu_va } }, + } +} + +fn at(cpu: u64, inc: u32, index: u32) -> D3D12_CPU_DESCRIPTOR_HANDLE { + D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + index as u64 * inc as u64) as usize } +} + +/// With the shared heap made (`console_heap::shared_heap`, after its null views): the table (no +/// entries) and null top-level views in their descriptors. Only with the swap on: no shader +/// reads them otherwise. False: the table could not be made (the swap's shaders must not run). +pub unsafe fn init_views(dev: &ID3D12Device, cpu: u64, inc: u32) -> bool { + if !super::hw_rt::traverse_enabled() { + return true; + } + let desc = D3D12_RESOURCE_DESC { + Dimension: D3D12_RESOURCE_DIMENSION_BUFFER, + Width: TLAS_TABLE_BYTES as u64, + Height: 1, + DepthOrArraySize: 1, + MipLevels: 1, + SampleDesc: windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, + Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + ..Default::default() + }; + let raw = D3D12_SHADER_RESOURCE_VIEW_DESC { + Format: DXGI_FORMAT_R32_TYPELESS, + ViewDimension: D3D12_SRV_DIMENSION_BUFFER, + Shader4ComponentMapping: D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, + Anonymous: D3D12_SHADER_RESOURCE_VIEW_DESC_0 { Buffer: D3D12_BUFFER_SRV { FirstElement: 0, NumElements: TLAS_TABLE_BYTES / 4, StructureByteStride: 0, Flags: D3D12_BUFFER_SRV_FLAG_RAW } }, + }; + let write_null_views = || { + for k in 0..TLAS_TABLE_ENTRIES { + dev.CreateShaderResourceView(None, Some(&tlas_view(0)), at(cpu, inc, MEM_HW_RT_TLAS + k)); + } + dev.CreateShaderResourceView(None, Some(&raw), at(cpu, inc, MEM_HW_RT_TABLE)); + }; + let mut buffer: Option<ID3D12Resource> = None; + let heap = D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_UPLOAD, ..Default::default() }; + if dev.CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, None, &mut buffer).is_err() { + write_null_views(); + crate::xlog_warn!("D3D12.X: XCL_HW_RT_TRAVERSE: the native top-level table could not be made"); + return false; + } + let buffer = buffer.unwrap(); + let mut mapped = std::ptr::null_mut(); + if buffer.Map(0, None, Some(&mut mapped)).is_err() || mapped.is_null() { + write_null_views(); + crate::xlog_warn!("D3D12.X: XCL_HW_RT_TRAVERSE: the native top-level table could not be mapped"); + return false; + } + let table = Table::default(); + let words = table.words(); + std::ptr::copy_nonoverlapping(words.as_ptr(), mapped as *mut u32, words.len()); + wc_sfence(); + for k in 0..TLAS_TABLE_ENTRIES { + dev.CreateShaderResourceView(None, Some(&tlas_view(0)), at(cpu, inc, MEM_HW_RT_TLAS + k)); + } + dev.CreateShaderResourceView(&buffer, Some(&raw), at(cpu, inc, MEM_HW_RT_TABLE)); + *GPU.lock().unwrap() = Some(Gpu { table, dev: dev.clone(), _buffer: buffer, mapped: mapped as *mut u32, cpu, inc, used: 0 }); ~~~~ --- `console_heap::shared_heap` explicitly allows concurrent first callers to build outside `GLOBAL`, and it calls `init_views` before choosing which heap wins publication. This global assignment can therefore retain the losing caller's device, mapped table, and descriptor handles. If that caller loses `GLOBAL`, shaders bind the winning heap while `sync` updates the other heap; the bound heap's native-TLAS table stays empty and lookups fall back to the console BVH. Could the table state be tied to the heap that wins publication, with a concurrent-first-initialization regression test?
capy-ai[bot] commented 2026-12-02 20:00:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-02T20:00:03Z.


Code review (head 69ac2d73b2, diff read only — not built or tested on Windows/GPU, not a merge-check)

Scope: only 69ac2d73b (the rest of the head is #3700 at 3620d7652 plus #3659's 89bfa9a23, not re-reviewed here). The Table state machine, Shader::native_tlas and the default-off gating look right. I found one real bug in how the table gets set up, plus a few smaller points.

1. init_views runs for every racing shared_heap caller, not just the one that wins GLOBAL (console_heap.rs ~514). shared_heap deliberately lets two threads each build a heap and keeps whichever stores to GLOBAL first. The loser's heap is dropped when the function returns. hw_rt_table::init_views is called before that decision, and every call overwrites the GPU static. So with XCL_HW_RT_TRAVERSE=1 and a race on first use, two things can go wrong:

  • If the loser calls init_views last, Gpu.cpu points into the dropped heap. Every later sync then calls CreateShaderResourceView on freed descriptor memory, which is a use-after-free.
  • Whichever caller is overwritten loses its upload buffer (the old Gpu is dropped along with _buffer). If that was the winner, the winning heap's MEM_HW_RT_TABLE SRV still points at the released buffer.

This only happens with the flag on and only under a race, but it's memory-unsafe. Fix: initialise only for the heap that actually wins. One way is to call init_views after storing to GLOBAL, and only on the g.is_none() path. Release the lock first, since the comment says descriptor hooks look up GLOBAL. No shader reads these slots until #3705, so writing them after publication is fine. The alternative is to make init_views refuse to replace an existing GPU, but then the loser's views would still be orphaned.

2. The concurrency comments promise more than the code delivers, though the code is safe. sync's doc says the _mm_sfence ordering means GPU readers "never observe torn … entries". sfence only orders the CPU's stores. D3D12 gives no ordering guarantee for host writes to an upload heap that a dispatch is reading at the same time. What actually makes torn reads harmless is the layout: the descriptor index is fixed per slot (MEM_HW_RT_TLAS + k), and an empty entry is (MAX, MAX). Any mix of old and new halves therefore never matches a real VA. It's worth saying that in the comment, so nobody later "simplifies" the layout and breaks it on the strength of the fences.

3. The header word is never read. native_tlas compares all 8 entries and never reads w[0] (the used count). The ordering logic for raising and lowering used in sync is therefore dead weight. Either drop it or note that it is debug-only.

4. Unconditional heap cost. Moving MEM_FIXED_END up by 9 takes 9 descriptors from dynamic allocation even with the flag off. That's fine, and the smoke run shows no change. The runner.rs test heaps are still sized max(MEM_NULL_STORE + 1). That is fine for now, but it will need MEM_FIXED_END once #3705's swap shaders run in recomp tests.

5. Test-global override (nit). set_traverse_for_tests(Some(true)) in hw_rt's align_up test flips a process-wide flag while other tests run in parallel. If a console_heap test happens to build the shared heap inside that window, the table goes ACTIVE for the rest of the binary. Either keep the override around a pure check, or scope it with a guard and a lock.

6. Test evidence. hw_rt_table's two tests are pure CPU and have no skip path, so the description's "24 GPU tests skipped … including all 9 hw_rt, 2 hw_rt_table, 4 ray_query" can't be literally right. Please say whether the WARP ray_query swap/trace case and the new warp_rehydrated_and_copied_blas_are_native RayQuery block actually ran or printed SKIPPED. They are the only execution evidence for native_tlas. The swap test itself is well built: there are four cases (mask 0x40, mask 0x80 at the origin, mask 0x80 shifted by FAR, and a VA that isn't in the table), and it is checked against the console walk.

Still needed on Windows/GPU: a fix for (1); a real-adapter run with XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1 (with #3705 for an actual reader) showing the "native top-level table" init/publish logs and no device removal; and the regular suite with the skip counts reported.

AI use: Capy, Claude Opus 5.5 (static code review only; not built or tested on Windows/GPU).

<!-- greyfinch-sync:ivall/xcl:comment:7357058999 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#issuecomment-7357058999). Originally posted by [capy-ai[bot]](https://github.com/apps/capy-ai) on 2026-12-02T20:00:03Z. --- Code review (head 69ac2d73b2, diff read only — not built or tested on Windows/GPU, not a merge-check) Scope: only `69ac2d73b` (the rest of the head is #3700 at `3620d7652` plus #3659's `89bfa9a23`, not re-reviewed here). The `Table` state machine, `Shader::native_tlas` and the default-off gating look right. I found one real bug in how the table gets set up, plus a few smaller points. **1. `init_views` runs for every racing `shared_heap` caller, not just the one that wins `GLOBAL` (`console_heap.rs` ~514).** `shared_heap` deliberately lets two threads each build a heap and keeps whichever stores to `GLOBAL` first. The loser's `heap` is dropped when the function returns. `hw_rt_table::init_views` is called before that decision, and every call overwrites the `GPU` static. So with `XCL_HW_RT_TRAVERSE=1` and a race on first use, two things can go wrong: - If the loser calls `init_views` last, `Gpu.cpu` points into the dropped heap. Every later `sync` then calls `CreateShaderResourceView` on freed descriptor memory, which is a use-after-free. - Whichever caller is overwritten loses its upload buffer (the old `Gpu` is dropped along with `_buffer`). If that was the winner, the winning heap's `MEM_HW_RT_TABLE` SRV still points at the released buffer. This only happens with the flag on and only under a race, but it's memory-unsafe. Fix: initialise only for the heap that actually wins. One way is to call `init_views` after storing to `GLOBAL`, and only on the `g.is_none()` path. Release the lock first, since the comment says descriptor hooks look up `GLOBAL`. No shader reads these slots until #3705, so writing them after publication is fine. The alternative is to make `init_views` refuse to replace an existing `GPU`, but then the loser's views would still be orphaned. **2. The concurrency comments promise more than the code delivers, though the code is safe.** `sync`'s doc says the `_mm_sfence` ordering means GPU readers "never observe torn … entries". `sfence` only orders the CPU's stores. D3D12 gives no ordering guarantee for host writes to an upload heap that a dispatch is reading at the same time. What actually makes torn reads harmless is the layout: the descriptor index is fixed per slot (`MEM_HW_RT_TLAS + k`), and an empty entry is `(MAX, MAX)`. Any mix of old and new halves therefore never matches a real VA. It's worth saying that in the comment, so nobody later "simplifies" the layout and breaks it on the strength of the fences. **3. The header word is never read.** `native_tlas` compares all 8 entries and never reads `w[0]` (the used count). The ordering logic for raising and lowering `used` in `sync` is therefore dead weight. Either drop it or note that it is debug-only. **4. Unconditional heap cost.** Moving `MEM_FIXED_END` up by 9 takes 9 descriptors from dynamic allocation even with the flag off. That's fine, and the smoke run shows no change. The `runner.rs` test heaps are still sized `max(MEM_NULL_STORE + 1)`. That is fine for now, but it will need `MEM_FIXED_END` once #3705's swap shaders run in recomp tests. **5. Test-global override (nit).** `set_traverse_for_tests(Some(true))` in `hw_rt`'s `align_up` test flips a process-wide flag while other tests run in parallel. If a `console_heap` test happens to build the shared heap inside that window, the table goes `ACTIVE` for the rest of the binary. Either keep the override around a pure check, or scope it with a guard and a lock. **6. Test evidence.** `hw_rt_table`'s two tests are pure CPU and have no skip path, so the description's "24 GPU tests skipped … including all 9 hw_rt, 2 hw_rt_table, 4 ray_query" can't be literally right. Please say whether the WARP `ray_query` swap/trace case and the new `warp_rehydrated_and_copied_blas_are_native` RayQuery block actually ran or printed `SKIPPED`. They are the only execution evidence for `native_tlas`. The swap test itself is well built: there are four cases (mask 0x40, mask 0x80 at the origin, mask 0x80 shifted by `FAR`, and a VA that isn't in the table), and it is checked against the console walk. Still needed on Windows/GPU: a fix for (1); a real-adapter run with `XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1` (with #3705 for an actual reader) showing the "native top-level table" init/publish logs and no device removal; and the regular suite with the skip counts reported. AI use: Capy, Claude Opus 5.5 (static code review only; not built or tested on Windows/GPU).
Kalmarv commented 2026-12-02 23:24:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:24:48Z.


Thanks @gut0to and @capy-ai — fixed the init_views race/UAF and folded in the minor items in 0e42eb3f8:

  1. shared_heap / init_views race & UAF (console_heap.rs, hw_rt_table.rs): Moved hw_rt_table::init_views to run only on the heap that wins GLOBAL (after releasing GLOBAL, with fill_nulls already having populated valid null views in those slots before publication). Also made init_views / init_views_in idempotent under GPU so concurrent first callers can never overwrite Gpu.cpu with a losing heap or drop a live upload buffer. Added WARP FL12_0 two-thread barrier regression test init_views_is_idempotent_and_safe_under_concurrent_first_init (dropping the losing heap and verifying idempotency).
  2. Concurrency comment accuracy (hw_rt_table.rs): Updated sync's comments to state that _mm_sfence only orders CPU write-combining stores and that torn GPU reads are harmless because each slot keeps a fixed descriptor index (MEM_HW_RT_TLAS + k, never 0), empty slots hold (u32::MAX, u32::MAX), and freed slots are quarantined for STABLE_FRAMES presents.
  3. w[0] header cleanup (hw_rt_table.rs): Removed the dead gpu.used raising/lowering ordering dance in sync; w[0] is now written once as a diagnostic-only count (Shader::native_tlas scans all 8 slots directly).
  4. Test-global traverse override (hw_rt.rs): Replaced raw set_traverse_for_tests with mutex+Drop-guarded with_traverse_for_tests so parallel --test-threads=4 runs cannot race.
  5. Test evidence clarity: Updated Tested to report exact non-skipped results on 0e42eb3f8 (hw_rt_table::tests 3/3, hw_rt::tests 9/9 with warp_rehydrated_and_copied_blas_are_native running on WARP, ray_query::tests 4/4 with warp_ray_query_matches_console_bvh_walk traversal swap running on WARP — 0 skipped on all three; full stack scripts/test.ps1 at 1f287a928: 3006 passed, 0 failed, 52 ignored, 24 SKIPPED; 60 s smoke on 0e42eb3f8: 1628 frames, 0 removals, 0 crashes).

(Fixed and replied via Antigravity (Gemini 4 Neon).)

<!-- greyfinch-sync:ivall/xcl:comment:7361962566 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#issuecomment-7361962566). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T23:24:48Z. --- Thanks @gut0to and @capy-ai — fixed the `init_views` race/UAF and folded in the minor items in `0e42eb3f8`: 1. **`shared_heap` / `init_views` race & UAF (`console_heap.rs`, `hw_rt_table.rs`):** Moved `hw_rt_table::init_views` to run only on the heap that wins `GLOBAL` (after releasing `GLOBAL`, with `fill_nulls` already having populated valid null views in those slots before publication). Also made `init_views` / `init_views_in` idempotent under `GPU` so concurrent first callers can never overwrite `Gpu.cpu` with a losing heap or drop a live upload buffer. Added WARP FL12_0 two-thread barrier regression test `init_views_is_idempotent_and_safe_under_concurrent_first_init` (dropping the losing heap and verifying idempotency). 2. **Concurrency comment accuracy (`hw_rt_table.rs`):** Updated `sync`'s comments to state that `_mm_sfence` only orders CPU write-combining stores and that torn GPU reads are harmless because each slot keeps a fixed descriptor index (`MEM_HW_RT_TLAS + k`, never 0), empty slots hold `(u32::MAX, u32::MAX)`, and freed slots are quarantined for `STABLE_FRAMES` presents. 3. **`w[0]` header cleanup (`hw_rt_table.rs`):** Removed the dead `gpu.used` raising/lowering ordering dance in `sync`; `w[0]` is now written once as a diagnostic-only count (`Shader::native_tlas` scans all 8 slots directly). 4. **Test-global traverse override (`hw_rt.rs`):** Replaced raw `set_traverse_for_tests` with mutex+`Drop`-guarded `with_traverse_for_tests` so parallel `--test-threads=4` runs cannot race. 5. **Test evidence clarity:** Updated **Tested** to report exact non-skipped results on `0e42eb3f8` (`hw_rt_table::tests` 3/3, `hw_rt::tests` 9/9 with `warp_rehydrated_and_copied_blas_are_native` running on WARP, `ray_query::tests` 4/4 with `warp_ray_query_matches_console_bvh_walk` traversal swap running on WARP — 0 skipped on all three; full stack `scripts/test.ps1` at `1f287a928`: 3006 passed, 0 failed, 52 ignored, 24 SKIPPED; 60 s smoke on `0e42eb3f8`: 1628 frames, 0 removals, 0 crashes). *(Fixed and replied via Antigravity (Gemini 4 Neon).)*
Foniass commented 2026-12-03 01:47:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T01:47:11Z.


merge-check
base: 078358a058
head: 0e42eb3f87
merge: clean
build: ok
tests: 3035 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 2 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16768 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 222 s there, 0 device removals, 0 crashes, 3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Adds the GPU-visible native top-level table (hw_rt_table), Shader::native_tlas and the XCL_HW_RT_TRAVERSE gate, off by default. The only default-path changes are 9 reserved descriptors at the start of the shared heap and moving init_views after GLOBAL is published. The table's publish/quarantine logic and the init race fix read correctly. Nothing in its own commit blocks it. The stack under it carries a rebased copy of #3659 and #3700's opt-in code with a check-then-read of title memory.

Medium

  1. Carries a rebased copy of #3659. Commit 70c8c51f3 has the same patch as #3659's head 5bfb22746 but is a different commit. With merge commits, merging #3659 and then this stack lands the change twice, and #3659 still has Foniass's "not yet". Either close #3659 in favour of the stack, or stack on #3659's own commit.
  2. Stack carries #3700's check-then-read of title memory. 150a15841 bvh_builder.rs ~639 read_archive_prims translates a GPU VA with cpu_at, checks readable() and then does a raw read_unaligned. That is the pattern bmjask flagged as critical in #3662 (fixed there with read_gpu_bytes / read_own). Opt-in only (XCL_HW_RT=1) and #3700's code, but it lands with this PR; it should use read_gpu_bytes.

Nit

  1. Own commit over 400 lines with no reason. 0e42eb3f8 is +720/-31 (751 lines), under 800 so no reason is required, but the description gives none.
Checked and fine
  • The init_views race raised by capy-ai and gut0to is fixed: shared_heap calls init_views only when it won GLOBAL, after releasing the lock; init_views_in rechecks GPU under its lock before installing, so a losing heap or a second buffer can't replace the live one; a WARP concurrency test covers it
  • Default path: MEM_FIXED_END moves the first dynamic slot up by 9 (cost 9 descriptors); with the flag off init_views returns at once and those slots keep fill_nulls' null views; hw_rt_table::sync returns early unless ACTIVE, and every caller is behind hw_rt::enabled()
  • Table logic: an entry is published after STABLE_FRAMES presents in the same buffer, taken out as soon as it changes, and freed slots are quarantined; empty slots hold a (MAX, MAX) VA and a fixed descriptor index, and the high word is written last, so a torn read never matches a real VA; the build hooks and summary_line use the same present clock
  • init_views failure path writes a null raw-buffer SRV and null AS SRVs, so swapped shaders find no entry and fall back
  • native_tlas compares all 8 entries without a loop and selects the fixed descriptor index; the WARP swap_kernel test covers mask, moved-VA and table-miss cases against the console walk
  • with_traverse_for_tests is now guard-scoped and, in this PR, wraps only pure asserts
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7364732760 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#issuecomment-7364732760). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T01:47:11Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 0e42eb3f876009db0576a68c69bd043d426e4c6a merge: clean build: ok tests: 3035 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 2 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16768 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 222 s there, 0 device removals, 0 crashes, 3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Adds the GPU-visible native top-level table (hw_rt_table), Shader::native_tlas and the XCL_HW_RT_TRAVERSE gate, off by default. The only default-path changes are 9 reserved descriptors at the start of the shared heap and moving init_views after GLOBAL is published. The table's publish/quarantine logic and the init race fix read correctly. Nothing in its own commit blocks it. The stack under it carries a rebased copy of #3659 and #3700's opt-in code with a check-then-read of title memory. #### Medium 1. **Carries a rebased copy of #3659.** Commit 70c8c51f3 has the same patch as #3659's head 5bfb22746 but is a different commit. With merge commits, merging #3659 and then this stack lands the change twice, and #3659 still has Foniass's "not yet". Either close #3659 in favour of the stack, or stack on #3659's own commit. 2. **Stack carries #3700's check-then-read of title memory.** 150a15841 bvh_builder.rs ~639 read_archive_prims translates a GPU VA with cpu_at, checks readable() and then does a raw read_unaligned. That is the pattern bmjask flagged as critical in #3662 (fixed there with read_gpu_bytes / read_own). Opt-in only (XCL_HW_RT=1) and #3700's code, but it lands with this PR; it should use read_gpu_bytes. #### Nit 3. **Own commit over 400 lines with no reason.** 0e42eb3f8 is +720/-31 (751 lines), under 800 so no reason is required, but the description gives none. <details><summary>Checked and fine</summary> - The init_views race raised by capy-ai and gut0to is fixed: shared_heap calls init_views only when it won GLOBAL, after releasing the lock; init_views_in rechecks GPU under its lock before installing, so a losing heap or a second buffer can't replace the live one; a WARP concurrency test covers it - Default path: MEM_FIXED_END moves the first dynamic slot up by 9 (cost 9 descriptors); with the flag off init_views returns at once and those slots keep fill_nulls' null views; hw_rt_table::sync returns early unless ACTIVE, and every caller is behind hw_rt::enabled() - Table logic: an entry is published after STABLE_FRAMES presents in the same buffer, taken out as soon as it changes, and freed slots are quarantined; empty slots hold a (MAX, MAX) VA and a fixed descriptor index, and the high word is written last, so a torn read never matches a real VA; the build hooks and summary_line use the same present clock - init_views failure path writes a null raw-buffer SRV and null AS SRVs, so swapped shaders find no entry and fall back - native_tlas compares all 8 entries without a loop and selects the fixed descriptor index; the WARP swap_kernel test covers mask, moved-VA and table-miss cases against the console walk - with_traverse_for_tests is now guard-scoped and, in this PR, wraps only pure asserts </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Kalmarv commented 2026-12-03 01:55:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T01:55:11Z.


Thanks for the merge-check, smoke run, and title run @Foniass!

On `PR description` is red: every pull_request_target workflow on xcl-dev/xcl (PR checks, Auto triage, Testing feed, Discord mirror) has been returning startup_failure repo-wide since ~22:47 UTC on 2026-12-02, so the PR description job never started on 0e42eb3f8 (run 46994373685). Running main's scripts/pr_check.py --local against PR #3704's current description and file list for 0e42eb3f8 passes (description ok), and Build and test (Windows, no GPU) is green (run 46994378951). Once pull_request_target recovers, I'll retrigger PR checks via a no-op description edit without changing 0e42eb3f8.

On the review points:

  • #1 (rebased copy of #3659): 70c8c51f3 is an identical cherry-pick of #3659's 5bfb22746 (git range-diff matches =). #3704 depends on two independent PRs (#3659 on main and #3700 on #3662 → #3697) and stays linear per CONTRIBUTING.md. Note that #3659's current head 5bfb22746 actually has your follow-up safe to merge verdict (the earlier not yet was on 9c33b8cc), so I'm keeping #3659 open; once #3659 and #3700 land on main, I'll rebase #3704 onto main so 70c8c51f3 (and #3662/#3697/#3700) drop cleanly rather than landing twice.
  • #2 (#3700's read_archive_prims check-then-read): Good catch on 150a15841 (bvh_builder.rs:639). Because hdr_addr can be either a CPU address (src_cpu_addrs[i]) or a GPU VA (d.source), replacing readable() + raw read_unaligned with read_gpu_bytes (for d.source) and dstorage::read_own (for src_cpu_addrs[i]) removes that TOCTOU window cleanly. I'll fix it in #3700 and pick it up when #3704 rebases onto #3700 (or sooner if you'd like it before merge).
  • #3 (own commit size, +720/-31): 0e42eb3f8 groups hw_rt_table.rs (422 lines incl. unit + WARP concurrency tests), Shader::native_tlas + WARP traversal-swap tests in ray_query.rs (+161 lines), and the console_heap.rs / hw_rt.rs / recomp/mod.rs wiring so the table binary layout, writer, reader, and WARP tests stay validated together.

Leaving 0e42eb3f8 untouched for now so this merge-check, title run, and green CI aren't churned during the pull_request_target outage.

Drafted with Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ivall/xcl:comment:7364881487 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#issuecomment-7364881487). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T01:55:11Z. --- Thanks for the merge-check, smoke run, and title run @Foniass! On `` `PR description` is red ``: every `pull_request_target` workflow on `xcl-dev/xcl` (`PR checks`, `Auto triage`, `Testing feed`, `Discord mirror`) has been returning `startup_failure` repo-wide since ~22:47 UTC on 2026-12-02, so the `PR description` job never started on `0e42eb3f8` (run `46994373685`). Running `main`'s `scripts/pr_check.py --local` against PR #3704's current description and file list for `0e42eb3f8` passes (`description ok`), and `Build and test (Windows, no GPU)` is green (run `46994378951`). Once `pull_request_target` recovers, I'll retrigger `PR checks` via a no-op description edit without changing `0e42eb3f8`. On the review points: - **#1 (rebased copy of `#3659`):** `70c8c51f3` is an identical cherry-pick of `#3659`'s `5bfb22746` (`git range-diff` matches `=`). `#3704` depends on two independent PRs (`#3659` on `main` and `#3700` on `#3662` → `#3697`) and stays linear per `CONTRIBUTING.md`. Note that `#3659`'s current head `5bfb22746` actually has your follow-up `safe to merge` verdict (the earlier `not yet` was on `9c33b8cc`), so I'm keeping `#3659` open; once `#3659` and `#3700` land on `main`, I'll rebase `#3704` onto `main` so `70c8c51f3` (and `#3662`/`#3697`/`#3700`) drop cleanly rather than landing twice. - **#2 (`#3700`'s `read_archive_prims` check-then-read):** Good catch on `150a15841` (`bvh_builder.rs:639`). Because `hdr_addr` can be either a CPU address (`src_cpu_addrs[i]`) or a GPU VA (`d.source`), replacing `readable()` + raw `read_unaligned` with `read_gpu_bytes` (for `d.source`) and `dstorage::read_own` (for `src_cpu_addrs[i]`) removes that TOCTOU window cleanly. I'll fix it in `#3700` and pick it up when `#3704` rebases onto `#3700` (or sooner if you'd like it before merge). - **#3 (own commit size, `+720/-31`):** `0e42eb3f8` groups `hw_rt_table.rs` (422 lines incl. unit + WARP concurrency tests), `Shader::native_tlas` + WARP traversal-swap tests in `ray_query.rs` (+161 lines), and the `console_heap.rs` / `hw_rt.rs` / `recomp/mod.rs` wiring so the table binary layout, writer, reader, and WARP tests stay validated together. Leaving `0e42eb3f8` untouched for now so this merge-check, title run, and green CI aren't churned during the `pull_request_target` outage. <sub>Drafted with Antigravity (Gemini 4 Neon).</sub>
Foniass commented 2026-12-03 15:32:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:32:31Z.


merge-check
base: 078358a058
head: 0e42eb3f87
merge: clean
build: ok
tests: 3035 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 2 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16768 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 222 s there, 0 device removals, 0 crashes, 3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Adds the GPU-visible native top-level table (hw_rt_table), Shader::native_tlas and the XCL_HW_RT_TRAVERSE gate, off by default. The only default-path changes are 9 reserved descriptors at the start of the shared heap and moving init_views after GLOBAL is published. The table's publish/quarantine logic and the init race fix read correctly. Nothing in its own commit blocks it. The stack under it carries a rebased copy of #3659 and #3700's opt-in code with a check-then-read of title memory.

Medium

  1. Carries a rebased copy of #3659. Commit 70c8c51f3 has the same patch as #3659's head 5bfb22746 but is a different commit. With merge commits, merging #3659 and then this stack lands the change twice, and #3659 still has Foniass's "not yet". Either close #3659 in favour of the stack, or stack on #3659's own commit.
  2. Stack carries #3700's check-then-read of title memory. 150a15841 bvh_builder.rs ~639 read_archive_prims translates a GPU VA with cpu_at, checks readable() and then does a raw read_unaligned. That is the pattern bmjask flagged as critical in #3662 (fixed there with read_gpu_bytes / read_own). Opt-in only (XCL_HW_RT=1) and #3700's code, but it lands with this PR; it should use read_gpu_bytes.

Nit

  1. Own commit over 400 lines with no reason. 0e42eb3f8 is +720/-31 (751 lines), under 800 so no reason is required, but the description gives none.
Checked and fine
  • The init_views race raised by capy-ai and gut0to is fixed: shared_heap calls init_views only when it won GLOBAL, after releasing the lock; init_views_in rechecks GPU under its lock before installing, so a losing heap or a second buffer can't replace the live one; a WARP concurrency test covers it
  • Default path: MEM_FIXED_END moves the first dynamic slot up by 9 (cost 9 descriptors); with the flag off init_views returns at once and those slots keep fill_nulls' null views; hw_rt_table::sync returns early unless ACTIVE, and every caller is behind hw_rt::enabled()
  • Table logic: an entry is published after STABLE_FRAMES presents in the same buffer, taken out as soon as it changes, and freed slots are quarantined; empty slots hold a (MAX, MAX) VA and a fixed descriptor index, and the high word is written last, so a torn read never matches a real VA; the build hooks and summary_line use the same present clock
  • init_views failure path writes a null raw-buffer SRV and null AS SRVs, so swapped shaders find no entry and fall back
  • native_tlas compares all 8 entries without a loop and selects the fixed descriptor index; the WARP swap_kernel test covers mask, moved-VA and table-miss cases against the console walk
  • with_traverse_for_tests is now guard-scoped and, in this PR, wraps only pure asserts
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7383319204 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3704#issuecomment-7383319204). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:32:31Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 0e42eb3f876009db0576a68c69bd043d426e4c6a merge: clean build: ok tests: 3035 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 2 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16768 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 222 s there, 0 device removals, 0 crashes, 3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Adds the GPU-visible native top-level table (hw_rt_table), Shader::native_tlas and the XCL_HW_RT_TRAVERSE gate, off by default. The only default-path changes are 9 reserved descriptors at the start of the shared heap and moving init_views after GLOBAL is published. The table's publish/quarantine logic and the init race fix read correctly. Nothing in its own commit blocks it. The stack under it carries a rebased copy of #3659 and #3700's opt-in code with a check-then-read of title memory. #### Medium 1. **Carries a rebased copy of #3659.** Commit 70c8c51f3 has the same patch as #3659's head 5bfb22746 but is a different commit. With merge commits, merging #3659 and then this stack lands the change twice, and #3659 still has Foniass's "not yet". Either close #3659 in favour of the stack, or stack on #3659's own commit. 2. **Stack carries #3700's check-then-read of title memory.** 150a15841 bvh_builder.rs ~639 read_archive_prims translates a GPU VA with cpu_at, checks readable() and then does a raw read_unaligned. That is the pattern bmjask flagged as critical in #3662 (fixed there with read_gpu_bytes / read_own). Opt-in only (XCL_HW_RT=1) and #3700's code, but it lands with this PR; it should use read_gpu_bytes. #### Nit 3. **Own commit over 400 lines with no reason.** 0e42eb3f8 is +720/-31 (751 lines), under 800 so no reason is required, but the description gives none. <details><summary>Checked and fine</summary> - The init_views race raised by capy-ai and gut0to is fixed: shared_heap calls init_views only when it won GLOBAL, after releasing the lock; init_views_in rechecks GPU under its lock before installing, so a losing heap or a second buffer can't replace the live one; a WARP concurrency test covers it - Default path: MEM_FIXED_END moves the first dynamic slot up by 9 (cost 9 descriptors); with the flag off init_views returns at once and those slots keep fill_nulls' null views; hw_rt_table::sync returns early unless ACTIVE, and every caller is behind hw_rt::enabled() - Table logic: an entry is published after STABLE_FRAMES presents in the same buffer, taken out as soon as it changes, and freed slots are quarantined; empty slots hold a (MAX, MAX) VA and a fixed descriptor index, and the high word is written last, so a torn read never matches a real VA; the build hooks and summary_line use the same present clock - init_views failure path writes a null raw-buffer SRV and null AS SRVs, so swapped shaders find no entry and fall back - native_tlas compares all 8 entries without a loop and selects the fixed descriptor index; the WARP swap_kernel test covers mask, moved-VA and table-miss cases against the console walk - with_traverse_for_tests is now guard-scoped and, in this PR, wraps only pure asserts </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3704:upstream-pr/3704'
git switch 'upstream-pr/3704'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3704'
git switch 'upstream-pr/3704'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3704'
git switch 'upstream-pr/3704'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3704'
git switch 'main'
git merge --squash 'upstream-pr/3704'
git switch 'main'
git merge --ff-only 'upstream-pr/3704'
git switch 'main'
git merge 'upstream-pr/3704'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3704
No description provided.