Shaders: accept known D3D_MIN_PRECISION signature elements #286

Open
tarcisioads wants to merge 1 commit from upstream-pr/286 into main
tarcisioads commented 2026-11-24 02:03:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T02:03:32Z.


Allow known D3D_MIN_PRECISION values (1 FLOAT_16, 2 FLOAT_2_8, 4 SINT_16, 5 UINT_16, 240 ANY_16, 241 ANY_10) at offset +28 of ISG1/OSG1/PSG1 signature rows in crates/victory-shader/src/emit/mod.rs, instead of failing with "a minimum-precision signature element".

DXBC already encodes those elements with a 32-bit ComponentType (1..=3), and DXIL SM 6.x declares them as 32-bit with MinPrecision = 0. Unknown/reserved MinPrecision values (such as 3) continue to return ShaderError::Unsupported.

Adds a unit test signature_accepts_known_min_precision_and_rejects_unknown covering all known D3D_MIN_PRECISION values and an unknown value.

Verification

  • cargo test -p victory-shader (57/57 passed on macOS; Windows dxil.dll validation not run)
  • cargo xtask policy (ok)
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/mod.rs (ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6572927861 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/286). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-24T02:03:32Z. --- Allow known `D3D_MIN_PRECISION` values (`1` `FLOAT_16`, `2` `FLOAT_2_8`, `4` `SINT_16`, `5` `UINT_16`, `240` `ANY_16`, `241` `ANY_10`) at offset `+28` of `ISG1`/`OSG1`/`PSG1` signature rows in `crates/victory-shader/src/emit/mod.rs`, instead of failing with `"a minimum-precision signature element"`. DXBC already encodes those elements with a 32-bit `ComponentType` (`1..=3`), and DXIL SM 6.x declares them as 32-bit with `MinPrecision = 0`. Unknown/reserved `MinPrecision` values (such as `3`) continue to return `ShaderError::Unsupported`. Adds a unit test `signature_accepts_known_min_precision_and_rejects_unknown` covering all known `D3D_MIN_PRECISION` values and an unknown value. ### Verification - `cargo test -p victory-shader` (57/57 passed on macOS; Windows `dxil.dll` validation not run) - `cargo xtask policy` (ok) - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/mod.rs` (ok)
jeremygold02 commented 2026-11-24 06:55:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:16:48Z.


Tested PR #286 at head 6afdb58eeb875499ff79b3f8434500894df2ace4 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 6afdb58eeb875499ff79b3f8434500894df2ace4.

  • cargo test --locked -p victory-shader signature_accepts_known_min_precision_and_rejects_unknown — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: emit::tests::signature_accepts_known_min_precision_and_rejects_unknown.

Behavior covered: Checks known D3D_MIN_PRECISION signature elements are accepted while unknown values are rejected.
Code: crates/victory-shader/src/emit/mod.rs

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121873209 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/286#issuecomment-7121873209). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:16:48Z. --- Tested PR #286 at head `6afdb58eeb875499ff79b3f8434500894df2ace4` (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at `6afdb58eeb875499ff79b3f8434500894df2ace4`. - `cargo test --locked -p victory-shader signature_accepts_known_min_precision_and_rejects_unknown` — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: emit::tests::signature_accepts_known_min_precision_and_rejects_unknown. Behavior covered: Checks known D3D_MIN_PRECISION signature elements are accepted while unknown values are rejected. Code: [crates/victory-shader/src/emit/mod.rs](https://github.com/Marvisak/VIctory/blob/6afdb58eeb875499ff79b3f8434500894df2ace4/crates/victory-shader/src/emit/mod.rs)
mercuryVM commented 2026-11-24 09:00:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:00:08Z.

Review: APPROVED


Tested 6afdb58 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed). victory translate <title exe> --validate --pipelines gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. None of these 12 has min-precision elements, so this runs on the validator only through the unit test.

  • The accepted set {1, 2, 4, 5, 240, 241} is exactly the defined D3D_MIN_PRECISION values, leaving out 3, which is reserved. Unknown values are still refused, and the message now says "unknown".
  • Treating these elements as 32-bit with MinPrecision = 0 in the emitted DXIL is consistent on both sides of an interface, since VS outputs and PS inputs go through the same signature path. A min-precision element is allowed to run at 32 bits anyway, so precision is preserved.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036305631 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/286#pullrequestreview-6036305631). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T09:00:08Z. **Review:** APPROVED --- Tested 6afdb58 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed). `victory translate <title exe> --validate --pipelines` gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. None of these 12 has min-precision elements, so this runs on the validator only through the unit test. - The accepted set {1, 2, 4, 5, 240, 241} is exactly the defined `D3D_MIN_PRECISION` values, leaving out 3, which is reserved. Unknown values are still refused, and the message now says "unknown". - Treating these elements as 32-bit with `MinPrecision = 0` in the emitted DXIL is consistent on both sides of an interface, since VS outputs and PS inputs go through the same `signature` path. A min-precision element is allowed to run at 32 bits anyway, so precision is preserved. No issues found. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 01:07:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:29:32Z.


Automated triage for the maintainers.

Needs work. signature in crates/victory-shader/src/emit/mod.rs now accepts min-precision signature elements as plain 32-bit ones (half: false); the enum values are right. The open question is how the console program passes these values: main decides 16-bit packing from the signature's component type and, for outputs, from the native program's fp16/pack2 flags (half_outputs in lower.rs). If the console compiler stores or interpolates min16 values packed, declaring them 32-bit unpacked reads or writes the wrong bits, whereas the current refusal at least fails clearly. Please add a console shader (or its translation log) with a min-precision element showing how its GFX10 code accesses it, or a round-trip test that passes dxil.dll validation and reads the right values.

CI: no check runs on the head commit.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148564430 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/286#issuecomment-7148564430). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:29:32Z. --- <!-- victory-triage v1 head=6afdb58eeb875499ff79b3f8434500894df2ace4 verdict=needs-work at=2026-11-25T00:19:34Z --> Automated triage for the maintainers. **Needs work.** `signature` in `crates/victory-shader/src/emit/mod.rs` now accepts min-precision signature elements as plain 32-bit ones (`half: false`); the enum values are right. The open question is how the console program passes these values: main decides 16-bit packing from the signature's component type and, for outputs, from the native program's `fp16`/`pack2` flags (`half_outputs` in `lower.rs`). If the console compiler stores or interpolates min16 values packed, declaring them 32-bit unpacked reads or writes the wrong bits, whereas the current refusal at least fails clearly. Please add a console shader (or its translation log) with a min-precision element showing how its GFX10 code accesses it, or a round-trip test that passes `dxil.dll` validation and reads the right values. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/286:upstream-pr/286'
git switch 'upstream-pr/286'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/286'
git switch 'upstream-pr/286'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/286'
git switch 'upstream-pr/286'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/286'
git switch 'main'
git merge --squash 'upstream-pr/286'
git switch 'main'
git merge --ff-only 'upstream-pr/286'
git switch 'main'
git merge 'upstream-pr/286'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!286
No description provided.