Repository navigation
Refuse VICTORY_INDIRECT_CLAMP=0: it kills the run, and hoisting is the answer to the cost - #169
HailLucifer666 wants to merge 1 commit into
Conversation
…DIRECT_CLAMP=0 opt-out to bypass per-draw argument clamping Part of #16
|
Tested this on GTA VI (Series X build), RTX 5080, Windows 11, with With The title's own crash reporter then starts (blocked upload to backtrace.io). That is a deliberate null write: the game's own fatal path, not a fault in VIctory. Both runs died about 90 s after launch, during the load into the world, before any gameplay frame. The same binary with the clamp left on (the default) loads and plays normally. So on GTA VI at least, some indirect arguments the title produces need the clamp, presumably group counts the clamp zeroes or bounds. Running One caveat for honesty: the same crash site showed up once before, on a first launch of a build with the BVH builder (#36), which then loaded fine on relaunch. Here it reproduced on the relaunch too, with a warm shader cache, which is why I attribute it to the switch. Context, in case it helps anyone working on GPU time: on this card the frame is front-end bound (Nsight Systems GPU metrics during gameplay: GR active ~75%, SMs active ~28%, SM issue ~4%), with ~5,000 one-record indirect mesh draws per frame, each with its clamp pass. So the cost of the clamp + (Tested and written with the help of an AI assistant, Claude Code; numbers above are from our own runs.) |
…cked Shaders: tbuffer_load_format_d16 loads pack two 16-bit channels per VGPR
…T_CLAMP=0 opt-out to bypass per-draw argument clamping (by HailLucifer666)
|
Thanks — this is the most useful telemetry on this PR, and I am taking both findings as they are. The flag is diagnostic only. The bottleneck is the one this PR was aimed at, but bypassing is the wrong route. ~5,000 one-record indirect mesh draws a frame with GR active ~75%, SMs ~28% and SM issue ~4% says the frame is front-end bound on the compute↔graphics switches, not on the clamp's arithmetic. Removing the switches by removing the clamp also removes the safety, which is not a trade worth making. The next step is to batch the clamp itself: one clamp dispatch, or a few windowed ones, covering a whole run of consecutive indirect records instead of one pass per record — every bounds check kept, and the Also noted that the same crash site appeared once on an earlier build and did not reproduce on relaunch — thank you for saying so rather than leaving it as clean attribution. It does not change the conclusion for the flag. |
5805143 to
eb56807
Compare
|
Rebased onto Two things worth knowing before merge:
Gate on |
c4f3bb8 to
ffda299
Compare
|
Rebased onto current Re-verified after the rebase, since a probe on an old tree proves nothing about the new one: Two corrections to what this PR body says above:
|
8e35e16 to
6555675
Compare
…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).
…same output, mesh stage data without the vertex inputs (#1366), mesh primitive indices of 9 bits (#1718, VICTORY_MESH_EDGE_FLAGS), normalized ends exactly +-1 (fxceless#169, VICTORY_NORM_ENDS), cube gradient level (4f57f46, VICTORY_CUBE_GRAD_LEVEL), the official semantics suite, SP3 text and s_atc_probe (fxceless#661, fxceless#1021)
What changed, and why the title changed
This PR no longer adds a bypass. It refuses one.
The bypass was meant to answer a real, measured cost:
dkdknight's Nsight capture on an RTX 5080 shows about 5,000 one-record indirect mesh draws per frame, GR active ~75%, SMs ~28%, SM issue ~4% — the machine is waiting on per-record work, and the per-record clamp pass is part of that work.He then set
VICTORY_INDIRECT_CLAMP=0and both runs died with0xc0000005writing0x0, within seconds, twice out of two. The title's argument buffer holds records whose bounds the pass is what enforces. Removing the check does not make it faster; it makes the process stop.So
0now means "I read the complaint, and no":clamp_settingreturns(clamp on, say so); the clamp is on for every value.clamp_is_onis consulted where the clamp is first made, so even a run that never reaches the pass is told.With no path left that could honour it, the dead half is deleted rather than left unreachable: the
if !clampedbranch, the twoif clampedteardowns, andwait_direct, which existed only to barrier an unclamped execute.What answers the cost
Hoisting the clamps out of the per-record path —
VICTORY_HOIST_CLAMPS, Phase I (perf/hoist-indirect-clamps, switch landed, default off). That keeps the bounds check and stops paying for it once per record. When hoisting is the default and survives hardware, deleting the per-record pass becomes a conversation with evidence behind it. This is not that conversation.Evidence
clamp_settingreturnsparse_clamp_enabled(asked)again → the new test fails withleft: (false, true), right: (true, true)→ restored byte-identical (indirect.rssha256ade38ee886e354e5).cargo test -p victory-gpu --lib: 161 passed, 1 failed —warp_budget_saturates_without_wraparound_and_preserves_draw_fields, the known flake (Tests: the warp budget test accepts either group winning the budget race #847/Indirect test: the two groups charge the budget in either order (the test failed 5 runs in 6) #849), untouched by this commit.cargo clippy -p victory-gpu --lib -D warnings: only the two pre-existing Clippy: main is clean again with -D warnings, with and without --all-features (3 lints) #841 errors (placed_filler_twins,sort_unstable_by_key) remain.Not covered
Native D3D12 — no GPU here. The refusal is proven by its decision and its message, not by a frame. Anyone who genuinely wants the old behaviour keeps it by running an older build, which is the honest place for a switch that crashes.
VICTORY_INDIRECT_CLAMP=0no longer does anything except print a warning. If that was in a launch script, it can come out.