Integrate/shaders2 #414
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!414
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/414/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AntoninMichelq on GitHub · 2026-11-24 03:04 UTC · original
AntoninMichelq:integrate/shaders2→main· +31224 −2127 · 82 files · 405 commits · closed without mergingNo description provided.
ds_read_{u,i}{8,16}, their _d16/_d16_hi forms, and ds_write_b{8,16} (and _d16_hi) went untranslated. Reads load the dword holding the data, shift it down and extend it; the d16 forms fill one half of the VGPR and keep the other, which the IR now records as a read of the destination. Writes clear the bytes and set them with two atomics, so lanes writing other bytes of the same dword at once keep theirs. Synthetic GFX10 compute programs check every form against a model of the console's LDS on the host GPU and WARP, including 64 lanes writing neighbouring bytes of shared dwords. Co-Authored-By: Claude Opus 5.5 <[email protected]>`victory run GTA6.exe`, run from the game folder, gives an exe path with an empty parent, and that empty folder was mounted as G:. An empty path cannot be made absolute, so the root stayed empty and G:\x64\a.rpf became \x64\a.rpf: the root of the current drive. The title then found none of its files. An empty root is now the current directory, which is what an empty folder means everywhere else (`Path::new("").join("x")` is `x` in the current directory). Passing a path with a folder in it is unaffected.Image samples and gathers now lower by their form (comparison, derivatives, coarse or 16-bit derivatives, level, level 0, bias, level clamp, texel offset) instead of a fixed list of opcodes. The address dwords follow LLVM's ImageDimIntrinsics and Mesa's ac_build_image_opcode: offset, bias and reference a dword each, then the derivatives (16-bit ones two per dword, each direction its own), the coordinates and the level or clamp. The decoder counted 32-bit derivatives for the _g16 forms; it now counts them packed. Newly lowered: - every texel-offset form of the samples above; DXIL immediates when the offset word is a constant in -8..7, else (past -8..7, or per lane) the coordinates move by offset / size at a level known at translation; - _cl (the DXIL clamp argument), _cd (as _d), _g16; - image_sample_c, _c_cl and their _o forms in compute as well as pixel shaders; image_sample_c_l(_o) with a level, image_sample_c_b(_cl)(_o) with a bias known to be 0; - image_gather4_l(_o) with a level known to be 0, image_gather4_c_lz(_o), image_gather4_c_l(_o) at level 0 (textureGatherCmp); - a16 biased samples (the bias an f16 in its dword's low half) and a16 comparisons; - image_store of some channels: the data VGPRs are the dmask's channels, the others are written as 0. Still refused, each with its reason: gathers at an implicit level or with a bias, comparisons with derivatives, at a level or with a bias not known to be 0 (SM 6.7/6.8 operations), and offsets past -8..7 or per lane at a level not known at translation. Tests: hand-assembled compute programs on the RTX 5070 against texels worked out on the CPU (offsets known, past -8..7 and per lane; levels, gradients, g16, bias and clamp through compute quads; comparisons and comparison gathers per texel; partial stores, d16 too), every newly accepted form through the validator, and the refusal reasons. On upstream/main all of them fail ("... is not supported"). Co-Authored-By: Claude Opus 5.5 <[email protected]>d2a4bae) 383bcb5591..in a title path stops at the virtual drive's root 18275322e49707daf) 5df733fd3b082e9a2) bccb4d9c1a687e7c9) cf1f4d4cccWhen the host cannot make an unordered-access view (no host texture, a format the host does not allow, a placed texture not mirrored), null_for() wrote a 2D null UAV whatever the title asked for. A shader that writes a 3D texture through it then has a dimension mismatch: GPU-based validation reports it ("UAV Dimension Expected: TEXTURE3D, UAV Dimension In Descriptor: TEXTURE2D") for the world's wind field (WindNew:CS_CopyWindFieldBeforeUpdateWithSmooth, compute 5bb23d336331db1d, image_load/image_store dim:SQ_RSRC_IMG_3D). Shader views already get a null view of the title's dimension (null_like); unordered views did not. Null texture UAVs now keep the title's dimension: 1D, 1D and 2D arrays, 3D (WSize -1). Multisampled and unnamed dimensions stay 2D. With this, the validation error is gone on an RTX 5070. Tests: the dimension mapping, and a null 3D UAV made on the real device leaves it alive. Co-Authored-By: Claude Opus 5.5 <[email protected]>Values a whole-wave section leaves were unknown when the section used a step the simulation did not model ("a whole-wave section step the simulation does not follow"). The simulation now also follows: - v_writelane_b32 (a constant or known-uniform lane takes the scalar, whatever EXEC holds): the exclusive prefix sum that carries lane 15 into lane 16 (and 31/47 into 32/48 on Wave64) with v_readlane/v_writelane. - scalar ALU on uniforms: s_mov_b32 copies, and s_add/min/max/and/or/xor combining two v_readlane results (the halves of a Wave64 reduction read at lanes 0 and 32); s_mov copies of a mask derived from the saved EXEC. - v_readlane_b32 with an SGPR lane the simulation knows, lane bits masked to the wave size, and v_readfirstlane_b32 (the first lane EXEC holds). A lane's own value of a VGPR from before the section moved to another lane (DPP, v_permlane16/x16, v_readlane) was still taken as the reading lane's own value; it is now unknown. The lowering computes a value the simulation found no shape for, when the steps that make it read no other lane (scalar code and loads scheduled into the section, lane-local vector code without DPP, permutes or lane reads/writes, and no EXEC operand), as it would outside a section: the lanes active on entry compute it as under their own EXEC. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm662a10e49) d38b73f9c9XGameSaveCreateContainer, XGameSaveCreateUpdate and XGameSaveInitializeProviderResult left the title's handle untouched when they failed. The GDK documents those handles as null on failure, and its own sample closes them on that basis ("if (containerContext) XGameSaveCloseContainer(...)" on a variable it never initialized), so a failed call made the title close whatever was on its stack: a heap corruption far from the failure that caused it. Each of the three now nulls the handle before anything can fail.A descriptor dword the code loads again alone (for an image's size bits) was matched with the load the image op uses only when both loads read the same base registers' values. The console compiler often builds the table pointer {table, 0} again before the second load (a copy in other registers, or the high half set to 0 again after the registers held scratch), so the size load found no use and failed with "a descriptor read only as data". Loads now also match when their traced addresses are the same parameter and computed term a whole number of dwords apart, and the rebuilt dwords' handle is computed from the size load's own address. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66A console wave64 program that reads masks whole or lanes of the other half now runs on a host without 64-lane waves when its group is one console wave (64 threads or fewer, no LDS). It runs as the console does ("console flow"): - `structure::structure_console` never resolves mask joins from what the lanes arriving know (every lane arrives); `Structured::execs` gives each vector instruction's EXEC bit. - Vector instructions are guarded by EXEC. Branches are the console's s_cbranch_*: EXEC, VCC and mask-operation SCC tests are the console wave's, from both halves' ballots exchanged through group-shared memory between group barriers, which every thread reaches since both halves branch alike. - Masks read whole are the exchanged ballots. v_readlane and v_readfirstlane read the owning half; v_writelane, v_mbcnt and mask bit tests use the console lane. The per-lane form is tried first; a program that needs the console flow is lowered again from the console structure. GPU tests on an RTX 5070 are exact against the console: s_bcnt1 over both halves (64, 48 and 32 threads), v_readlane 40, an exchange inside a branch only the lower half takes, and a loop the halves leave at different iterations with a lane read in each. The last one shows that the per-lane form, which hosts with 64-lane waves get, is wrong for it (on a Radeon iGPU): noted in docs/wave64-on-wave32.md, not changed. Co-Authored-By: Claude Opus 5.5 <[email protected]>7dddec2) d105484017e63b96a) 1343a0b71aA descriptor held in VGPRs is used through a waterfall loop: each pass reads the first active lane's dwords with v_readfirstlane_b32, compares them with every lane's own (v_cmp_eq), runs the access with the lanes that match and repeats for the rest. Tracing stopped at the readfirstlane results ("a descriptor neither loaded nor built"). The tracer now follows the read lanes' dwords to where each lane gets its own: global_load_dword* from a table or heap at a per-lane address (an image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per lane between such sources (e.g. two s_load descriptors). Other sources fail naming them (LDS read, buffer load, phi, input, computed VGPRs). The loop's compares of those reads with their own dwords are recorded. Lowering gives the access each lane's heap index (its load address over the descriptor size, or a per-lane select of indices) with createHandleFromHeap's nonUniformIndex set, lowers the recorded readfirstlanes as the lane's own dword and their compares as true, so the loop runs once with all lanes. Wave32 and wave64 are tested. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66bb1d5d6) f78d2431ddA join of registers that held a descriptor on one edge and data on another failed the whole program ("a scalar memory read as data" or "a descriptor read only as data"): the dwords now enter the phi as undef on the descriptor edge. An eight-dword descriptor whose only reads are its size bits, with no access in the program, is taken as a 2D texture for getDimensions. Co-Authored-By: Claude Opus 5.5 <[email protected]>scratch_load_* and scratch_store_* were refused ("flat memory"), so any program that keeps a local array with a dynamic index, or spills to memory, failed to translate and its draws or dispatches were dropped. Each lane's private memory is now an alloca of i32 in the entry block, as DXC makes local arrays. A FLAT scratch address (a VGPR, an SGPR or neither, plus the 12-bit signed offset) is a byte offset into the lane's own memory: the hardware interleaves the lanes' dwords itself (RDNA 2 ISA, "Scratch"; LLVM AMDGPUUsage, "Private Segment"; Mesa ACO uses these instructions on GFX9+ the same way), so no lane index enters the address. Lowered: dword x1-x4 loads and stores, ubyte/sbyte/ushort/sshort loads, byte/short stores, and the _d16 / _d16_hi forms (one half of the VGPR written, the other kept; stores of the high half). Loads write under the lane guard; stores run under it. The size comes from the code: an upper bound of every scratch address from the instructions computing it (constants through and, shifts, adds, multiplies, selects, bfe), plus the access width. Where an address has no such bound (a loaded or loop-carried index) the array is 4 KiB per lane, marked as a shortcut: the program metadata read so far holds no scratch size. At most 64 KiB, the D3D11 limit of indexable temporaries. Accesses past the end read 0 and drop writes; the index is checked, never wrapped. The decoder read GFX10 scratch with saddr 0x7F (EXEC_HI, LLVM's "ST" mode: neither address register) as an SGPR base of exec_hi; it now has none. The bitcode writer gains alloca (INST_ALLOCA, explicit type). Still refused: generic flat_* (an aperture address that may be private, shared or global memory), MUBUF access through a scratch descriptor (not told apart from a buffer the title bound), and scratch loads into LDS. Tests (emit/scratch_tests.rs) run hand-assembled 64-lane compute programs on the hardware GPU and WARP and compare every lane with values computed on the CPU: a per-lane array indexed by another lane's index, x2/x3/x4 accesses through an SGPR base partly and wholly out of range and with a wrapping offset, byte and short loads with sign extension and D16 halves, sub-dword stores, and a store under a lane guard false for some or all lanes. Each program also passes dxil.dll validation. Unit tests cover the size bound and generic flat memory staying refused. On main every GPU test fails in lower with "flat memory". Co-Authored-By: Claude Opus 5.5 <[email protected]>..in a title path stops at the virtual drive's root) into the integration 964aa1325bThe validator rebuilds ISG1/OSG1/PSG1 from the module's signature metadata and compares bytes ("Container part 'Program Input Signature' does not match expected for module", 29 + 25 programs). Follow DXC's DxilProgramSignatureWriter for validator 1.6: rows sorted by register, then name offset (element order), not by column (the row-only sort is from PR #136's signature fixes); mask and read/write mask of unallocated elements counted from column 0; canonical system value names; and pixel inputs the interpretation table marks NotInSig (SV_Coverage, SV_InnerCoverage, SV_CullPrimitive) named but not listed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66A waterfall loop's descriptor is often held in VGPRs that phis join: carried unchanged through a loop (through copies the phis do not see through), loaded in the branches of an if/else on EXEC, or reloaded in some passes of an outer loop. Tracing stopped there ("a descriptor read from the first lane of a phi"). The tracer now follows VGPR phis. A phi whose arguments all come to one dword (through other phis and v_mov copies, ignoring self-references and VGPRs no instruction wrote on some path) is that dword. Other joins become Source::Paths: one source per predecessor, chosen by the path each lane takes into the block (EXEC branches are per-lane branches after structurisation), with Source::Carried for a loop's back edge back to the join being traced and Source::Unset for VGPRs never written on a path. Unwritten VGPRs taken as undefined are listed in Waterfall::unset; the lowering refuses them if the hardware loads them. Untraceable arguments fail with their own reason (LDS read, input VGPR, ...). Lowering gives Paths a DXIL phi of each predecessor's heap index computed at its end (filled after all blocks for back edges), used through createHandleFromHeap with nonUniformIndex. A per-lane descriptor loaded under a partial EXEC (a guarded global load, as in an if/else without s_cbranch_execz) now fails instead of giving every lane the loaded index. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66Fixes 5 shader emission and DXIL container/validator issues in `victory-shader`, raising validated shaders across the test corpus from 21,983 to 22,159 (+176; 100% of emitted VS/PS/CS shaders now validate cleanly): 1. Biased 16-bit image samples (`emit/lower.rs`): - Remove the `a16` rejection on `image_sample_b` and separate 32-bit prefix operands (offsets, bias, comparison reference) from `a16`-packed tail operands (gradients, coordinates, explicit LOD) starting at `regs[first]`, matching GFX10 MIMG hardware operand layout. 2. Conservative depth `SV_Position` interpolation (`emit/mod.rs`): - Declare `SV_Position` with `linear_noperspective_centroid` (5) instead of `linear_noperspective` (4) in pixel shaders outputting `SV_DepthLessEqual` or `SV_DepthGreaterEqual` (kinds 18/19). 3. Per-row interpolation mode consistency (`emit/mod.rs`, `emit/lower.rs`): - Add `harmonize_row_interp()` so elements sharing a signature row always declare the same interpolation mode: rows containing integer attributes or `SV_IsFrontFace` propagate `nointerpolation` (1) to sibling elements, and after pixel-shader lowering unread siblings inherit the actual read mode of sibling elements in the same row. 4. Container signature row ordering (`emit/container.rs`): - Sort `ISG1`/`OSG1` rows stably by register only (`row`) rather than `(row, col)`, preserving DXIL element-ID order within a row so the container signature matches DXIL validator expectations byte for byte. 5. SM 6.6 compute-shader implicit derivatives (`emit/shader.rs`, `emit/container.rs`, `emit/lower.rs`): - Track compute shaders emitting implicit-derivative sampling ops and emit `dx.valver = 1.8` with `PSVRuntimeInfo3` (52 bytes, carrying `EntryFunctionName`), enabling validation and D3D12 compute PSO creation. Adds 5 unit + `dxil.dll` validation (+ D3D12 compute PSO) tests in `emit::tests`.@Raxstreams on GitHub · 2026-11-24 03:20 UTC · original
Tested
d3917dfoffline on an RTX 3080 Ti with the adapter's reported 32-lane target. I replayed 273 distinct shader containers that a previous Series S integration had failed to translate or create a pipeline for. With this PR, 90 passed both DXIL validation and host pipeline creation. Of those, 69 were ray-tracing material resolve compute shaders. The indirect-light primary shading shader 2fe078146e7045ff also passed. This verifies pipeline creation. I am still checking the visible result in the opening scene.Pull request closed