Skip to content

Shader: fix biased 16-bit image samples and DXIL validator failures - #306

Closed
wbkepler wants to merge 3 commits into
Marvisak:mainfrom
wbkepler:shader/validator-and-16bit-sample-fixes
Closed

wbkepler wants to merge 3 commits into
Marvisak:mainfrom
wbkepler:shader/validator-and-16bit-sample-fixes

Conversation

@wbkepler

Copy link
Copy Markdown

Summary

Fixes 5 shader emission and DXIL container/validator issues in victory-shader (+176 newly validated shaders, 100% of emitted VS/PS/CS validating cleanly):

  • Biased 16-bit image samples (emit/lower.rs):
    • Enables a16 biased image samples (image_sample_b) by separating full 32-bit prefix VGPRs (offsets, bias, comparison reference) from a16-packed tail operands (gradients, coordinates, explicit LOD) matching GFX10 MIMG hardware layout.
  • Conservative depth SV_Position (emit/mod.rs):
    • Sets SV_Position interpolation to linear_noperspective_centroid (5) in pixel shaders outputting conservative depth (SV_DepthLessEqual/SV_DepthGreaterEqual).
  • Row interpolation consistency (emit/mod.rs, emit/lower.rs):
    • Adds harmonize_row_interp() so packed elements in the same signature row share one interpolation mode (propagating Constant for integer/SV_IsFrontFace rows and inheriting read modes for unread PS siblings).
  • Signature ordering (emit/container.rs):
    • Stably sorts ISG1/OSG1 signature rows by register only (preserving element-ID order within a row to match DXIL validator expectations).
  • Compute implicit-derivative sampling (emit/shader.rs):
    • Tracks SM 6.6 compute-shader implicit-derivative sampling to emit dx.valver = 1.8 and PSVRuntimeInfo3 (52 bytes with EntryFunctionName).

Verification

  • cargo clippy --workspace --all-targets — passed (zero new warnings)
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test --workspace — passed (victory-shader: 74/74 including 5 new dxil.dll validation and D3D12 compute PSO tests)
  • cargo xtask policy — passed (151 files ok)

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Review note on the a16 address layout, two points where this differs from LLVM's AMDGPU backend:

  1. The bias. The test here builds image_sample_b ... a16 with "a 32-bit f32 bias", and the lowering reads the bias dword whole. SITargetLowering::lowerImage has:
// Special handling of bias when A16 is on. Bias is of type half but
// occupies full 32-bit.
SDValue Bias = DAG.getBuildVector(MVT::v2f16, DL, {Op.getOperand(ArgOffset + I), DAG.getPOISON(MVT::f16)});

and asserts "Bias needs to be converted to 16 bit in A16 mode". So with a16 the bias is an f16 in the low half of its own dword; read as an f32 it is a denormal near zero, and the sample silently loses its bias. The test passes because it encodes the same assumption.

  1. Derivatives. With a16 the derivatives are taken as packed 16-bit values. On GFX10.3 they are 16-bit only in the _g16 opcodes; LLVM's gfx10_asm_mimg.s has image_sample_d ... dim:SQ_RSRC_IMG_2D a16 with five address dwords (four 32-bit derivatives plus the packed coordinates).

#160 and #318 read the bias as f16; #73 and #136 as f32, like this one. I got point 2 wrong myself in #160 and fixed it there.

From the documents and synthetic tests only; I have no copy of the title and have not run this on console hardware.

@wbkepler

Copy link
Copy Markdown
Author

Thanks @r4tedx, you're right on both points. Fixed in a8430f2:

  1. Bias with a16: the bias keeps its own address dword, but it is now read as an f16 from the low half (masked, then legacyF16ToF32) instead of as an f32. The synthetic image_sample_b ... a16 test now puts f16 -1.0 in the low half and junk in the high half, so the test no longer bakes in the f32 assumption.
  2. Derivatives: outside the _g16 opcodes, a16 leaves each derivative as a full 32-bit dword. Only the coordinates and LOD are packed. The decoder's address dword count now follows this (2D image_sample_d ... a16 = 5 dwords, _g16 packs one dword per direction), and the lowering reads the gradients as full f32 dwords, with the packed coordinates starting after them. There is a new decoder unit test for these counts.

The workspace clippy, tests and cargo xtask policy pass.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…73d66, and Marvisak#180)

The wave64 stack (Marvisak#223, Marvisak#233, Marvisak#320, Marvisak#439, with Peter Bonanni's
whole-wave sections across the halves, 9b73d66) merged with Marvisak#180 (twin
descriptor loads and quad gradients for compute samples), at 24b3bcc.
That commit has one parent (e49302a); Marvisak#180's changes come in without
its commits. Marvisak#233 is in this tree as 1eb9995, the same tree as
3098672, so each file was merged with 3098672 as the base instead of
the e0865d2 git chooses.

Conflict resolutions:
- emit/wave.rs, v_permlane16/x16 in whole-wave sections: Marvisak#98's "every
  lane active" and 9b73d66's "or fi set" are both kept, for both
  instructions.
- emit/lower.rs, Lower::new: Marvisak#320's test for lane reads and writes in
  divergent programs counts live instructions only, as Marvisak#233's does
  with Marvisak#309 (dead SGPR-spill lane instructions are no lane reads).
  Marvisak#307's waterfall arm of v_readfirstlane still comes before the
  console-flow arm; Marvisak#320 adds no arm of its own.
- Compute samples with implicit derivatives (Marvisak#160, Marvisak#180, Marvisak#306): Marvisak#180
  decides plain and biased samples, all of Marvisak#160's forms of them
  (implicit_derivatives from sample_form: _o, _cl, cube, a16), with
  Marvisak#160's bias address (bias_at) and level clamp; Marvisak#306's validator 1.8
  is now declared only for what still uses the host's derivatives in
  compute (comparison samples, op 64). The Marvisak#306 test of image_sample
  now asserts no 1.8 (48-byte PSV0) and still validates and creates
  the pipeline; a twin test with image_sample_c asserts 1.8.
- sgpr_spill test (Marvisak#309): without forwarding, the per-lane form still
  stops with "a lane mask holding lanes elsewhere read as data", but
  emit now takes the console flow (Marvisak#320); the test checks both, and
  that forwarded spills do not ask for the console flow.
- Mechanical: per_lane_only in two hand-built Parts in emit/lower.rs
  tests; emit/mod.rs module order (split_tests before threading).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@upipibi upipibi mentioned this pull request Nov 24, 2026
@iurysf

iurysf commented Nov 24, 2026

Copy link
Copy Markdown

Measured offline against main d2a4bae: victory translate --list --validate over the title's shaders.rpf + executable (26,096 programs), dxil.dll 1.9.2602.17 (DXC v1.9.2602).

validated rejected by the validator "incompatible with the shader stage" (cs)
main 21,983 185 23
main + this PR 22,159 53 0
main + this PR + #309 + #385 (clean merge) 22,320 53 0
  • No program that validated on main is rejected with this PR, alone or stacked.
  • The 53 left are all mesh vertex plus primitive output size is greater than 32768.
  • The incompatible with the shader stage rejections grow to 34 with Shaders: forward SGPRs reloaded from VGPR lanes as the spilled value #309 and 45 with Shaders: track every incoming edge of a lane-mask phi #385 alone (newly emitted compute programs with implicit-derivative sample). This PR clears them all, so it's worth landing before or with those two.
  • I hit the same root cause independently. A minimal HLSL compute shader with Texture2D.Sample compiled by dxc with -T cs_6_6 -validator-version 1.6 or 1.7 fails with exactly this error, and it passes with 1.8. So dx.valver 1.8 for compute derivatives is the right fix.

@slint6614-dev

Copy link
Copy Markdown

Measured on the full retail shader pack (26,503 containers) with victory translate --validate, against main d2a4bae:

VS/PS validated CS validated MS validated cargo test -p victory-shader
main 12172 1670 8129 ok
#569 12208 1670 8129 ok
#73 12208 1670 8129 ok
#318 12208 1670 8129 ok
#306 12316 1693 8138 ok

All four clear the 108 "biased image sample with 16-bit coordinates" programs identically. #73 and #318 also clear the 27 image_sample_d_cl refusals, but those programs then stop on another reason (emitted count unchanged). #306 additionally clears 15 of the 16 validator error kinds (only the mesh 32 KiB output size remains, see #459); it overlaps #554/#565/#381. Windows 11, dxil.dll from SDK 10.0.26100.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…rol flow; waterfall loops proven)

Marvisak#566 is stacked on Marvisak#307, which this tree holds as its first two commits
(the tree's resource.rs was identical to ffa6635's). The merge so also
brings Marvisak#307's last two commits, 077ec8b and 6285e19. Git found upstream
main as the base, which sets Marvisak#307's own lines against themselves; each
file was merged with ffa6635 as the base instead.

- crates/victory-shader/src/resource.rs: Marvisak#566's, unchanged (the tree had
  no edits of its own there).
- crates/victory-shader/src/emit/lower.rs: no conflict on that base. The
  tree's lowering is kept (Marvisak#307's waterfall arm of v_readfirstlane before
  the console-flow form, fetched_index through Marvisak#483's heap guard), with
  Marvisak#566's Source::LanePhi arms and tests. lane_heap_index joins the
  indices heap_index and fetched_index return, so each is already
  guarded. Marvisak#226's annotation test passes the per-lane form to track.
- crates/victory-shader/src/structure.rs: both sides' additions kept:
  MAX_MEMO (Marvisak#288) with MAX_MEET, and in Structured the wave64 stack's
  execs, others and pairs with Marvisak#566's reach and paired_masks.
  paired_masks is filled last, since it takes the masks pairs reads.
- crates/victory-shader/src/emit/mod.rs: translate keeps Marvisak#309's spill
  forwarding and Marvisak#223's target, structures first and passes the per-lane
  form to track as Marvisak#566 does. The threading retry of emit passes its
  own. The tests' helpers (Marvisak#223's, Marvisak#306's, Marvisak#459's, Marvisak#48's) pass it too.
- apps/victory/src/translate.rs: Marvisak#566's arm (Source::LanePhi is no
  leaf); the tree's fix already counted Fetched as loaded, as 077ec8b
  does.
- docs/architecture.md: no conflict on that base; Marvisak#566's text.
- emit/image_tests.rs (Marvisak#160), emit/lane_read_loop_tests.rs (Marvisak#439),
  sgpr_spill.rs (Marvisak#309, Marvisak#320): track takes the per-lane form. Helpers
  that return the error keep the order of failures (resources, I/O,
  then structure).
- emit/waterfall_tests.rs (new, Marvisak#566): lower::Parts gets the tree's
  target, console_cf and per_lane_only; the dispatch fills Marvisak#483's guard
  dwords.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@Halfect Halfect left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of a8430f2, focused on the container/validator items. I did not run the suite here; this is code reading plus comparison against an independent implementation.

Compute implicit-derivative sampling (dx.valver 1.8 + PSVRuntimeInfo3). The approach is correct and the emitted bytes are right: RuntimeInfoSize 52, with the EntryFunctionName string-table offset 1 (main\0 appended after the leading empty string) as the last four bytes of the info. I had implemented this same item independently on a fork branch before noticing this PR; the PSV0 output is byte-identical, so I am dropping mine as a duplicate of this item. The tracked opcode set (60 Sample, 61 SampleBias, 64 SampleCmp, 81 CalculateLOD) is exactly the implicit-derivative set — SampleLevel (62), SampleGrad (63) and SampleCmpLevelZero (65) take an explicit level or gradients and correctly stay at validator 1.6/1.7.

On the interaction with #180: even if #180 lands and converts plain compute image_sample / image_sample_b to SampleGrad, comparison samples with implicit derivatives (image_sample_c* in compute) still require validator 1.8, so this item stays necessary either way. The two are complementary, not conflicting.

Row-interpolation harmonization. It runs from both lower (pixel inputs, after fill_phis) and emit. The function only rewrites elements with usage == 0 and never changes the mode it computes from, so the second pass is a no-op — redundant but harmless. Forcing Constant on rows that hold SV_IsFrontFace or integer elements matches the validator's one-interpolation-mode-per-row rule.

Conservative depth. Switching the pixel SV_Position input to linear_noperspective_centroid (5) when the shader outputs SV_DepthLessEqual/SV_DepthGreaterEqual matches the validator's conservative-depth requirement; leaving it at 4 otherwise is right.

a16 layout. The a8430f2 fix matches LLVM's lowerImage: the bias is an f16 in the low half of its own dword, and derivatives stay 32-bit outside the _g16 opcodes. The two points @r4tedx raised are addressed.

One process note: the PR is currently dirty against main (ffe310e) and needs a rebase before it can land.

No blockers from what I can check statically. AI-assisted.

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…isak#306 Marvisak#333 Marvisak#105 Marvisak#288 Marvisak#343 Marvisak#353 Marvisak#326 Marvisak#259 Marvisak#179 Marvisak#176 Marvisak#226 Marvisak#286)

Conflicts:
- emit/lower.rs: shader-opcodes and shader-tracking each keyed heap
  handles by the resource properties (a tuple vs two flattened words);
  the same key, shader-tracking's form and comment kept. Lowered's
  test-only fields, test imports and tests of both sides kept.
- emit/wave.rs: tests of both sides kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Conflicts in crates/victory-shader/src/emit/lower.rs, all in fn image
against Marvisak#306 (from shader-tracking), except the first:
- After half_outputs: shader-tracking's half_inputs and Marvisak#160's
  SampleForm / sample_form are both kept.
- The sample and gather path takes Marvisak#160's address layout (coord_at,
  grad_at, bias_at): with a16 the bias is an f16 in the low half of its
  own dword, and a16 packs the coordinates and level but not the
  derivatives (only the _g16 opcodes do). Marvisak#306 read the bias as a 32-bit
  dword and packed the derivatives with a16; those hunks (bias, gradients,
  comparison reference, level, gather offsets) are Marvisak#160's.
- Marvisak#306's other parts stay: its addr_dword / addr_val(start, k) split for
  the non-sample image paths (comment updated, as samples no longer use
  it directly), the removed a16-bias refusal (Marvisak#160 removes it too), and
  cs_derivatives for compute samples with implicit derivatives (valver
  1.8, PSV0 runtime info 3), plus its signature and container fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Found when merging Marvisak#160 with Marvisak#306. Marvisak#306 declares dx.valver 1.8 for a
compute shader that samples with implicit derivatives. From 1.8 on, the
validator counts a Sample, SampleBias, SampleCmp or SampleGrad whose
clamp is neither undef nor the constant 0 as needing tiled resources
(DXC DxilShaderFlags.cpp, CollectShaderFlags: hasSampleClamp and
canSetTiledResourcesBasedOnLodClamp); 1.7 and earlier do not, and refuse
the flag. Marvisak#160's _cl forms in compute shaders therefore failed "Flags
must match usage" (declared 0xC0000000, actual 0xC0001000) in
emit::image_tests: sample_cl, b_cl, c_cl, c_b_cl and their _o forms.

A clamp known to be 0 is now passed as the constant 0. Any other clamp
marks the shader, and a shader declaring 1.8 sets the TiledResources
flag (bit 12) and its SFI0 feature bit (0x100).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ordis-labs

Copy link
Copy Markdown

Rebased this onto current main (ffe310e) locally to measure it there, since it no longer merges cleanly. Three things needed:

  1. emit/mod.rs: main now has Shaders: centroid position with conservative depth #565's conservative-depth rule as a separate block after the interpolation loop, and this PR has the same rule inside the loop. I kept this PR's version plus harmonize_row_interp(interpolated) and dropped main's block. Same result for SV_Position.
  2. emit/lower.rs: Shaders: image_sample_o with constant offsets #634 (image_sample_o) added addr_val(self, 0) in the old two-argument form. With this PR's addr_val(l, start, k) that becomes addr_val(self, 0, 0), which is identical to main's addr_val(l, k).
  3. The test helper in emit/mod.rs (~line 806): resource::track takes Some(&st) since ffe310e, so structure goes first.

Results on ffe310e (translate --list --validate over the 1.0.2.1 shaders.rpf, SDK 10.0.26100 dxil.dll, outcomes matched program by program against main):

  • +153 programs validate, 0 lost. 44 are "a biased image sample with 16-bit coordinates". The rest were validator signature errors that harmonize_row_interp fixes (TEXCOORD/NORMAL/COLOR/SV_IsFrontFace locations, input/output signature mismatches) plus 24 "incompatible operation".
  • Every emitted vertex/pixel program validates: 12,275/12,275 (main: 12,155 of 12,231).
  • cargo test -p victory-shader: 111 passed. The 15 failures also fail on main on this machine (Windows 10, no SM 6.6 device for the GPU tests).

Windows 10 19045, RX 6700 XT. Tested and written up with Claude's help.

Fixes 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`.
@SAitken91

Copy link
Copy Markdown
Contributor

Measured this against my #569 (same biased-a16 fix) on the retail shaders.rpf, each merged alone onto main ffe310e, victory translate --validate, Windows SDK dxil.dll:

VS/PS emitted / validated CS validated MS validated
main 12231 / 12155 1417 8152
+ #569 12275 / 12191 1417 8152
+ #306 9342153 12275 / 12275 1441 8161

Both unblock the same 44 programs (a biased image sample with 16-bit coordinates 108 → 0), but #306 also clears every remaining validator failure on this pack except the 53 mesh vertex plus primitive output size > 32768 — including the interpolation-row ones, while keeping rows in place (the reason I closed #554 in its favour). So #306 covers #569; if this lands, #569 isn't needed.

MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
….dll is older than validator 1.8"

This reverts commit 119b763.
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…tic names per element, skip on validators older than 1.8)

The author's head now does what the bundle's own commit did (a validator version query and the
skip below 1.8), and fixes the second failing test at its cause; the bundle's commit is
reverted just before this merge.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…ring

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…centrics

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…bustness

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…sak#704 + Marvisak#1511

Conflicts in crates/victory-shader/src/emit/lower.rs, resolved by hand:

1. descriptor_data: the bundle (Marvisak#953 s_buffer_load uses, Marvisak#1067 "read only as data"
   from the table's range) and Marvisak#180 (twin loads of the same dwords) both rewrote how
   the view's kind is found. Kept Marvisak#180's lookup (own uses, else a twin load's) and the
   bundle's handling of the use and of the unused case, plus the one case Marvisak#180 accepted
   that the bundle did not: an 8-dword load outside a table/heap range, taken as a 2D
   image (Marvisak#180's "image the program only measures"). Where both accepted a descriptor
   they built the same view.
2. phi joins: the bundle's arm (Marvisak#1073, a mask dword joined by ballot) and Marvisak#180's arm
   (a descriptor dword at a data join is undef) were inserted at the same place. Both
   kept, bundle first; the first needs a tracked lane mask, which a descriptor dword
   is not, so they do not overlap.
3. No textual conflict, did not compile: the bundle (Marvisak#306) gave `addr_val` a start
   position (`addr_val(l, start, k)`); Marvisak#180's compute image_sample_b arm read the bias
   with the old form at dword 0 through `as_float`. It now reads it as the bundle's
   sampleBias does: after the offset word when there is one, an f16 with a16
   (`to_float`). This is the bias half of the Marvisak#160/Marvisak#180 interaction described in
   Marvisak#160 (comment) , which the
   bundle's offset forms already expose.
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…ge samples) onto Marvisak#309 + Marvisak#180 + Marvisak#704 + Marvisak#1511

PR Marvisak#160 head 5ce85c5, merged onto integ/next-v3 (0bb7335). The bundle
(Marvisak#1511) already carries Marvisak#306 (a16 bias as f16, a16 derivatives 32-bit),
10ac6ce (cube gradient samples, image_sample_d_cl) and cbc8c33 (image_get_lod
on cubes); Marvisak#180 adds compute image_sample/_b as sampleGrad with quad gradients.
Where Marvisak#160 and the bundle implement the same thing, they read the same address
layout: offset, bias and reference a full dword each (a16 bias an f16 in the low
half), derivatives 32-bit unless _g16, a16 packing only coordinates and level or
clamp. The bundle's Marvisak#306 layout is kept as the base and Marvisak#160's forms are added
to it.

gfx10/fields.rs (image_addr_dwords): both sides size derivatives by _g16 and
pack only coordinates and levels with a16. Kept the bundle's Marvisak#306 version (a g16
token rather than Marvisak#160's ends_with("_g16"), which gives the same count for every
opcode name) together with its a16_keeps_derivatives_32bit_outside_g16 test.

emit/host.rs (1 hunk): Marvisak#160 adds a test-host arm for Levels/CubeLevels/Depth
SRVs; the bundle (Marvisak#704) extended the UAV arm to BufferUav with a stride column.
Both arms kept: Marvisak#160's arm first, then the bundle's UAV arm unchanged.

emit/lower.rs:
1. Free functions after half_outputs: the bundle added half_inputs and Marvisak#160
   added SampleForm/sample_form/GATHER_AT_LEVEL in the same place. Kept both.
2. Opcode match: the bundle added "image_sample_d" | "image_sample_d_cl" to the
   fixed list, and Marvisak#160 replaced the list with the parsed form (_ if form.is_some()).
   Took Marvisak#160's. d_cl is the form {d, cl}, so it still lowers to SampleGrad with
   its clamp.
3-4. Address layout: the bundle had (Marvisak#306) first = offset + bias + cmp
   full dwords, 32-bit derivatives (2 per direction on a cube, 10ac6ce), and
   `at` = first + grads, from which the a16-packed coordinates and level start.
   Marvisak#160 had the same layout as whole/per_direction/first, plus _g16 derivatives and
   _cl. Kept the bundle's names and layout (first, graded, at, addr_dword) and put
   Marvisak#160's pieces on them: first is now o + b + c from the form (it was
   offset_word + (name == image_sample_b) + cmp); per_direction halves the
   derivative dwords for _g16 only; grad_at, coord_at, bias_at, float and known
   (Marvisak#160) read through the bundle's addr_dword in place of Marvisak#160's duplicate `raw`.
   Marvisak#306's to_float/addr_val pair for coordinates and Marvisak#160's float(coord_at(k))
   compute the same thing; the latter is kept because the level, clamp and known
   checks use it. The a16 refusal of comparisons in the bundle's code is
   dropped, as in Marvisak#160 (the reference is a full dword).
   Also, without a textual conflict: Marvisak#160 refused level queries on cubes
   ("... or a level query"), but the bundle lowers image_get_lod on cubes
   (cbc8c33). That refusal is dropped and only texel coordinates (both sides)
   and texel offsets (Marvisak#160) are refused on cubes. The bundle's `face` variable is
   kept in place of Marvisak#160's `cube_face`.
5. sample (60): the bundle's constant-offset code is the base code with
   addr_dword. Marvisak#160 moved offsets before the match (immediates in -8..7, otherwise
   a coordinate shift at a level known here) and added the clamp. Took Marvisak#160's
   version, reading the word with addr_dword.
6. sampleBias (61): bundle addr_val(offset_word, 0) + to_float, Marvisak#160
   float(bias_at). Both read the same position, an f16 low half with a16. Kept the
   bundle's comment and Marvisak#160's reader, plus Marvisak#160's clamp.
7. sampleGrad (63): the bundle reads `graded` 32-bit derivatives per direction,
   turns cube face derivatives into direction derivatives after reading, and
   reads its own _cl clamp. Marvisak#160 reads through grad_at (g16 too) with a per-face
   branch. Kept the bundle's structure (loop over `graded`, then the cube
   conversion) reading through Marvisak#160's grad_at, so _g16 works. The bundle's inner
   clamp is dropped for Marvisak#160's clamp, which comes from the same position
   (coordinate `coords`) and now covers every _cl form. Marvisak#160's `_cd` shortcut
   comment is kept.
8. sampleCmp/LevelZero (64/65): the bundle reads addr_dword(first - 1) and Marvisak#160
   reads float((o + b, None)). These are the same dword, since first = o + b + c
   and c is set. Kept the bundle's line. Marvisak#160's clamp is pushed for SampleCmp.
9. sampleLevel (62): bundle name == "image_sample_l" with addr_val(at,
   coords), Marvisak#160 f.l with float(coord_at(coords)). These are the same position.
   Took the form test so that _l_o and the others are covered.
10. gather (default arm): the bundle's checks and per-lane offsets are the base
    code with addr_dword. Marvisak#160 moved the checks into the op choice (level 0,
    comparison gathers, GATHER_AT_LEVEL) and the offsets ahead of the match.
    Took Marvisak#160's.
Duplicate method: 10ac6ce (bundle) and Marvisak#160 both add Lower::cube_gradient with
the same table (u, v move by 2 ds, 2 dt, the major axis by 0). With no conflict
git kept both. Kept Marvisak#160's, which shares by_face with cube_direction, and
removed the bundle's.

Marvisak#180 interaction (integration fix from
Marvisak#160 (comment), r4tedx):
Marvisak#180's compute image_sample/_b arm (sampleGrad from quad gradients) dropped the
level clamp, and before 5703405 it also read the bias at dword 0. With Marvisak#160,
_b_o, _cl and _b_cl_o reach that arm. The arm now reads the bias with
float(self, bias_at) (after the offset word, an f16 with a16; this is the same
position 5703405's addr_val(offset_word, 0) + to_float read) and pushes Marvisak#160's
level clamp instead of undef.

Marvisak#160 x Marvisak#306 interaction (no textual conflict; emit/shader.rs, lower.rs):
Marvisak#306 declares dx.valver 1.8 for a compute module with an implicit-derivative
sample (cs_derivatives, which Marvisak#180's sampleGrad arm also sets). Validator 1.8
counts a sample's level clamp (a non-undef clamp operand) as TiledResources use,
and 1.6 does not. Marvisak#160's _cl forms in compute (Marvisak#180's arm with the clamp above,
and SampleCmp for _c_cl) therefore failed "Flags must match usage" in
sample_and_gather_forms_lower_to_valid_dxil, comparisons_and_comparison_gathers_
match_per_texel_comparisons and texel_offsets_and_levels_sample_the_texels_they_name
(declared and actual flags differ by exactly 1 << 12). Marvisak#160 alone declares 1.6,
where this does not apply. Added flags::TILED_RESOURCES (bit 12, SFI0 0x100). It is
set when a sample takes a level clamp (Shader::lod_clamp) and the module declares
valver 1.8. Still needed on this Marvisak#1511 head: its Marvisak#1402 (119b763) only skips two
of Marvisak#306's own tests when dxil.dll is older than validator 1.8 and does not change
what Marvisak#306 declares.

Checked (on the previous Marvisak#1511 head, 289f241, which also carried Marvisak#98; this
replay was checked with cargo check --workspace --all-targets --all-features and
the full suite at the end of the line): cargo build --workspace --all-targets, clippy -D warnings, xtask
policy. cargo test --workspace on an RTX: 427 passed, 0 failed, 6 ignored. With
VICTORY_WARP=1 --no-fail-fast: 426 passed, 1 failed (valu_tests::
v_cndmask_on_an_untracked_mask_tests_this_lanes_bit, which also fails on the base),
6 ignored. #[test] count: base 424 + 8 from Marvisak#160 = 432 in the tree; the
victory-shader lib lists all 204 of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…sak#98, Marvisak#334 to Marvisak#492, validation)

The line rebuilt on the bundles' current heads (Marvisak#1402 119b763, Marvisak#1492 5bbc098
without Marvisak#98, Marvisak#1504 1d41891, Marvisak#1511 ca601f0) with every merge replayed, and the
merges after this file's first version (Marvisak#334, Marvisak#346, Marvisak#1024, Marvisak#211, Marvisak#492): merge
order, the runner's numbers on 967d3ae (RTX 571, WARP 570 + the known Marvisak#1084
failure, all features 580; Marvisak#98's one test leaves), what is not included (Marvisak#98,
Marvisak#282 for Marvisak#346, Marvisak#693 for Marvisak#1024, Marvisak#306's latest commit), and the open pull
requests whose head is contained here (109, from the 18:24 collection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexdeliu

Copy link
Copy Markdown

Rechecked e3067ae on the RX 9070 (RDNA4) with the stock Windows SDK 10.0.26100 dxil.dll (1.7.2308): cargo test --workspace --locked gives 348 passed, 0 failed, 6 ignored. Both PSV0 failures I reported are gone, and compute_shader_implicit_sample_uses_valver_1_8_and_validates and signature_part_preserves_element_order_within_row_and_validates pass. Thanks!

Note: the branch is still on ffe310e. Merging current main (70564ae) conflicts in emit/lower.rs and emit/shader.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.