Shaders: second rows of packed 16-bit pixel inputs #592
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/592"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T05:15:19Z.
Pixel inputs that pack two 16-bit rows per dword (
pack2) failed when their metadata leaves the second row out (row2=row). With no second row, reading any of its halves failed with "a packed input half no element holds". That blocked 172 programs in shaders.rpf, mostly ped and mirror-reflection pixel shaders.Change
half_input_partners. It finds the missing second row the way the output side already does (half_outputs): the next 16-bit row of the input signature that no input entry names, taken in row order. Rows the metadata does give are taken first, so they aren't handed out twice.pack2is set androw2=row. An explicitrow2is used as before.Why not just read 0
I tried that first, and it would have validated more programs. A diagnostic showed the failing reads were halves 4–7 with a 4-channel first row, which is the second row's data, not padding. Reading 0 would have hidden real values, so I didn't do it.
Results
victory translate --validate shaders.rpf: vertex/pixel validated 12172 → 12289. 6 programs whose metadata does name a second row still stop at this error. That looks like a separate case, and it's left as is.Testing
cargo test -p victory-shader: 70 passed, including the newpacked_pixel_inputs_find_their_second_row. Clippy and rustfmt are clean.This is independent of #539, #554, #563, #565, #569 and #571.
Written with the help of Claude (AI).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T05:20:20Z.
Review: APPROVED
Tested and verified on Windows 11 x64 (D3D12 WARP + Hardware).
ow2 == row.
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T05:33:56Z.
I have the same local v1.0.2.1 shader archive and will investigate the 6 remaining explicit-
row2cases as a follow-up to this PR, rather than changing this branch. I’ll first reproduce them on7139712and inspect only the signature metadata and failing half indices needed to distinguish the case.If the cause is separable, I’ll add a focused synthetic regression test and open a small follow-up PR stacked on this head. I’ll report counts and metadata only, without shader contents or extracted data. AI-assisted (Kimi).
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T05:44:56Z.
Opened the follow-up as #621, stacked on this head: https://github.com/Marvisak/VIctory/pull/621
The explicit-
row2padding fix turns all 6 remaining failures into validated modules: VS/PS emitted 12,389 → 12,395, validated 12,289 → 12,295, with 6 gained and 0 lost across 25,889 matched labels. The inferred-partner case remains strict, and the new synthetic test covers that distinction. AI-assisted (Kimi).Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T05:48:18Z.
Hardware readback on
7139712with a synthetic full-screen draw. The VS supplies three distinctTEXCOORDrows, and the translated PS reads both halves of packed channels 0 and 2. The VS and emitted PS passed the Windows SDK DXIL validator (1.8.2502.11).row2 = rowrow2 = 2d2a4baea packed input half no element holds[0.125, 0.25, -5, -4]7139712[0.125, 0.25, 1.25, 2.5][0.125, 0.25, -5, -4]The results matched on the RTX 5090 (32.0.16.1656) and Radeon iGPU (32.0.21042.62). This covers the inferred pairing and the explicit control for this constant-varying fixture. The explicit padding cases are tracked in #621.
The same fixture also passed on #176 at
f0e7745after the triage comparison. Both adapters matched 16/16 pixels for the inferred row and the explicit control.Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T06:17:01Z.
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17:AI-assisted.
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T08:43:55Z.
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines created on an AMD RX 9070, Adrenalin, Windows 11; dxil.dll from SDK 10.0.26100), against main1f858b0. Counts are emitted / validated / pipelines.#621 clears all 172 (+123 validated pixel programs); #176 and #592 give identical results (+117, 6 left). CS and MS unchanged in all three.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T11:04:57Z.
Heads-up on the stack: #621 is stacked on this PR — its body says "Stacked on #592 at
35bf153; only7e5c7c8is new here", and since its base ismainwith 2 commits, merging #621 as-is would land both this change and the explicit-padding follow-up together.I reviewed and approved #621 after rebasing it onto current main locally: merges cleanly,
cargo test -p victory-shader --locked→ 98 passed / 0 failed (macOS arm64). The combined diff keeps this PR's pairing logic (packed_input_half/half_input_partners) intact.Also noting #176 (Yaekai) is an independent implementation of the same root fix (pairing
pack2fp16 inputs whose metadata leavesrow2 == row), with several reviews already. So the maintainer has two routes: merge #592+#621 as a stack, or compare against #176. Either way this PR's content is covered by my #621 approval if the stack lands first.Imported from Marvisak/VIctory. Originally posted by dpalacios69 on 2026-11-24T15:07:56Z.
Independent check on Linux, merged onto current
main(ffe310e) in a scratch branch: textually clean,cargo test -p victory-shader --lockedpasses (97 passed, 0 failed, 1 ignored, the new test included),cargo clippy -p victory-shader --libhas no warnings.--all-targetsshows only the two unused-import warnings inemit/mod.rsthatmainalready has on Linux. No GPU run. AI-assisted; no game data.Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T16:20:46Z.
Measured on Linux (RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master), head
35bf153merged onto our tree:a lane mask read as data281 -> 310 and similar), which looks like the expected next class, not a regression.cargo test -p victory-shader --lib114 pass, only the known failure.Not tested: in-game on this branch; native Windows.
Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-24T16:28:09Z.
An independent count of what this blocks, measured on main
ffe310ewith my own copy of package 1.0.2.1 (title buildb99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93), on a second machine. Command:victory translate <shaders.rpf> --validate --list.PS_MirrorPedTextured_Eight, 45PS_PedTextured_Eight_Decals, 28PS_PedTexturedCutOutTint_Zero, 12PS_DeferredPedTexturedNC_Packed, 10PS_PedAlphaPrepass_Fire, 10PS_PedAlphaTransmission_Fire, 10PS_Textured_Eight_Fire, 1PS_DeferredTexturedStdFireColor, 1PS_DeferredTexturedStdFireNC. Your "mostly ped and mirror-reflection pixel shaders" matches the top of this list.What the code path allows, reading
emit/lower.rs: the reason is produced at exactly one place,lower.rs:5543, reached only through the_f16branch (lower.rs:5511,lower.rs:5541-5543), and everyNonecomes frompacked_half(lower.rs:291-307) or from the non-packed branch atlower.rs:5522. That gives four routes:>= nabut< a_halves— padding inside the first row's own extent.row2 == row, so no partner row is offered (lower.rs:5508).>= extent(b)— the named partner row declares fewer channels than the interpolation reads.fp16set,pack2clear, and the attribute asks for the upper half (lower.rs:5522,highdecoded atgfx10/fields.rs:565).Routes 2 and 3 are what #176, #592 and #621 describe, and I read #176 and #592 as the same pairing fix described twice (
half_inputsandhalf_input_partners), so I don't know which one is intended. Route 1 with an inferred partner is the one #592's "why not just read 0" argument is about. Route 4 I don't see in any of the three. I cannot tell how my 166 split across the routes without printing each program's declared rows and channels.One thing that may help whoever implements #621: this same function already reads a missing half as zero for a flat input. In the
mode == 1branch,lower.rs:5547-5549buildsself.s.m.i32(0)and applieshalf(self, h)?.unwrap_or(z)for both halves, while the_f16branch refuses the identicalNone. So "the padding reads as zero" is already the behaviour of one of the two paths, and the difference between them is only which one the program asks for. Also measured on the same run: the neighbouring refusals of this function never fire on this package —a 16-bit read of a 32-bit input,32-bit interpolation of a 16-bit input,one input interpolated two ways,an input the signature lacks,a non-provoking vertex valueandpull-model interpolationare all 0 — whilethe first half of an interpolation(lower.rs:5555) is 29, which is a separate gap.If any of #176, #592 or #621 lands, I can run the same census before and after on a clean worktree and report which families unlock and how many, the way I did for #878.
Written with an AI assistant.
Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-24T16:41:17Z.
Following up on my count with a probe that says which missing-half case each read actually hits. The probe is local and small: a guarded
eprintln!at the one failure site (emit/lower.rs:5543, enabled by an environment variable) that prints the row, channel,highflag, the half index being asked for,pack2, the partner row, and the extent of both rows as the signature was built. Same commit (ffe310e), same copy of the package, nothing else changed. As a control I re-ran the whole pack with the probe in place: the census's own totals are byte-for-byte the same as without it (emit 3436,I/O207, resources 360, validator 162, this reason 166), so the probe is not changing what gets refused.First, a correction to my own note. The 167th line is not a wrapped report. The census ends with one line per reason, shaped
<count> <label>: <reason> (e.g. <one example program>), and that line itself matches a search for the reason text. The census publishes its own table: it states 166 for this reason, which is the figure I gave. Per-reason numbers are best read from that footer; counting lines for a reason comes out one higher for every reason.With the probe, the 166 programs make 1048 failing half-reads, and they land on exactly two of the four routes I listed:
partner = None: the metadata names no second row for that input at all. That is the case the inferred pairing in this PR and in #176 supplies.Nothing landed on the other two routes. No read asked for a half in the padding of its own row (
want >= naandwant < a_halves), no read referenced an input row missing from the built signature, and no read was the upper half of anfp16input withoutpack2. So on this package there are only two shapes, and by reads the named-but-short partner is about four times as common as the absent partner.Two limits, stated plainly. These are reads, not programs: a program makes several such reads, and the lowering has no program name in scope, so I cannot say how the 166 split between the two cases or which families sit on which side. And this is a pre-fix number. My reading of the three changes is that once this PR lands, the 220 should disappear and the 828 should be what is left standing - which would make the remaining question exactly #621's. I can measure that on the merged result the same way I did for #878 and #877, on a clean worktree, before and after.
Written with an AI assistant.
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T17:27:00Z.
Review: COMMENTED
Independent verification of
35bf153merged onto current mainffe310e(clean merge; onlycrates/victory-shader/src/emit/lower.rs, +87/−1), Windows 11, rustc 1.98.1 (x86_64-pc-windows-msvc):cargo test --locked -p victory-shader --lib, CPU-only suite skippingdiff_tests,valu_tests,waterfall_tests,stub_pipeline_is_created: 98 passed, 0 failed, 1 ignored —packed_pixel_inputs_find_their_second_rowincluded.cargo clippy --locked -p victory-shader --lib --tests -- -D warnings: clean.cargo xtask policy: 154 files ok.Code read on the merged tree:
half_input_partnersmirrors the output-sidehalf_outputsconvention — the next 16-bit signature row that no input entry names and no explicitrow2already claims, in row order — and the partner is consulted only underpack2 && row2 == row, so flat inputs and explicitly paired rows are untouched. The test's assignments (0→1, 3→4, explicit 5→6 left alone) match that rule, and @fiestorra's probe (220 partner-absent reads vs 828 named-but-short) lines up with what this PR covers versus what remains for #621.One observation, not blocking: the partner map is rebuilt per packed-half read. Signatures are small, so the cost is negligible, and caching it would complicate lifetimes for no measurable gain.
Disclosure: my #621 is stacked on this head, so I have an interest in it landing; this is still an independent check of the merge with current main, which the existing runs don't cover (Linux, macOS, or the older
7139712head).CPU-only; no GPU run, no game data. AI-assisted (Kimi).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:58Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Second rows of packed 16-bit pixel inputs: superseded by main's first-fit packing rule (packed_half in emit/lower.rs,
13091f6e), which needs no partner row.If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed