Repository navigation
Conversation
…ate on 32-lane GPUs Two gaps kept the ray-tracing programs off on a host whose waves are 32 lanes. 1. Buffer views picked from the view heap at a computed index. The shadow-ray trace programs read the address of their structure out of a heap descriptor they choose with a per-wave index, and walk the memory behind it. The translator could only take such an address from a fixed table position. The host now keeps, after the strides of `SLOT_STRIDES`, two more dwords per heap slot (low and high of the title address of the buffer view there), written where the strides are written, and the shader reads them by heap slot (`SLOT_ADDRESSES`). No new root parameter; the table grows from 8 MB to 24 MB per view heap. 2. `lane_uniform` proves three more things where no lane of a wave can part from the others: `tid >> 6` of the entry thread number (in a group whose x size is a multiple of 64) is the same in all lanes of a console wave; an `ds_read_b32` at such an address is; and a value joined by a phi, also at a loop header, is when its arguments are and every predecessor is entered by all the arriving lanes or none (a greatest fixed point over the loop's carried values and lane masks). The structure builder's block-scan programs fetch a wave-uniform running total with `v_readfirstlane` in such a loop; without the proof they asked for an exchange between the two host waves where not every lane runs. Effect, with `VICTORY_HOST_WAVE=32` on a 32-lane card: - 4 of the 5 shadow-ray trace programs (and their screen-space variants) now translate and validate; the adaptive one still stops at a lane mask read as data. - 52 of the 52 structure-builder programs now translate, validate and create a host pipeline (3 did not). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
I found a wrong-code case in The regression initializes I put a fix and the synthetic test in fb57dd0, directly on your PR head. All three divergent cases failed before the change and pass afterward. The paired cases still take the optimization when the old VGPR is uniform too. AI-assisted. Tested the shader library on Linux with |
|
Tested Machine: Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 3050 8 GB (driver 32.0.16.2124), AMD Ryzen 5 3600, 16 GB. D3D12 Agility SDK 1.620.2 (Marvisak/VIctory#175/#362, needed on Windows 10 for SM 6.6).
The three that failed before are the same three the runtime names on this machine as the stages that keep the builder off ( Without Tests: Not done yet: a title run with Tested and written with Claude Code (Claude Opus 5.5). |
|
In-game result with the builder on, RTX 3070 8 GB, Windows 10 22H2 + Agility 1.620, Series X profile. Tree: main at 4e17478 + #81 + #150 + this PR + ryotdev's fb57dd0 (+ #40, #51, #52, #63 and a local save-folder fix). Diagnostics build,
With the builder off (default), the same tree runs fine, at ~1.8 fps in a diagnostics build. Faces in cutscene close-ups come out black with only the eye rims lit, in every run. They also go black in a dark shot without this PR, so I read it as the missing ray-traced bounce light rather than a bug here. |
|
RTX 3070 Ti, fork main 4e17478 + #23 #24 #25 #51 #52 #32 #58 #71 + #92 #115 + this PR,
AI-assisted (Claude Code). |
Keep both export lists in emit/mod.rs: main's view_heap_limit and this branch's SLOT_ADDRESSES and SLOT_STRIDES_DWORDS. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ict resolution
Shaders: lower v_mul_hi_u32_u24 and v_mul_hi_i32_i24
|
Tested on Windows 10 (19044), RTX 3080 (32-lane waves), title build 1.0.2.1, release + diagnostics. With this PR + #213 and However, once the builder engages in-world the title crashes ~7 s later: unhandled With the builder left OFF, the irradiance-cache shade shaders translate (with #11) and the static world renders lit. Sharing in case the garbage-bounds path is reproducible on other 32-lane NVIDIA cards. |
Shaders: lower v_mul_hi_u32_u24 and v_mul_hi_i32_i24 (cherry picked from commit 256d7b9)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…witch, its lowerings of instructions the title does not run, and 16-bit results by MODE Ported from Marvisak/VIctory into emit/official.rs, a child module of the lowering; lower.rs and the instruction modules (valu, valu16, salu, buffer, interp, image, export) only call it (lower.rs: 129 bytes more, for the module and the round-mode state). On by default, `VICTORY_<NAME>=0` gives the translation as before (each is part of the shader cache key): - VICTORY_MESH_EDGE_FLAGS (#1718, c0228d9): a mesh primitive's corners are 9-bit indices, the edge flag above each (bits 9, 19, 29) no part of it. Ours took 10 bits, so a flagged corner named vertex 512+ and the triangle was culled as naming a vertex past the program's count. Every mesh program's DXIL (the mask constant). - VICTORY_NORM_ENDS (fxceless#169, 645391b): a normalized buffer format's ends load as exactly 1.0 and -1.0 whatever the host's division gives there (vertex fetch, typed-format loads of compute programs): 9,764 programs. - VICTORY_CUBE_GRAD_LEVEL (4f57f46; the same fix as 9ee9adf of fxceless#767, flagged by amdsh): a cube sample with gradients takes log2 of the longer gradient in texels (DXIL's Log is base 2, ours multiplied it by log2(e) again: 1.44 times the level, blurrier cube reads), at least the _cl clamp: 29 pixel programs. - VICTORY_SMINMAX_SCC (77053a0's scalar part): s_min/s_max set SCC to whether the first operand was chosen (RDNA2 ISA); ours set result != 0. - VICTORY_INTERP_F16_MODIFIERS (#1696, e29391f): v_interp_p2_f16 honours op_sel[3] (the high half), omod and clamp; only an instruction that has one of them translates differently (the title's have none). - VICTORY_DEAD_PHI_LATCHES (#1471, be3202d): an empty loop latch whose phis are all unread folds as an empty one does. - VICTORY_BRANCH_FALLTHROUGH (#1282, 1ed26e5): a conditional branch to the next instruction is a jump. As a branch it gave its block the same successor twice, and the join's phi the wrong value (the official test fails on ours without it, on WARP). Off by default: - VICTORY_OMOD_ZERO=1 (77053a0): an output multiplier reads a denormal operand as a zero of its sign and gives +0 for a zero product, as RDNA2 measured with IEEE mode off. Compilers fold every x2, x4, x0.5 into one: 12,276 programs would gain its eight instructions, for the sign of a zero. - 16-bit results by MODE (77053a0), under our VICTORY_F16_NEAREST=1: every f32 to f16 result of a VALU operation (v_cvt_f16_f32, v_fma_mixlo/hi_f16, packed and scalar f16 arithmetic, f16 interpolation) rounds as the console's MODE says where it is: toward zero after `s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 3` (the title writes it 6,694 times, around its 16-bit interpolation), to nearest even elsewhere; the switch covered 16-bit arithmetic only, at nearest even everywhere. Without switches (no program of the title runs them): s_quadmask_b32/b64 (#1443), v_cvt_off_f32_i4 (#1391), v_sad_u8/hi_u8/u16/u32 and v_msad_u8 (fxceless#162), v_mul_hi_u32_u24/i32_i24 (fxceless#156), tbuffer_load_format_d16_* packed two channels a VGPR (fxceless#169, c430b1d), a signed 64-bit operand's literal sign-extended (fxceless#447, 7d04943), v_cndmask_b32 on an inline constant mask or a mask the structurisation keeps among its other masks (#1221, 67c4f53; Structured::other exported), and v_cmp_f/tru as constants (`fcmp false/true` removed the WARP device; 77053a0). format_load and write_half became pub(super), for official.rs. Tests: the official ones of these (valu_tests on the hardware adapter and WARP: quad masks, cvt_off, tbuffer d16, normalized ends, i64 literals, branch to fallthrough), its instruction tests fxceless#1052, fxceless#1050 and fxceless#990 (they pass on ours unchanged), CPU models of the SAD, 24-bit high multiply and s_min/s_max SCC results, and the MODE rounding under VICTORY_F16_NEAREST. Census (CPU, against wave5's own): with every switch off, every program's DXIL is byte for byte as before; with the defaults, 10,711 programs change (Ms 8,765, Cs 1,077, Vs 840, Ps 29) and none is lost or gained (25,953 of 25,953 pass either way).
What
Two translator/host gaps kept the title's ray-tracing programs from running on a host whose waves are 32 lanes (the console's are 64). This PR closes both.
With
VICTORY_HOST_WAVE=32on a 32-lane card:the ray-tracing structure builder stays off ... missing=3.Changes
1. Buffer views picked from the view heap at a computed index (
shader.rs,mod.rs,descriptor/host.rs,lower.rs)The shadow-ray trace programs read the address of their structure out of a heap descriptor they choose with a per-wave index, then walk the memory behind it. The translator could only take such an address from a fixed table position (
view_addressrefusesa.dynamic).The host now keeps, after the strides of
SLOT_STRIDES, two more dwords per heap slot: the low and high dword of the title address of the buffer view there. They are written where the strides are written. The shader reads them by heap slot (SLOT_ADDRESSES,Lower::slot_address). No new root parameter and no change todraw.rsor the pipeline code.Cost: the table grows from 8 MB to 24 MB per view heap.
2.
lane_uniformproves three more things (lower.rs)Each only where no lane of a wave can part from the others:
tid >> 6of the entry thread number, in a group whose x size is a multiple of 64, is the same in all lanes of a console wave;ds_read_b32at such an address is;The structure builder's block-scan programs fetch a wave-uniform running total with
v_readfirstlaneinside such a loop. Without the proof they asked for an exchange between the two host waves where not every lane runs, which cannot be done (it needs a group barrier).shortcut:(marked in the code) an LDS read is taken to see what a read by another wave of the same instruction would. A write by another wave between the two host waves' reads is not looked for; the scan programs read after a barrier.Testing
Hardware: one NVIDIA RTX 3090, Windows 11 (32-lane waves). Nothing else was tried.
cargo clippy --release -p victory-shader -p victory-gpu: clean.cargo test --release -p victory-shader -p victory-gpu: 110 + 210 passed, 0 failed.victory translate --validate --pipelineswithVICTORY_HOST_WAVE=32over the structure-builder library: 52 emitted, 52 validated, 52 pipelines.What this does not do
VICTORY_BVH_BUILDER=1(also withVICTORY_BVH_QUARANTINE=1) the builder now does start (all 53 programs have host pipelines), but in my runs the frame time went from about 0.3 s to about 4 s and the scene came out washed out in white. I did not try it without quarantine. Nothing here changes its default.Does it only work on this GPU?
I only know it on the 3090. By construction:
lane_uniformproofs only matter where a console wave64 program runs as two host waves of 32 and would need an exchange between them. On a host with 64-lane waves that path is not taken, so it should be inert there.🤖 Generated with Claude Code