Repository navigation
Shaders, second round: geometry programs as geometry shaders, loops as the console runs them, lighter wave64 forms, dispatches past 65,535 groups in x (stacked on #854) - #993
Open
PiloteCode wants to merge 36 commits into
Conversation
…s-only count `cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6 with this toolchain: unnecessary_sort_by in draw.rs, the bench's depth_written in indirect.rs never read, and placed_filler_twins unused without the diagnostics feature. No code changes.
…rams over 32 KiB linked with their pixel program, and more: 230 more programs pass Over the title's shader pack (`victory translate --validate --pipelines` on an RTX 5090, 32-lane waves), 25,682 of 25,953 programs translate, validate and get a pipeline, against 25,452 on 9376fd6 (compute 2,729 against 2,695, mesh 8,694 against 8,657, pixel 12,067 against 11,947, vertex 2,192 against 2,153). Of the 271 left, 195 are the unused voxel geometry stages and 71 the mesh programs below, valid once linked. - Wave64 compute programs on 32-lane hosts in a paired form: each console wave runs as one host wave, each thread two of its lanes (n and n + 32); every per-lane branch is taken by the whole wave with EXEC as each lane's guard, and lane reads, permutes, lane masks and reductions take both halves through the host wave's own operations. Tried after every other form for a program the host refuses (it asks for 64-lane waves) or that does not translate: 28 programs (screen-space tracing tiles, particles, decal trails, hair shadow masks, alpha resolve, three structure-builder programs, a cascade shadow program). Tried before the per-half forms that are approximate: 36 programs in which each half-wave counted, ORed or elected over its own 32 lanes now run as on the console. VICTORY_WAVE_PAIRS=0 turns it off. The allocation idiom also takes a base with a multiply-add (three lens-flare scans keep their per-half form, which is exact for them). - Mesh programs whose outputs pass D3D12's 32 KiB as translated alone (71: pedestrian, vehicle and prop transforms, 65 to 71 components for 128 vertices; NVIDIA builds them, the validator refuses them) are translated again with the pixel program of the pipeline (emit::link_mesh): the mesh program writes only what the pixel program reads, which declares only the inputs it reads. pipeline/host.rs makes such a pipeline from the linked pair (once per pair, same root signature and bindings; VICTORY_MESH_LINK=0 turns it off). `victory translate` with VICTORY_PAIRS links and validates pairs as the runtime does: 710 pairs (each of the 71 with the ten pixel programs that read most of its outputs) link, validate and get a pipeline. - One interpolation mode per signature register (70 programs: a float the console declared nointerpolation beside an integer or the front face); signature rows in the validator's order (72 programs); a level-of-detail query of an array texture leaves the layer undefined. - An immediate sampler chosen by a uniform branch: the block is copied for each way in (ir::split_joins; the terrain programs). - Pixel programs ordered by primitive (POPS) go past the console's wait and use rasterizer-ordered views (ten cut-out programs). - A 16-bit write over a first interpolation half reads that half as zero (eight deferred and decal programs). The write of zero over every first half (v_interp_p1_f32, v_interp_p1ll_f16) is left out: with it, 59 pixel programs that translated came out changed and none more translated; the retry with first-half pairs stays. - Whole-wave sections that a jump splits are joined into one block (the water optical depth program), tried first for a program whose permutes no followed section holds; elsewhere the v_permlane16/x16 lowering stands. - 64-bit floats and their wave sums (five water volumetrics programs), one implementation of the two that existed (float64.rs): both dwords of a sum from one host wave operation (in place of Red64F/ActiveF64, which summed each dword on its own), v_add_f64, v_mul_f64, v_cvt_f64_f32, and the IEEE v_cvt_f32_f64 on integers. Its unused flush-to-zero twin and ignored test are left out. - Descriptors read only for their size, one implementation of the two (descriptor_data.rs): a buffer with a used-resource entry gets the title's view, structured where its elements are whole dwords (a raw handle of such a view answered 2 records where it holds 9 on the RTX 5090); VICTORY_DESC_WHY stays. - A subtraction on group-shared memory (ds_sub, or ds_add of 0 - x) is a compare-exchange loop: NVIDIA's compiler refuses the pipeline otherwise (E_OUTOFMEMORY; DXC's own InterlockedAdd(g, -x) too). The weather particle update gets a pipeline. - A lane mask parked in two VGPR lanes that also hold single scalars comes back as the mask (ir::with_shared_slots; the voxelization program). - Loops of programs that test rays against tree nodes stop at 1,024 iterations (the compute limit is 4,096): with the title's builder off, a walk follows whatever memory holds. Shadow mask 11.7 -> 2.4 ms a frame in timing runs of the opening of the gameplay. The allocation-idiom check (idiom.rs), descriptors read as data (descriptor_data.rs) and 64-bit floats (float64.rs) are modules of their own, so that lower.rs stays under the asset policy's 512 KiB a file. Tests: each new form is run on the card against what the console's 64 lanes give; the linked signatures, the LDS subtraction loop, the shared slots, the joined sections and the descriptor sizes have tests of their own.
…, mesh programs linked with their pixel program (VICTORY_MESH_LINK) The whole pack on an RTX 5090 (32-lane waves): 25,682 of 25,953 programs translate, validate and get a pipeline, against 25,452 at 9376fd6. All 52 structure-builder programs translate (three in the paired form); switched on in game runs, the builder crashed the title about 80 s into the gameplay, so it stays off.
…ate sessions; no conflict
…them The shader tests' host can now bind a root UAV as a table of one raw view (`Root::Uav`, and `Root::UavAlias` for a destination that is its source, as the title rehydrates its structures in place) for a root signature from `Host::compute_pipeline_bounded`, as the layer binds root UAVs: an access past the buffer's end is dropped. An unbounded root UAV let random inputs write past the buffers and remove the device. The views' contents come back after the heap's UAVs, in the order of the roots.
…024,...) The limits of translated loops were literals in count_iteration, and the switch set one limit for every stage. Now they are named per stage (pixel 128, vertex and mesh 256, compute 4,096, ray tracing 1,024, as before) and the switch can set one stage alone (`stage:n` pairs) or all (one number); the shader cache keys on all four. The documentation says what a lane at the limit does: where the loop branches back on a condition it leaves the loop and goes on; where it jumps back it leaves the program (a pixel discards).
…s limit (VICTORY_LOOP_NOTES=1) With the switch, every program with a counted loop gets a root UAV of ours (u252, space 1) and each lane that reaches a loop's limit adds one to that loop's record: the lanes that left the loop and went on, and the lanes the limit took out of the program, by the loop's first code byte. The host binds each program a range of one shared buffer of its own at its first draw and logs the records that grew every five seconds, by stage and hash. A helper lane of a pixel shader writes nothing, so it is never counted. Off by default: it adds a root parameter to every program with a loop. Part of the shader cache key. First run, the opening cutscene from a new game (8 minutes, 254 programs with counted loops drawn): only the three environment BRDF integration programs reached a limit, all 65,536 texels of each table in each of their six loops; no lane of any program was taken out.
The console runs a pixel program's helper lanes as lanes of EXEC (the program starts with s_wqm), so a waterfall loop over descriptors serves a helper lane in a pass of its own, with its own descriptor. The host's wave operations leave helper lanes out (SM 6.6) and give them undefined results: a helper lane whose value no other lane of its wave held never met it as the first lane, went round the translated loop to the iteration limit (with the loop's samples each pass) and left with what the loop computes never set, which its quad's derivatives then read. The character skin and cloth program (94d281151ca58b4f) samples its material layers in nine such nested loops. A first-lane read in a pixel program now gives a helper lane its own value; since scalar code made of such a read may then differ in helper lanes, every heap handle of such a program is created non-uniform. Test: a waterfall over each pixel's own number, with the count of the lane across the quad's x read through a quad permute. On the RTX 5090 the helper lane's count was 0 (never served) before, 1 now; WARP agrees.
…limit The iteration limit is for loops whose end the data decides (a count read from memory the host has not got yet). A loop whose exit is a scalar counter that starts at a constant, moves by a constant step each pass and is compared with a constant (at its bottom, or at its top with a jump back) runs as often as the console's, up to 65,536 passes: its limit becomes its own count. The title's environment BRDF integration tables (PS_IntegrateEnvBRDF, the Beckmann and thin-film variants) integrate 1,024 samples a texel, two or four a pass, in six loops of 256 or 512 passes. At the pixel limit of 128 every one of the 65,536 texels of each table stopped at a half or a quarter of its samples (loop notes, opening cutscene), and the tables, which every specular reflection reads, held a half or a quarter of their values. Translated now with limits of 256 and 512. Tests: the count analysis on synthetic loops (bottom and top tests, four adds a pass, counts the data bounds or that never meet their constant), and a compute loop of 5,000 passes that runs past the compute limit on the GPU and WARP.
Where two host waves run one console wave of 64 lanes, they exchange first lanes, masks and LDS order through group barriers, only in blocks every lane runs (`all_lane_blocks`): no per-lane branch's region, the blocks a branch reaches that do not post-dominate it. A loop each lane leaves on its own (its back edge or a break on the lane's own bit) has blocks that post-dominate the branch, its own among them, yet only the lanes that stayed run them again: a waterfall loop in one block was taken for code every lane runs and got two host waves' exchange of the first lane, four group barriers a pass, which lanes that had left met at other barriers. In the projected-decal classification (CS_ProjDecalReduceClassification_Scalarized, 1f1fbd86759b3da2) lanes then never met their descriptor and ran to the compute limit of 4,096 passes: 77 lanes in each of five loops, 44, 19 and 1 in three more, in seven minutes of the gameplay's opening (loop notes); those lanes lost their loads. A loop a lane branch leaves is now part of that branch's region (natural loops of the lane exits). Of the 1,085 compute programs seen in the title's runs, two translate differently: the decal classification takes each host wave on its own (approximate: the tile's sums are each half's; the exact paired form is tried after the approximate ones), and CS_SortRayTiles (a1bf269d5b19f025) keeps its form with its LDS ordered by group barriers at the loop's ends. Test: the waterfall's block is not every lane's, a scalar loop around a lane branch still is.
…n 100 columns, tests last, lint)
lower.rs had grown past the asset policy's 512 KiB per file (533,966 bytes; `cargo xtask policy` refused it). The limits by stage, the count and its test on back edges and the loop notes move to emit/loops.rs, the regions of lane branches (blocks every lane runs, the natural loops they leave) to emit/regions.rs, both child modules of the lowering. No change in what is emitted; lower.rs is 520,593 bytes.
…t by ending the lane A loop that goes round by jumps back alone has its exit test elsewhere in its body; at the limit its jump back could only end the lane (a pixel discarded, a mesh or compute lane stopped before its writes). Its exit tests now take the limit too, so a lane at the limit leaves there and goes on with the program, as one does at a branch back; the jump back still ends a lane whose way round passes no exit test. With the limits raised to 1,024 / 4,096 / 65,536 (VICTORY_SHADER_LOOP_LIMIT, loop notes) the opening cutscene lost the card again, 9 minutes in, and the notes named loops of that kind that never end: PS_Textured_Eight (b37565055f2f7d3b, 1af4a50c7fb40c97), whose search of its shadow cascades reads its cascade count as 0 (the count minus one never stops it), 10,441 pixels taken out at 1,024 (holes in what it draws); and the projected-decal resolve's walk of its decal bits (c4183d3cbee28e8e, in the approximate one-host-wave form), 10,381 lanes at 65,536. The limits stay where they were; the comment records why. The loop limit's helpers (`limit_of`, the exit test, the search for such loops) live in emit/loops.rs. Tests: a loop closed by a jump goes on with s6 at the limit; one whose way round skips its exit still ends the lane.
…ery stage
With loop notes (VICTORY_LOOP_NOTES=1) every program with a counted loop
binds the notes as a root UAV. A vertex or mesh program that binds a UAV
must say so (ShaderFlags bit 16, SFI0 0x4); without it the validator
refused 62 of the 801 vertex and mesh programs of a game run translated
with notes ("Flags must match usage"); with it they all validate (but
the two whose outputs pass 32 KiB, as without notes). The runtime does
not validate, so the game ran them as they were.
Test: a vertex program writing the notes' UAV validates.
For an A/B of what the fix changes on screen: with the switch at 0, helper lanes of pixel programs read the host wave's first lane in the title's first-lane reads again, as before. On by default; part of the shader cache key (the build script lists every VICTORY_ switch the translator reads).
…remote-desktop reset The opening cutscene run with the limits raised to 1,024 / 4,096 / 65,536 did not lose the card to a long loop: Windows reset it 2.5 s after a Parsec session ended (09:54:32 disconnect, 09:54:34 "Resetting TDR"), as in the day's other losses. The limits stay where they are for the reason the loop notes give: no loop needs more, and the ones that reach them never end (PS_Textured_Eight's cascade search, the decal resolve).
…5,535 groups in x is named The clamp of indirect records counts, per list, the compute records that ask for more groups in x than one dispatch runs (up to 93,648 in the runs of this morning, cut to 65,535: the rest never run), but not whose they are. At recording, the arguments are now read where title memory has them (the card writes them, so this is an earlier frame's copy-back), and the first record over the limit of each program is logged with its counts.
…s count their groups from a base the host gives One host dispatch runs at most 65,535 groups in a dimension; the console runs more. The title's depth-of-field blur asks for up to 115,200 groups in x every frame of a defocused shot (2 x 57,600: one group per 8x8 tile of each of its two layers at 2560x1440; the clamp of indirect records counted 81,064 to 115,200 asked, 0.3 to 3.5 records a frame cut, in the opening's first minutes), and the clamp cut the record to 65,535: the groups past it never ran. The tiles of the second layer past that point stayed unblurred, which shows as blocks: in the kitchen shot the blinds are blurred above a row and, in that row, left of a column, sharp everywhere after it, the shape of a tile list in reading order cut after its 65,535th tile. - Translator: a compute program's group id in x adds a user-data dword the host computes, USER_GROUP_BASE (0x104), as the host's other words are given (not for programs with a spilled user-data table, whose root signature is close to the host's 64 dwords). - Direct dispatches of more than 65,535 groups in x run as several, each told its first group by a root constant. - Indirect dispatches of such programs are clamped as split dispatches (a kind of the clamp's own): each record becomes four records of the base and the counts, at most 65,535 groups in x each (up to 262,140 in all), run through a command signature that sets the base and dispatches; the records past a count buffer's count come out empty, and every one runs. Tests: on the software adapter, a record of 100,000 groups runs each group from 0 to 99,999 once and a record past the count runs none; the clamped records and the budget charged are checked. A compute program reading its group id in x asks for the base; one reading y does not. The 3,418 shaders of this morning's runs translate with the change (warm-up, 94 s).
A split dispatch's command signature is cached by the address of the root signature it was made for (with the root parameter and dword of the group base). D3D12 does not say that a command signature holds a reference to its root signature: with the root signature released and another made at the same address, the cache would hand out a signature made for the first, and ExecuteIndirect with a command signature of another root signature is undefined. The cache now keeps the root signature alive with it, so an address in the cache names one root signature for the whole run. Few root signatures run split dispatches (the screen-probe final gather's and the meshlet culling's in the general tests), so nothing much is kept.
A program that counts its groups from a base is named once (info) when its indirect dispatch asks for more than 65,535 groups in x, and run as several; one that asks for more than runs even so is still a warning.
It runs nothing whatever its x (one such record, 6,062,079 x 0 x 0, was named in the opening run of the split dispatches).
…a 32-lane host With VICTORY_SHADER_CENSUS, `victory translate` now writes `form=` for each console wave64 compute program translated for a host of 32-lane waves: paired, local (each host wave on its own), local-any (approximate), exchange (two host waves meeting at group barriers), halves (two host waves with nothing to exchange) or wave64 (refused by such a host); empty for every other program. The lowering names its form, and each program emitted since the last `emit` is remembered by its DXIL, so the form of the one `emit` returns is known whatever forms were tried before it. On integration (9376fd6 merged), the title's wave64 compute programs: 69 paired, 30 local (all the allocation idiom, exact), 160 exchange, 141 halves, none refused.
…re only lanes inside the guard read it In the paired form every per-lane branch is the wave's, so EXEC stays a guard on each vector instruction and a guarded write is select(guard, new, old): about a sixth of the paired programs' host code (360,668 of 2,303,768 instructions in the title's 69 paired programs, against 29,850 selects of that kind in all the other forms of the same programs), each keeping the register's old value alive. A lane that reads the register under a guard that implies the writer's ran the write, so it now reads the value as computed: its own registers only (not a DPP source, a lane read or write, a swizzle or permute, which read other lanes), never the old value a write keeps for the lanes outside its guard. The reader reads the writer's SSA value, so the writer dominates it and no atom of the writer's guard is defined again in between: both guards are evaluated on the same lane-mask atoms, and the implication of the two functions (Bools::meet) holds lane by lane. The selects nothing reads any more go with the clean-up's dead code. Offline (CPU census, every program of the title): only the 69 paired programs change; their host instructions 2,303,768 -> 1,617,871 (-30%), guard selects 360,668 -> 124,509, joins 151,991 -> 122,297. VICTORY_WAVE_RAW=0 turns it off. Test: values written and read under the same guard, a narrower one in the block and in a nested branch, a wider one after it and by every lane past the branch, floats and an accumulator, against the console's 64 lanes.
…n as two host waves of their own, not meeting at group barriers A console wave64 compute program whose wave-wide values are used only as the allocation idiom uses them (idiom::wave_local: each wave's first lane reserves its count on a shared counter, every lane takes the base plus its rank) is exact with each host wave on its own: the same records, reserved by each half in another order. That form was only tried for programs no form in two host waves took, so a program the exchange form also translated took that one: two host waves meeting at two group barriers for each first-lane read, mask and sum. CS_Primary_RegisterAllocationRequests (33 group barriers in 681 host instructions) took 3.7 ms of the card per dispatch in the opening cutscene, 2.8 ms a frame, the most of any wave64 program; its irradiance-cache twin 0.5 ms a frame. Where the exchange form translates a program, the local form is now tried and kept if it translates (split::local_if_exact). The idiom check also took every guarded write as mixing the register's old value (a wave count, say) into the lanes outside its EXEC, read or not: the light-probe allocations reuse the register that held the count for the first lane's lane number. Such a write now keeps its kind where no reader can see those lanes (split::read_inside_only): followed through the guarded writes that keep it and the joins that take it, every reader of its own lane reads under a guard that lies, where it stands, inside the guards written since the old value; a reader of other lanes and a loop's join count as seeing them, a whole-wave section's select by its mask, a first-lane read by its own guard (the idiom's shortcut for first-lane reads). Offline (CPU census of every program, the same build with the switch off): 40 of the 160 exchange-form programs take the local form (both allocation requests, the depth-of-field and trail-map tile classifications, the depth pyramids, shadow-mask denoises, ray-bin offsets, the screen-space ray pre-passes, water patch culling, among them), and 5 of the 70 paired programs (the four temporal resolves that count frame statistics, and lens_flares CS_ScanMip0, the idiom with a multiply-add as its three siblings); no other program changes. Their host instructions: the 5 paired ones 48,501 -> 19,039. VICTORY_WAVE_SPLIT=0 turns both off. Diagnostics builds: VICTORY_WAVE_PAIRED_OVER_EXCHANGE=1 gives the remaining exchange-form programs the paired form, to time the two in a run. Test: an allocation that reuses its count register as the light-probe requests do takes the local form; on the card its counter and records against the console's (the paired form's also in the console's order).
…ps only its system values The 71 mesh programs whose outputs pass D3D12's 32 KiB as translated alone (128 vertices of 65 to 71 components) were linked with the pixel program of their pipeline (link_mesh), but a pipeline without one, as the title makes for depth (14,576 binds of 143 mesh programs alone in the runs so far), got the invalid translation as it is. link_mesh_alone translates such a program again without its outputs of arbitrary semantics, which only a pixel program reads: position, clip and cull distances stay, and it fits. The runtime makes those pipelines with it; the offline census, whose stub pixel program reads nothing, checks that form of the 71 (all 71 validate and get a pipeline, RTX 5090) and counts them on its mesh line. None of the 71 was drawn alone in the runs so far: the two drawn (72da0ba1efaec1e0, 8a621a22094767f3) came with pixel programs and linked.
The census's 195 geometry programs (all GS_VoxelizeGeneric variants) stopped at resource tracking: their first load reads the console driver's table that user data 0 and 1 point at. The console runs such a program in one hardware stage after the ES half of its vertex program: it reads its triangle's vertices from LDS at the offsets v0 and v1 hold (16 bits each), writes the vertices it emits to its lane's slot of the GS-VS ring, also in LDS, and sends a GS message for each emit and cut. The stage data gives the ring's layout (vertex count and dwords per vertex, four per register of the output signature; StageIo::Gs). The host runs the ES half as the vertex program it is (the container's VS program, the other compilation of the same HLSL) and the program as a geometry shader of one invocation per primitive (crate::geometry, emit/rings.rs): the address of each LDS access is followed to the input vertex and dword it reads, or the emitted vertex and dword it writes; a ring read is that input's loadInput, a ring write is kept as that vertex's output, and the n-th emit stores vertex n's outputs and emits it. The load from the driver's table only places the ring (resource::DRIVER: its value is never needed). The prologue that narrows EXEC to the wave's GS threads keeps every lane (NativeProgram::patched_code). The primitive id (v2) is the host's; an invocation id (v3, instancing), vertices 4 and 5 (adjacency), another stream or emits in branches are refused. Offline (32-lane host) all 195 translate and validate (the census's new geometry line), the DXIL of every other program unchanged; their pipelines between a stub vertex and pixel shader build on the WARP device (the card's are left to the general test session). Tests: the rings of a program of the console's form written for them, the refusals, the prologue, the primitive id, and that program drawn between a pass-through vertex and pixel shader (every texel as it writes it; passed on WARP). No run so far drew with a geometry stage.
A pipeline whose stream has a geometry shader was refused ("only vertex,
mesh, pixel and compute stages are translated") and its draws dropped. Its
geometry program now translates (the commit before): the host pipeline is
the vertex program, the pixel program and the geometry program between
them, its user data and views bound per stage as the others' (stage last,
so the pixel stage keeps its place; no rectangle stage beside it, and none
in a mesh pipeline). Its library entry has a name of its own. The translated
geometry stage brings its used-resource entries like the other stages.
shortcut: not run in the title yet: none of the runs so far (opening
cutscene, gameplay from the user's save) drew with a geometry stage.
… that allocate, dispatches past 65,535 groups Four lines in the summary: the 195 geometry programs run as host geometry shaders (no run has drawn with one), oversized mesh programs drawn without a pixel program keep their system values, and the CPU census (25,948 of 25,953 translate and validate; the rest: five ray-trace programs); the loop fixes; the two wave64 forms; the split of dispatches past 65,535 groups in x. VICTORY_WAVE_SPLIT and VICTORY_WAVE_RAW in the table of switches, VICTORY_MESH_LINK's alone form, and geometry stages out of what the shaders lack.
ExoCalibra
added a commit
to ExoCalibra/victory-exo
that referenced
this pull request
Nov 25, 2026
# Conflicts: # crates/victory-gpu/src/draw.rs # crates/victory-gpu/src/indirect.rs
RENOxDECEPTION
added a commit
to RENOxDECEPTION/victory-fork
that referenced
this pull request
Nov 25, 2026
…e64 paired forms, mesh over 32 KiB, geometry shaders, ray-tracing builder runs
…ate sessions, frame capture, texture copy-back and wide loads; no conflict No conflict. Upstream's loads of four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default) merge into emit/lower.rs, emit/mod.rs and emit/bitcode/opt.rs beside this branch's forms; lower.rs is 504,469 bytes of the policy's 524,288. The rest of upstream's commits is in files this branch does not change, but for README.md (additions side by side) and three lint lines in draw.rs, indirect.rs and resource.rs.
…rt, an if joined to its let, counts tested with is_multiple_of) `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on 085ee7c with the pinned toolchain (1.98.1), after the two fixes before this one too: map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and with --all-features in draw.rs and watch.rs (twice). No change of behaviour.
…thered indirect records, frame capture, card-memory windows, texture copy-back and wide loads; no conflict No conflict. Read through where both sides changed the same code: - indirect.rs: the clamp's source now has upstream's gathered records (bit 2 of has_count: a record's place read from a table) and this branch's split dispatch (kind 3). Only a windowed draw's record is gathered, never a dispatch's, so the two do not meet. - draw.rs: execute_indirect ends the list's gathering for a dispatch before the split clamp, and a direct dispatch split past 65,535 groups ends it on entry. - emit/lower.rs, emit/mod.rs, emit/bitcode/opt.rs: upstream's loads of four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default) beside this branch's forms; lower.rs is 511,375 bytes of the policy's 524,288. - host.rs, shadow.rs, lib.rs, README.md: additions side by side.
…rt, an if joined to its let, counts tested with is_multiple_of) `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on 085ee7c with the pinned toolchain (1.98.1), after the two fixes before this one too: map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and with --all-features in draw.rs and watch.rs (twice). No change of behaviour.
Author
|
Merged Merged without a conflict, and read through where both sides changed the same code:
Added after the merge: one lint commit for Checked, the branch as it is (
|
…e card takes The test lowered the program for 64-lane waves only and returned when the device refused the pipeline, so on a GPU of 32-lane waves it passed with nothing run on the card (review of fxceless#854). It now asks the device how wide its waves are (D3D12_OPTIONS1) before choosing the form: the console's own 64 lanes where they fit, the paired form on waves of 32, nothing on narrower waves (the software adapter's 4). The pipeline and the dispatch are then made on that same device, and a refusal fails the test. On an RTX 5090 (32-lane waves) the paired form gives the console's tree bit for bit with 64, 63, 40, 33, 32, 17, 5 and 1 lanes left.
…uns on the card in the form the card takes
PiloteCode
added a commit
to PiloteCode/victory-fork
that referenced
this pull request
Nov 25, 2026
PiloteCode
pushed a commit
to PiloteCode/victory-fork
that referenced
this pull request
Nov 25, 2026
…le-tables Formats: share immutable texture swizzle tables
ExoCalibra
added a commit
to ExoCalibra/victory-exo
that referenced
this pull request
Nov 26, 2026
# Conflicts: # crates/victory-gpu/src/draw.rs # crates/victory-gpu/src/fpsbox.rs # crates/victory-gpu/src/pipeline/library.rs # crates/victory-shader/src/emit/lower.rs # crates/victory-shader/src/emit/mod.rs
ExoCalibra
added a commit
to ExoCalibra/victory-exo
that referenced
this pull request
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #854. The branch is #854's head (
0751197e) withmain(0b0074e0) merged in, which had no conflict. The 25 commits after that merge are this PR's. Once #854 is in, only they remain. The first one is the clippy fix formainthat our other open PRs also start with (shadow.rs,manual_is_multiple_of).Offline census over the title's whole shader pack (
victory translate --validate --list,VICTORY_HOST_MAX_WAVE=32, CPU only: translation and DXIL validation, no pipelines, as the card was reserved): 25,948 of 25,953 programs translate and validate, against 25,682 with #854 alone.The 71 mesh programs pass in the form they take when drawn without a pixel program (below); #854 links them with their pixel program for the pipelines that have one. The five left are shadow-mask trace programs (a descriptor read only as data). Our ray-tracing PR, stacked on this one, makes four of them translate.
What changes
Geometry programs translate as geometry shaders (
geometry.rs,emit/rings.rs,native.rs,pipeline/host.rs)The title's 195 geometry programs (all
GS_VoxelizeGenericvariants) stopped at resource tracking: their first load reads the console driver's table that user data 0 and 1 point at.How the console runs such a program: in one hardware stage, after the ES half of its vertex program. It reads its triangle's vertices from LDS at the offsets in v0 and v1 (16 bits each), writes the vertices it emits to its lane's slot of the GS-VS ring (also in LDS), and sends a GS message for each emit and cut. The stage data gives the ring's layout (
StageIo::Gs).How the host runs it now:
crate::geometry,emit/rings.rs). The address of each LDS access is followed to the input vertex and dword it reads, or to the emitted vertex and dword it writes:loadInput;resource::DRIVER).NativeProgram::patched_code).A title pipeline with a geometry stage was refused before ("only vertex, mesh, pixel and compute stages are translated"). It now gets a host pipeline: the vertex program, the geometry program and the pixel program, each stage's user data and views bound as the others are. The geometry stage comes last, so the pixel stage keeps its place.
Offline, all 195 translate and validate, and the DXIL of every other program is unchanged by this commit. Their pipelines, between a stub vertex and pixel shader, build on WARP. No run so far drew with a geometry stage.
A mesh program over 32 KiB drawn without a pixel program keeps only its system values (
emit/link.rs,pipeline/host.rs)#854 links each of the 71 oversized mesh programs with the pixel program of its pipeline. A pipeline without a pixel program, as the title makes for depth, still got the invalid translation: the runs so far bound 143 mesh programs alone 14,576 times.
link_mesh_alonetranslates such a program again without its outputs of arbitrary semantics, which only a pixel program reads. Position, clip and cull distances stay, and it fits. The runtime makes those pipelines with it. The census checks that form of the 71, since its stub pixel program reads nothing: all 71 validate and get a pipeline (RTX 5090).VICTORY_MESH_LINK=0turns this form off too.Loops (
emit/loops.rs,emit/regions.rs,emit/trip.rs,lower.rs)A helper lane of a pixel program is its own first lane. The console runs a pixel program's helper lanes as lanes of EXEC (the program starts with
s_wqm), so a waterfall loop over descriptors serves a helper lane in a pass of its own. The host's wave operations leave helper lanes out (SM 6.6) and give them undefined results. A helper lane whose value no other lane held never met it as the first lane. It went round the translated loop to the iteration limit, sampling each pass, and left with nothing computed, which its quad's derivatives then read. The character skin and cloth program (94d281151ca58b4f) samples its material layers in nine such nested loops.VICTORY_HELPER_OWN=0turns it off, for an A/B on screen.A loop whose code fixes its count runs to its end, whatever the limit. The limit is for loops whose end the data decides. A loop has a fixed count when its exit is a scalar counter that:
Such a loop now runs as often as the console's, up to 65,536 passes. The environment BRDF integration tables (
PS_IntegrateEnvBRDFand its Beckmann and thin-film variants) integrate 1,024 samples a texel in six loops of 256 or 512 passes. At the pixel limit of 128, every one of the 65,536 texels of each table stopped at a half or a quarter of its samples (loop notes, opening cutscene). Every specular reflection reads those tables.A loop each lane leaves on its own is not code every lane runs. Where two host waves run one console wave of 64 lanes, they exchange first lanes, masks and LDS order through group barriers, and only in blocks every lane runs. A waterfall loop in one block was taken for such code and got two host waves' exchange: four group barriers a pass, which lanes that had left met at other barriers.
1f1fbd86759b3da2), lanes then never met their descriptor and ran to the compute limit of 4,096 passes, losing their loads.A loop closed by a jump leaves at its exit at the limit. Such a loop has its exit test elsewhere in its body. At the limit, its jump back could only end the lane: a pixel discarded, a mesh or compute lane stopped before its writes. Its exit tests now take the limit too, so a lane at the limit leaves there and goes on with the program. A lane whose way round passes no exit test still ends.
A vertex or mesh program with a root UAV declares UAVs at every stage (ShaderFlags bit 16). With loop notes on, the validator refused 62 of 801 such programs of a run.
Diagnostics.
VICTORY_SHADER_LOOP_LIMITtakes one number, orstage:npairs.VICTORY_LOOP_NOTES=1: each lane that reaches a loop's limit adds one to that loop's record in a root UAV of ours, and the log names the loops whose counts grew, every five seconds (crate::loop_notes).The limits themselves stay. With them raised to 1,024 / 4,096 / 65,536, the notes named loops that never end, for example a cascade search that reads its count as 0, and a decal resolve's walk.
Wave64 programs on 32-lane GPUs (
emit/split.rs,emit/guarded.rs,emit/forms.rs)VICTORY_WAVE_SPLIT=0turns it off). Some console wave64 programs use their wave-wide values only as the allocation idiom uses them: each wave's first lane reserves its count on a shared counter, and every lane takes the base plus its rank. Such a program is exact with each host wave on its own: the same records, reserved by each half in another order. Before, a program that the exchange form also translated took that form: two host waves meeting at two group barriers for each first-lane read, mask and sum.CS_Primary_RegisterAllocationRequests(33 group barriers in 681 host instructions) took 3.7 ms of card time per dispatch in the opening cutscene, 2.8 ms a frame: the most of any wave64 program.split::read_inside_only).VICTORY_WAVE_RAW=0turns it off). In the paired form every per-lane branch is the wave's, so a guarded write isselect(guard, new, old). That was about a sixth of the paired programs' host code, each select keeping the register's old value alive. A lane that reads the register under a guard that implies the writer's guard reads the computed value. This holds only for its own registers: a DPP source, lane read or write, swizzle or permute reads other lanes. Offline, only the 69 paired programs change: host instructions 2,303,768 -> 1,617,871 (-30 %), guard selects 360,668 -> 124,509.form=withVICTORY_SHADER_CENSUS).Dispatches of more than 65,535 groups in x run whole (
lower.rs,shader.rs,draw.rs,indirect.rs)One host dispatch runs at most 65,535 groups in a dimension; the console runs more. The screen-probe final gather of the indirect diffuse light asks for up to 2 x 57,600 = 115,200 groups in x: one group per 8x8 tile of each of its two layers at 2560x1440. The clamp of indirect records cut such a record to 65,535, so the tiles past that point never ran. This showed as blocks along the bottom of the picture, and on a head lit by the window as a washed-out orange light with a vertical seam.
USER_GROUP_BASE(RootType::Other(0x104)). Programs with a spilled user-data table do not ask for it: their root signatures are close to the host's 64 dwords.indirect::SPLIT_DISPATCH):In our tree, in the save's gameplay (the cell window, the same static view): before, about 0.8 records a frame were cut, blue and white blocks lined the bottom edge, and the hair took the washed-out light. After, 166 frame lines asked for more than 65,535 groups, none was cut, the bottom edge was clean and the hair was lit as the rest of the room. That tree clamped into a ring of the list's (not in
main). Here the split is written ontomain's clamp program and scratch buffer: the same records and signature, tested on WARP.Switches
VICTORY_WAVE_SPLIT=0: allocation-only wave64 programs take the forms they took beforeVICTORY_WAVE_RAW=0: the paired form selects every guarded write, as beforeVICTORY_HELPER_OWN=0: helper lanes read the host wave's first lane, as beforeVICTORY_MESH_LINK=0now also turns off the system-values-only form of oversized mesh programs drawn aloneVICTORY_SHADER_LOOP_LIMITpixel:<n>,vertex:<n>,compute:<n>,trace:<n>VICTORY_LOOP_NOTES=1Every
VICTORY_*switch the translator reads is part of the shader cache key.Tested
The branch was checked as it is (its head merged with
mainalready). The card was reserved for other work, so the tests ran on the software adapter:cargo test -p victory-shader -- --test-threads=1withVICTORY_WARP=1: 259 passed, 5 failed, 2 ignored. The same five fail on Shaders: wave64 programs in a paired form on 32-lane GPUs, mesh programs over 32 KiB linked with their pixel program, and more (230 more programs pass) #854's head merged withmain(237 passed, 5 failed), all on the software adapter (WARP refuses the pipelines of the first four, E_INVALIDARG, and reads another lane count in the fifth):ds_min_max_f32_order_floats_and_return_the_old_value,lds_subtractions_get_a_pipeline_and_stay_atomic,v_permlane16_and_x16_read_the_lanes_their_selectors_pick,whole_wave_f64_sum_and_cvt_f32_f64anda_lane_mask_joined_with_a_number_is_read_as_the_number_it_is. Tests that need the card's 32-lane waves run on WARP here; they passed on the RTX 5090 when they went in.cargo test -p victory-gpu --features diagnostics -- --test-threads=1withVICTORY_D3D12_WARP=1: 186 passed, 1 failed, 6 ignored. The failure,depth_bounds_pipeline_loads_and_filters_draws, fails the same way on Shaders: wave64 programs in a paired form on 32-lane GPUs, mesh programs over 32 KiB linked with their pixel program, and more (230 more programs pass) #854's head merged withmain(185 passed): WARP does not reject the pixels outside the depth bounds.cargo test -p victory: 1 passed.cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features: clean.cargo build --release -p victory,cargo build --profile diag -p victory --features diagnosticsandcargo xtask policypass.New tests:
Earlier, all of these changes ran in our tree on the RTX 5090, with our layer work: its general test (an opening cutscene run and gameplay runs from a save) had no device loss, no refused pipeline and no exception.
Overlaps with open pull requests
USER_GROUP_BASE,RootType::Other(0x104)), to the group id in x. Here one execution of split records runs up to 262,140 groups, and direct dispatches are split too. The translator parts are nearly the same; whichever goes in second keeps one.RootType::Other(0x104), for another word (USER_DISPATCH_THREADS). With both, one of the two needs another code. Our ray-tracing PR (stacked on this one) does thread counts with0x105.IsHelperLane, and adds quad reads. Here a helper lane reads its own value in a pixel program's first-lane reads.Not tested