shader,gpu: resolve heap-loaded view addresses and widen native complement masks #738
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!738
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-738"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@powplusplus on GitHub · 2026-11-25 06:06 UTC · original
powplusplus:shader/heap-view-addresses→main· +219 −33 · 6 files · 1 commits · openSummary
Unlocks the remaining 5 untranslated ray-tracing shadow-mask trace compute programs (bringing all 64 BVH trace programs in the archive from 59/64 to 64/64 emitted and DXIL-validated):
SLOT_VIEW_ADDRESSES = 252):Lower::view_address), which previously only handled static descriptor tables and failed witha descriptor read only as data.HostHeap(crates/victory-gpu/src/descriptor/host.rs) now maintains a companion upload buffer ofSLOT_STRIDES_COUNT(lo, hi)dword pairs recording each view heap slot's 64-bit title GPU virtual address inHostHeap::mirror, kept as a root SRV inpipeline/host.rsand bound indraw.rs.Lower::view_addressreads(lo, hi)fromSLOT_VIEW_ADDRESSES(with clamped heap index) forRootType::ResourceHeapand dynamically indexedRootType::Tabledescriptor loads.Lower::mask_dword, native wave32/wave64 compute shaders (MaskData::Console && !local) now checkall_lane_blocks(self.x.st)when a mask holds lanes outside EXEC, and callneed(made)when written inside a per-lane branch.emit::emit(crates/victory-shader/src/emit/mod.rs) enableswiden()onMASK_ELSEWHEREalongsideLANE_MASKfor compute shaders so the per-lane skip around the mask is promoted wave-wide rather than assuming divergent blocks run all lanes.Verification
cargo test -p victory-shader --lib(173 passed, 0 failed, including newheap_descriptor_address_reads_from_view_address_tableandnative_wave32_complement_mask_in_all_lanes_block_lowerstests).victory-shader -- -D warnings) and workspace check clean on8dd30ab.VICTORY_HOST_MAX_WAVE=32, RTX 3080,dxil.dll): 64/64 emitted, 64/64 DXIL-validated (up from 59/64). Combined with the single-latch / pipeline-stack fix, 64/64 create D3D12 pipelines on RTX 3080 with 0 failures and 0 timeouts.@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:07 UTC · original · edited 2026-11-25 06:21 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ea40c9aℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -497,3 +498,3 @@if native.stage == HwStage::Cs&& what == lower::LANE_MASK&& (what == lower::LANE_MASK || what == lower::MASK_ELSEWHERE)&& std::env::var_os("VICTORY_WAVE_WIDE").is_none_or(|v| v != "0") =>@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:21 UTC · original
On a 32-lane host running a wave64 compute shader, this arm invokes
widen()whenMASK_ELSEWHEREsurvives the earlier retries even ifVICTORY_WAVE_WIDEis unset. That bypasses the explicit opt-in atemit/mod.rs:404–409, which disables split-wave widening because its group barriers inside branches and loops have caused device hangs. A synthetic 64-thread wave64 shader with a complement defined under an EXEC skip reaches this newly default-enabled path. Restrict the default-on retry to native host waves, and retain the explicitVICTORY_WAVE_WIDE=1requirement for split wave64 execution.Useful? React with 👍 / 👎.
@ -2692,0 +2695,4 @@// table in it): read its 64-bit title address from the host's per-slot// table (`SLOT_VIEW_ADDRESSES`).if matches!(rp.root, RootType::ResourceHeap | RootType::Table) {let slot = self.heap_index(site, 0, false).ok()?;@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:21 UTC · original
For a dynamically indexed table containing a CBV,
State::tables()relocates the table into dynamic host slots, andbind()substitutes that new base into its user data. Consequently,heap_index()returns a dynamic host slot here, but the address buffer is populated only for title slots throughnote_buffer();make_at()andconstant_at()never populate the relocated entries. These newly supported shaders therefore read a zero address instead of the buffer's title address and access the wrong memory. Use the original title-table index for this lookup, or populate the address metadata alongside relocated descriptors.Useful? React with 👍 / 👎.
@ -3047,0 +3079,4 @@&& made.is_none_or(|b| match &self.exchange {Some((_, _, all)) => all.get(b).copied().unwrap_or(false),None => all_lane_blocks(self.x.st).is_some_and(|all| all.get(b).copied().unwrap_or(false)),@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:21 UTC · original
For a native wave32 group with 16 threads,
all_lane_blocks()proves only that every launched lane reaches the block, not that all 32 mask bits have corresponding host invocations. If EXEC is narrowed to0xffands_xor_b32 s2, exec_lo, -1is subsequently read as data, this new check accepts it, but the emitted ballot returns0x0000ff00rather than the console result0xffffff00: lanes 16–31 cannot vote. The parent rejected this case. Require complete native waves for this shortcut, or explicitly reconstruct the mask bits belonging to unlaunched lanes.Useful? React with 👍 / 👎.
@ -3047,0 +3079,4 @@&& made.is_none_or(|b| match &self.exchange {Some((_, _, all)) => all.get(b).copied().unwrap_or(false),None => all_lane_blocks(self.x.st).is_some_and(|all| all.get(b).copied().unwrap_or(false)),@Dathinel on GitHub · 2026-11-25 21:45 UTC · original · edited 2026-11-25 21:58 UTC
Confirmed on an RTX 3050 Laptop at PR head
ea40c9a. One detail for the regression fixture: the word0x8802_C17Einnative_wave32_complement_mask_in_all_lanes_block_lowersdecodes as s_or_b32, although the comment says XOR. The XOR word is0x8902_C17E(SOP2 opcode 0x12).With EXEC narrowed to the low eight bits, I read the scalar result back through lane 0. With the XOR word, a full 32-thread group returned the reference
0xffffff00; a 16-thread group returned0x0000ff00. With the original OR word the respective outputs were0xffffffffand0x0000ffff. A local full-wave guard and corrected fixture preserved the XOR result for 32- and 64-thread groups (native wave32) and rejected the partial groups of 16 and 48 at lowering. Both focused tests passed. This is a synthetic readback; it does not establish which of the five title programs use partial groups. AI-assisted.Follow-up on the partial group: a narrow alternative to refusing this specific shader pattern is to ballot the bounded input and then invert the scalar. When the original EXEC is narrowed by AND-saveexec, unlaunched lanes have zero input bits. Inverting the resulting 32-bit scalar restores their ones. The candidate below applies only to native wave32, the direct narrowing of entry EXEC, and an XOR with inline -1 in a block reached by the whole wave. Other partial complement shapes still refuse.
RTX 3050 Laptop: 24 single-group readbacks across sizes 16/32/48/64, then eight groups per dispatch, each writing a different expected word. Group g enabled the first g lanes of the selected wave; its last launched thread stored the result after EXEC was restored. All 48 group/wave results matched
0xffffffff << g, including the second, partial wave of each 48-thread group. For a scalar select reading SCC from this same XOR, the incremental change below compares the reconstructed dword with zero. On the RTX 3050, 36 flag readbacks matched, including when EXEC was restored and the destination SGPR overwritten before the select. A partial-group OR control still refused. This exercises a direct scalar select; it does not cover arbitrary SCC consumers. No claim about title visuals.Candidate emitter diff against
ea40c9a(includes corrected XOR test word)@ -2692,0 +2695,4 @@// table in it): read its 64-bit title address from the host's per-slot// table (`SLOT_VIEW_ADDRESSES`).if matches!(rp.root, RootType::ResourceHeap | RootType::Table) {let slot = self.heap_index(site, 0, false).ok()?;@Dathinel on GitHub · 2026-11-25 22:05 UTC · original · edited 2026-11-25 22:10 UTC
Confirmed the relocated CBV case on
ea40c9awith a synthetic D3D12 heap. The original slot contained the sentinel title address 0x1_1234_5600, while the dynamic slot's companion-table entry read 0. Passing the original title address separately from the scratch GPU VA to constant_at made the same test pass, including a second binding with a different high dword and clearing the slot to null (1 passed, 0 skipped). This reads the mapped table on the CPU. The SRV null-fallback path and visible output remain unverified.A related NVIDIA comparison is Marvisak/VIctory#2178. Its RTX 5060 Ti tests exercise raw versus structured descriptor stride. That is a separate variable: for a shader-side regression test here, keep descriptor type and stride fixed and compare original versus relocated slots. That would distinguish an incorrect title address from an incorrect byte offset.
Shader readback on an RTX 3050 Laptop now confirms the SRV case. I registered a 256-byte synthetic buffer, placed a structured SRV with FirstElement=3 and stride=16, and verified that make_at created a backed view. A one-thread HLSL dispatch read three 64-bit entries via t252 with Load2(slot * 8), then copied the UAV output back after a fence. With the make_at metadata write omitted, the original slot returned base+48, the relocated slot 0, and the null control 0. Restoring only that write gave [base+48, base+48, 0]. This isolates the SRV metadata write. The probe does not run a translated game shader or measure frame output.
AI-assisted investigation and synthetic tests.
@ -1352,0 +1380,4 @@let host = heap.host()?;let gpu = host.addresses_gpu()?;const ONCE: usize = usize::MAX - 0x5f;if list.first_use(ONCE)@BradRoland on GitHub · 2026-11-25 22:14 UTC · original
This key is shared by every heap on the list. If the list binds heap A, then B, then A again, the second call returns B’s GPU address while only A’s address buffer has been retained. The native descriptor heap and this separately allocated upload buffer have independent lifetimes. The title can release B before the GPU consumes that root SRV.
I reproduced this through
State::bindwith the PR’s synthetic shader on an RTX 4080. At list close and after synchronous submission, the list held A’s address table once and B’s zero times. Retaining each distinct table produced one reference to each. Reset released both. This checks ownership without dispatching against a freed buffer.I put the correction and a focused regression in a single commit based on this exact PR head. The regression passed on WARP, and all 139 enabled tests passed in the hardware GPU suite. Cherry-pickable correction
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.