Repository navigation
Ray tracing: the title's structure builder runs without crashing it (dispatches by thread counts, title memory by address made ready); node tests answer no hit while it is off (stacked on #854 and #993) - #994
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.
Five of the title's sun-shadow trace programs (shadowmask:CS_TraceShadowRays at full, half, quarter and eighth resolution) take the address of their ray-tracing structure out of a buffer descriptor they pick from the view heap at an index they compute, and walk the structure from it: they stopped at "a descriptor read only as data". The host now keeps, per view heap, a table of each slot's view address (buffer views, and ray-tracing structure views) beside the table of strides, and such a load reads it (root SRV t252 in space 1). Offline (`victory translate`, VICTORY_HOST_MAX_WAVE=32, the game's shader archive): compute programs 2677 -> 2681 of 2682 emitted, nothing else changed; the four validate and get pipelines. The fifth (FullAdaptive) now stops further on, at a lane mask read as data. In the user-save scenario the title uses the checkerboard variant, which translated before.
… indirect records, frame capture, card-memory windows, texture copy-back and wide loads; conflicts in draw.rs, host.rs and lib.rs Conflicts, each a place where both sides added lines; both sides are kept: - crates/victory-gpu/src/draw.rs: a method each after State::list_dropped_roots (trace_dispatch here, may_store upstream). - crates/victory-gpu/src/host.rs, twice: a diagnostics statement each under one attribute line, in run_deferred's title copy and at the top of write_mapped (the builder's trace line here; upstream's count of who reads what the copy-back stored, backreads). Each has the attribute now; upstream's statement stays next to the copy or the write it marks. - crates/victory-gpu/src/lib.rs: a diagnostics module each under one attribute line (bvhtrace here, backreads upstream). Merged without a conflict, and 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 dispatch by thread counts goes through dispatch, which ends it too. A title copy run on the card (HostList::copy_on_card) follows a draw or dispatch of its list that stores by address, so the list no longer gathers by then. - 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 519,626 bytes of the policy's 524,288. - queue.rs, shadow.rs, resource.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.
…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.
|
AI-assisted (Claude Code). Numbers and log lines only, no game data. RTX 4090 with this stack and the builder on: no crash, no device loss, 4.5 fps in the barracks, and the picture is clean. Setup. RTX 4090 (32-lane waves), driver 621.40, i9-14900K, 64 GB, Windows 11, Series X profile, diagnostics build. Tree: fork Stability. Six launches today on this tree, 3 to 10 minutes each (four of them cold-cache starts). Every one had 0 first-chance exceptions and no device removal. Each launch logged Frame time in the barracks, once loading settled:
Windows outside buffers compared on the CPU came to 544-600 MB a frame, in 136-150 ranges. Before #346 or this PR's raw-store rule it was 16.1 GB in 4,028 ranges, at 0.3 fps. What changed in the picture against the tree without #854/#993. Same save, same spots:
The indirect diffuse chain runs whole. The run bound 81 programs of
In two A pitfall for anyone judging pictures by screenshot. A plain desktop capture (GDI |
|
Merged Conflicts. Four places in three files, each one where both sides had added lines. Both sides are kept in all of them:
Merged without a conflict, and read through where both sides changed the same code:
Not run together: this branch with
Added after the merge: one lint commit for Checked, the branch as it is (
|
BradRoland
left a comment
There was a problem hiding this comment.
I checked the builder-off path on the updated head and found one title-memory access that still runs on a disabled traversal. The returned no-hit values themselves were correct.
| // node is 64 bytes on 64, so its first half lies in one | ||
| // 64 KiB page whatever its kind. | ||
| let (handle, byte) = self.bvh_memory(low, high, guard); | ||
| let (handle, byte) = self.bvh_memory(low, high, reads); |
There was a problem hiding this comment.
The first directory lookup is emitted before branching on built. Passing a false reads predicate sends the fault-buffer store to the sink at word 0. With USER_STRUCTURES=0 on 1ffff57, a synthetic WARP dispatch of 32 lanes targeting missing page 11 changed that word from 0xabcdef01 to 11. The page-request slot stayed zero and the box returned four misses. The extra UAV write is measurable independently of any effect on frame time.
I moved the directory lookup into the existing enabled block. The test keeps the entire fault buffer intact with traversal disabled, then enables traversal and checks that page 11 is requested. It passed on WARP and the RTX 4080. Correction and regression based on this head
For testing this alongside #1165, I also adapted the missing-page fix to this branch. All nine intersection tests passed on the combined tree, including disabled traversal, fully missing boxes and boxes split across pages. Gameplay remains unverified here. Combined branch
…records are named (builder only) From fxceless's ray-tracing branch (fxceless#994: 2d95091, 273fc65), by hand onto the fork's marks design. With VICTORY_BVH_BUILDER set, list upload memory comes from chunks shaders reach by address (9afd8c2, the commit before), each chunk is given its copy, and the 8-byte title addresses in the block a dispatch's root SRVs point into (16 KiB at most, up to what the list handed out) are named before the dispatch: the builder's leaf rehydration takes index and vertex buffers out of 48-byte records there, and the ones in no copy read zeros (leaves without triangles; the builder-on run at 75a4fe7 had no walls). Without the builder asked for nothing is carved or scanned. The low dword of a constant pair is no longer also named in 256-byte units: most windows named that way were such low dwords. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017V7WBCi8h4eymnRhdth77t
…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
|
@BradRoland thanks, that is a real defect and your fix is the right one. With the structures off, the first look in the directory was still emitted, with a false predicate, before the branch on Your commit
The missing-page fix you adapted from #1165 is not taken here: it belongs with #1165, and this PR stays what it was plus your correction. |
|
@deadkid14 thanks for the report and for what you ruled out. A read of Two runs would tell:
If it is the first, a stub pixel shader for those pipelines under Proton would be the way round it (the offline census already builds them that way); say so and we will add it behind a switch. |
|
@Zayfway @Exopus-0x65f7ad0 @Yorivel thanks for the three reports.
|
…=1, off by default); VICTORY_WAVE_WIDE=last (fork PR #1141) The structure builder does not run unless asked for, and the title's ray-traced passes run all the same: every node test then reads whatever bytes lie where a structure would be, in a walk bounded at 65,535 steps a wave. With VICTORY_BVH_NO_HIT=1 (and not VICTORY_BVH_BUILDER=1) a box node enters no child and any other node is missed: every ray leaves at its first test, the answer is the same in every run, and the program asks the host for neither the directory of title memory nor the list of missing pages (unit test). The idea is fork PR #994's, done here at translation instead of by a host word. Also fork PR #1141 as it is (VICTORY_WAVE_WIDE=last: the barrier form only for programs every other form leaves at 64 lanes; opt-in), and the comment on the wide loads corrected (not the same result on the card: run 277). A TRANSLATOR EDIT: an exe from here on has a new shader fingerprint; wipe the DXIL cache and the pipeline library before its first launch. Not run in a game. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@PiloteCode thanks. Results of the two checks you asked for, same tree as my report (main
The program: I added a log line before each library load and make, with the thread, and compared what was in flight at three crashes. Each time, the crash follows the start of the make of
The same program builds fine in the same tree without #993/#994 ( Something else turned up while looking, in both builds: four compute pipelines start and never finish on this stack ( I can run a build that leaves AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request. |
|
AI-assisted (Claude Code). Numbers and log lines only, no game data. RTX 5070 12 GB, 32 GB RAM, builder on, no quarantine: no crash, no device loss, 6 min 17 s with the builder, and the picture looked right to the player. On Setup. RTX 5070 12 GB (32-lane waves, driver 610.88; an RTX 3060 in the same PC, the game on the 5070 by Windows' per-app GPU preference), Core Ultra 7 270K Plus, 32 GB with a 32 GB paging file, Windows 11 26300, Series X profile, release build (no diagnostics). Tree: fork Merging. Since the last merge of
The run. 10 min 51 s; the builder came up at 3 min 30 s ("all of its programs have host pipelines", 53). From then on:
For comparison, without this PR. On 32 GB the builder fits for these six minutes; with shared memory still growing at the end, a longer run would tell whether it stops. |
|
Follow-up on Linux with this PR's current head ( The result is the same crash as before, so This was at frame 1268. A cached form of the same program had bound earlier at that frame, and the crash comes right after this new translation of it. No Xid and no device loss. So on Windows the driver takes this pipeline, and under Wine vkd3d-proton fails on it with a null read. I haven't tried a newer vkd3d-proton than GE-Proton11-14's. If someone on Linux has one built from master, this program would be the one to check. AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request. |
Stacked on #993 (the second translator PR), which is itself stacked on #854. This PR's commits are the 21 after
README: geometry stages, loops as the console runs them, .... It needs that PR in two places:Where the builder stands
Until now, the title died about a frame after the structure builder's first frame, on pointers of all ones read from its own objects. The cause was the layer's: it took the builder's dispatches by thread counts for group counts (below).
With the fix, in runs of our tree on an RTX 5090:
VICTORY_BVH_BUILDER=1, its trace on): no fault and no card loss. Every stage ran, none was dropped (Dec 2,516, Leaf 2,516, Box32 7,446, Box16 14,719, ReloadTriangles and Refit 26,144 each, Construct 5,618, LoadInstances 2,032 dispatches), about 200 builder dispatches a frame once the world was up. In the window scene, the hair's light is steady with the builder on. With it off, it changed from run to run: dark in two runs, lit in one, because the passes walked whatever lay in memory.This PR keeps the builder opt-in, as on
main(VICTORY_BVH_BUILDER=1), for its cost:Whether the traced passes light as the console's do is still to be compared picture by picture.
What changes
Dispatches by thread counts run only those threads (
list.rs,draw.rs,pipeline.rs,shader_cache.rs,emit/lower.rs)DispatchX(x, y, z, flags)passes the console's dispatch initiator bits as its flags. The builder setsUSE_THREAD_DIMENSIONS(0x20; 0x8020 for its wave32 programs) on its header copies (DecompressHeader), its box rehydration of pre-built structures (Box32Rehydration, Box16Rehydration) and its triangle reloads (ReloadTriangles, ReloadProcedurals). There, x, y and z count threads: the last group is cut short, and no thread past the count is launched. The layer ran them as group counts.The box stages rebuild one level of a tree a dispatch, in place, one node a thread: group g writes its 64 nodes at g x 8 KiB (4 KiB for 16-bit boxes), and a lane count read off EXEC (
WaveAllBitCount) places each node's payload. In the first frame of a crashing run they ran 272,948 and 47,026 groups where 5,983 and 4,217 were wanted, and wrote 2.2 GiB of empty nodes past their levels. Where that was put back, it lay over the title's own objects, which share those pages at a CPU view 24 GiB lower. Every crash site of that run lies inside such an overrun.dispatch_xnow makes groups of the program's console size out of the counts. Where a last group is cut short:victory_shader::emit::translate_thread_limited), made at its first such dispatch and cached under a key of its own.USER_THREAD_LIMIT,RootType::Other(0x105)), only along a dimension whose groups are more than one thread wide.The plain translation is untouched: only dispatches by thread counts whose last group is cut short use the second form.
Title memory by address made ready for the builder (
list.rs,memory.rs,host.rs,queue.rs,pipeline.rs,draw.rs)List upload memory where shaders reach it. The builder hands its stages the addresses of tables it writes into list upload memory (
allocate_upload); its header stage reads its records through them. The layer gave out blocks of the process heap at 1.5-1.8 TiB, beyond the console's 40 bits and the directory of title memory by address (below 128 GiB): the records read as zeros and no structure header was written. Upload memory now comes from 4 MiB chunks of one 512 MiB write-watched reservation between 4 GiB and 128 GiB. Each chunk is a window of memory outside buffers, copied when a list that names it is submitted. Larger requests still come from the heap.The addresses in the records of upload memory are named. The leaf rehydration reads 48-byte
D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESCrecords through a root SRV in upload memory, and loads vertices and indices through the addresses in them, which no root argument names. In one run, 638 of the 2,139 such addresses lay in no copy when the stage ran, and those leaves read zeros. Before such a dispatch, the block of upload memory each root SRV points into is looked through (16 KiB at most) for 8-byte title addresses, which are named like the dispatch's own.Copies by address declared written only for address stores. A program that reaches title memory by address declared every numbered copy written as soon as it could store anywhere. Only a program that can store through a raw address now does (a flat or global store or atomic, not to scratch, or code not all known). Of the builder's 52 programs, 11 store that way.
Copies kept current where named. Each list that ran such a program refreshed all 1,023 numbered windows (4 GiB) and, if it could store, declared them all written. With the builder's dispatches bound and not run, that alone made a median of 975 ms a frame, against 353 without the builder. Now:
VICTORY_MEMORY_ALL=1restores the old way.The structures' sizes are copied on the card. The title copies each structure's compacted size out of the builder's buffer with
CopyBufferRegion, in the list that computed it. Done on the CPU at submission, the copy took what the buffer held before the list's shaders ran. In a list whose shaders store by address, a copy whose source those shaders declared written now runs on the card behind them, and its destination is declared written. Other title copies stay on the CPU.VICTORY_CARD_TITLE_COPIES=0turns this off.Remaps after the flights.
CopyPageMappingsBatchXmaps pool pages at once, while the console does it behind the work sent before. A remap now first waits for the flights in the air whose declared writes touch its range, so their writes are not put back into pages mapped there since.VICTORY_REMAP_LAND=0turns this off.View addresses read from the view heap by slot (
descriptor/host.rs,draw.rs,emit/lower.rs)Four sun-shadow trace programs (
shadowmask:CS_TraceShadowRaysat full, half, quarter and eighth resolution) take their structure's address out of a buffer descriptor they pick from the view heap at a computed index. They stopped at "a descriptor read only as data". The host keeps, per view heap, a table of each slot's view address (SLOT_VIEW_ADDRESSES, a root SRV beside the strides), and such a load reads it. The fifth (FullAdaptive) now stops further on, at a lane mask read as data.Node tests answer no hit while the builder does not run (
emit/intersect.rs,pipeline.rs,draw.rs)The title's ray-traced passes run whether or not anything built their structures. With the builder off, they walked whatever bytes lay where the structures would be: screen-aligned dark tiles on sunlit hair, lit squares in shadow, and hair dark in some runs and lit in others.
A program with a node test now reads a host word (
USER_STRUCTURES,RootType::Other(0x106)): 1 while the builder runs whole, 0 before its first dispatch, withoutVICTORY_BVH_BUILDER=1, or once it is turned off. While it is 0, every node test answers no hit without reading the node: rays escape, and shadow rays find no occluder.VICTORY_BVH_NO_HIT=0lets them walk memory, as before.Diagnostics (diagnostics builds)
VICTORY_BVH_TRACE=<file>, written unbuffered so that a crashing run keeps it. One line per:VICTORY_BVH_DRY=1binds the builder's dispatches without running them.VICTORY_BVH_CHECK=<hash>[,<hash>]walks the structures that the header stage, and the in-place rebuild's header stage, start, once their headers are put back. It reports bad nodes: bounds not finite, inverted or outside the parent's, nodes outside the structure or reached twice.VICTORY_CRASH_MEMORY=1adds to a crash report the title memory around each register that holds a title address, and one pointer further.Switches
VICTORY_BVH_BUILDERmain=1runs the builderVICTORY_BVH_NO_HIT=0: node tests walk memory while the builder does not run, as beforeVICTORY_MEMORY_ALL=1: every numbered copy refreshed and declared written, as beforeVICTORY_CARD_TITLE_COPIES=0: the title's buffer copies all on the CPU, as beforeVICTORY_REMAP_LAND=0: remaps do not wait for flightsVICTORY_BVH_TRACE,VICTORY_BVH_DRY,VICTORY_BVH_CHECK,VICTORY_CRASH_MEMORYTested
The branch was checked as it is. 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: 264 passed, 5 failed, 2 ignored. The five are the ones that 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 withmainon the software adapter (see 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). The tests that need the title's builder DLL skip.cargo test -p victory-gpu --features diagnostics -- --test-threads=1withVICTORY_D3D12_WARP=1: 188 passed, 1 failed, 6 ignored. The failure isdepth_bounds_pipeline_loads_and_filters_draws, as 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: WARP does not reject the pixels outside the depth bounds.cargo test -p victoryandcargo test -p victory-loader: 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 policy: pass.Offline census over the title's whole shader pack, as for #993 (
victory translate --validate --list,VICTORY_HOST_MAX_WAVE=32, CPU only: no pipelines): 25,952 of 25,953 programs translate and validate, against #993's 25,948. The four sun-shadow trace programs are the difference (compute 2,733 of 2,734). The one left is the FullAdaptive shadow-mask trace (a lane mask read as data). All 52 builder programs validate.New tests:
VICTORY_TEST_BVH_DLLpointing at the title'sXboxBvhBuilder.dll(skipped when unset), the builder's wave64 programs run in their picked and paired forms on the same inputs, and agree. With the same switch, 49 of the 52 programs translate for thread counts and validate; the three paired prefix sums are refused.The shader tests now keep one device per adapter for the whole test process. Two card test sessions had died in the driver (an access violation in
nvwgf2umx.dllon a driver thread, reading freed memory) after a test made and dropped its device.Overlaps with open pull requests
GPU and shaders: handle DispatchX USE_THREAD_DIMENSIONS partial thread groups (#16) #646 handles
USE_THREAD_DIMENSIONStoo: groups bydiv_ceil, and a user-data word (USER_DISPATCH_THREADS,RootType::Other(0x104), 0 for no cap) read by the prologue of every spilled compute program. On wave64-on-wave32 hosts and in programs with barriers, GPU and shaders: handle DispatchX USE_THREAD_DIMENSIONS partial thread groups (#16) #646 keeps every thread alive and predicates memory accesses, ballots and reductions. Here:GPU and shaders: handle DispatchX USE_THREAD_DIMENSIONS partial thread groups (#16) #646 uses
0x104, which 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 and GPU: indirect dispatches past 65,535 groups in x run the rest in a second execution #834 use for the group base: one of them needs another code.GPU: only a shader that can store by address declares its title-memory copies written (12 GB/frame of CPU compare with ray tracing) #916 is the same change as "copies by address declared written only for address stores" (
stores_by_addressinpipeline.rs).Builder quarantine that holds; tracing where the builder's results land #935 adds a
crates/victory-gpu/src/bvhtrace.rsof its own under the sameVICTORY_BVH_TRACEswitch, crash-report memory dumps, and a quarantine that holds. Its runs crashed 3 to 12 s after the builder's first frame. The overrun of the dispatches by thread counts, fixed here, explains such crashes. Whichever goes in second needs a merge ofbvhtrace.rsandcrash.rs.shader,gpu: resolve heap-loaded view addresses and widen native complement masks #738 and Shaders: view-address table for descriptors picked by a computed index #749 keep a table of view addresses by heap slot as well. shader,gpu: resolve heap-loaded view addresses and widen native complement masks #738 uses the same slot (
SLOT_VIEW_ADDRESSES, 252) and also widens complement masks, which makes the fifth shadow-mask program translate. Shaders: view-address table for descriptors picked by a computed index #749 keeps addresses, lengths and strides.Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814 and Live ray tracing (#814) on current main, conflicts resolved; tested on an RTX 3080 #905 (live ray tracing) carry view addresses, a thread-count word and title-memory write-back changes of their own.
NVIDIA (32-lane waves): four refused compute programs run, the whole structure builder has pipelines, xmem maps page runs as one view #823 and Ray-tracing builder translates on 32-lane GPUs; textures spill to shared memory; findings on a 6 GB laptop #601 give the whole builder pipelines on 32-lane GPUs in other ways (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 does it with the paired form). GPU: VICTORY_BVH_SKIP drops chosen structure-builder pipelines (diagnostics) #579 drops chosen builder pipelines (diagnostics). Shaders: guard title-memory fault writes and skip second BVH directory lookup on non-straddling box32 nodes #607 saves the second directory lookup of a 128-byte box node.
GPU: constant buffer views at most 64 KiB (NVIDIA removed the device for a larger one) #911 caps constant buffer views at 64 KiB. With the builder on,
mainneeds it (or an equivalent cap): without it a 1.3 MB view removed the device on an RTX 4070 about 36 s after the builder's pipelines were ready, and with it the same run went on (tested by rafaconvaitis below). Our tree has the cap.Not tested