Shader size: census of the 2.4x (25,635 programs), two measured reductions, and what avatarmanz's fork has for the black shadows #1383
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from fxceless/victory-fork. Originally posted by marekpastuszczak-lang on 2026-11-26T21:28:11Z.
Two things that may save you time, from reading this fork next to avatarmanz/VIctory-7900XTX and from an offline look at the translated shaders. Nothing here was run in the game; where a number is a measurement it says of what.
1. Where the 2.4x goes: a census of the whole archive
The README says the translated programs are about 2.4 times the console's instruction count "broadly, with no single" cause. I ran
VICTORY_SHADER_CENSUSover the whole shader archive (build085ee7c, 25,635 programs) and weighted it by the per-pipeline card times of one world run:So it is indeed broad, but two things stand out.
a) The legacy multiply.
legacy_mul/legacy_fmadinemit/lower.rsemitfmul+ twofcmp oeq 0.0+or+selectfor everyv_mul_legacy_f32. Compares of a float against zero alone are 6.7% of all host instructions; the whole pattern is my estimate of 12 to 15%.avatarmanz already has a cheaper form:
rdna::LEGACYincrates/victory-shader/src/emit/mod.rsand the first branch oflegacy_mulinlower.rsreturn the plain product when the factors are the same value, both bounded, or one a finite non-zero constant, and one compare otherwise. Their own note inmod.rsputs it in proportion, though: the whole float set took the title's dispatches and draws from 18.4 to 17.6 ms on an RX 7900 XTX, 0.4 ms of that fromLEGACY. So a real saving in instructions, a small one in card time on that card. It is gated to RDNA hosts there.b) An LLVM pass over the finished module. The five passes in
emit/bitcode/opt.rsare the only optimiser. I fed 400 modules from the shader cache to DXC'sIDxcOptimizer(dxcompiler.dll1.8.2502, from the Windows SDK) and counted instructions from the disassembly:-instcombine -gvn -adce -simplifycfg-sroa -early-cse -simplifycfg -instcombine -reassociate -sccp -jump-threading -correlated-propagation -simplifycfg -instcombine -licm -gvn -dse -bdce -adce -simplifycfg -instcombine -strip-dead-prototypes0.03 to 0.07 s a shader. The gain is in bitcast, select, shifts and branches, not in the arithmetic.
dxil.dll's validator accepts 386 of the 400 after the passes against 388 of 400 for the modules as translated; the two new refusals are "Flags must match usage", so the shader flags would have to be recomputed after the passes. Whether 10% fewer cheap instructions moves the card's 84 to 128 ms I cannot say; I did not run it.This is the measured side of point 2 in #1382.
2. Two open items here that avatarmanz's fork has answers for
Their fork left yours at
a26859fand has not come back, so in case you have not looked:crates/victory-gpu/src/ambient.rsthere is a stand-in for the bounced light (VICTORY_AMBIENT, with creases and air), and since today a band that keeps the traced indirect light in range when ray tracing is on (VICTORY_AMBIENT_RT=<least>,<most>).VICTORY_PORT_CONSTANTS_ORDER, on by default, 2 to 5 ms;reports/POPIN.md, runs pop-14 to pop-17).In the other direction I have told them about
VICTORY_HEAP_WORKERandVICTORY_LOOKUP_CACHE, which they do not have.