Repository navigation
feat(shader): add opt-in perspective-center barycentric inputs - #281
jeremygold02 wants to merge 1 commit into
Conversation
Emit the D3D barycentric system value when a perspective-center register reaches an effect. Gate the D3D vertex-order model behind a build feature while native ordering is investigated. Refs: Marvisak#97
|
Tested PR #281 at head
Behavior covered: Checks feature-gated perspective-center barycentric input is emitted only when a live center read exists. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested d9bbff5 on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 70 passed, both by default and with --features experimental-barycentrics, including direct_pixel_barycentrics_require_a_live_perspective_center_read. cargo clippy -p victory-shader --all-targets is clean. victory translate --validate --pipelines on the local title executable reports 12 of 12 programs, the same as main, so default builds are unchanged.
- The default build can't change behaviour.
Val::Missing(DIRECT_CENTER)is only produced in thecfg!(feature = "experimental-barycentrics")arm, so the retry branch inloweris unreachable without the feature, and a perspective-centre read still fails as before. - With the feature,
SV_Barycentricsis added, andBARYCENTRICSset in the flags and SFI0, only when a direct I/J read reaches a live effect. An unused read doesn't force the capability. The test checks both cases through SFI0. - As the Cargo comment says, D3D's vertex order versus the console's possibly rotated order is the open risk, so keeping it opt-in is right.
AI-assisted (Claude Code).
…center barycentric inputs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Closing because another open pull request covers the same change. See #453. Draft: raw I/J reads as SV_Barycentrics.yz behind a new Cargo feature, with an assumed vertex order. #453 does the same and more without a feature; and the three pixel programs main still refuses for 'barycentrics read directly' are overwritten registers (#457), not real reads. 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. |
What changes
A live read of the GFX10 perspective-center I or J register currently stops pixel-shader translation. With the new
victory-shader/experimental-barycentricsCargo feature, the emitter can assign the native triangle vertices D3D primitive order and loadSV_Barycentrics.yz. This emits the unpacked float3 input, the DXIL entry-point flag and the separate SFI0 capability bit. The emitter retries with that input only if a direct read reaches an effect. An unused read and ordinary paired interpolation keep their previous requirements.Why this is a draft
The chosen vertex order is explicit and opt-in. D3D defines barycentric component order in the API primitive, including odd triangles in a strip. AMD's raw I/J order can rotate relative to those vertices. The synthetic draw below verifies the D3D-order experiment. Matching the console's vertex order, or proving a given consumer is invariant to the permutation, is still open. D3D ordering · AMD raw-coordinate ordering
Local verification
Compared with main at
d2a4baeon Windows 11 and an RTX 5070.(0.26195815, 0.24601395, 0, 1)at the sampled pixel after fence completion. The CPU reference was(0.2619579, 0.24601403, 0, 1). A paired-interpolation control produced byte-identical validated DXIL in both builds.calculateLODon 2D-array textures. With the feature enabled, all three failed SDK validation. Applying only the spatial-coordinate hunk from #136 at8ae232fmade the same three pass (0/3 to 3/3). Compute and mesh totals were identical. This comparison ran on the CPU.cargo test -p victory-shader --lib direct_pixel_barycentricspasses with the feature off and on. The test covers a live center export, a dead read, rejection of the linear-center case, the SFI0 bit, and the input signature. The wider library run passed 59 tests in each configuration, with the WARP and differential GPU suites excluded. Shader formatting and Clippy passed.To build the executable with this experiment, use
cargo build -p victory --features victory-shader/experimental-barycentrics.Refs #97. Related signature work is in #136.