Shaders: evaluate centroid reads with evalCentroid when mixed with center #3160
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!3160
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3160"
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?
@fuzeofficlal on GitHub · 2026-11-26 10:34 UTC · original
fuzeofficlal:fix/shader-input-center-and-centroid→main· +259 −57 · 2 files · 1 commits · openSummary
Previously,
Lower::interprejected any pixel input read with two different interpolation modes ("one input interpolated two ways"), refusing valid pixel shaders that read the same float input at both center and centroid (EvaluateAttributeAtCentroid).Fix
io.interpsinLower::plan_interp_modes(reusing extractedinterp_modeandinterp_channelshelpers).comp == 9) is read only at(PerspectiveCenter, PerspectiveCentroid)or(LinearCenter, LinearCentroid), declare its input signature element at center (2or4) and record it incentroid_inputs.dx.op.loadInput.f32for center reads anddx.op.evalCentroid.f32(opcode89) for centroid reads regardless of instruction order, while preserving single-mode lowering (including centroid-only and sample-frequency inputs) and continuing to reject incompatible mode combinations (such as perspective+linear, perspective+sample, or interpolated+flat).Verification
Added four synthetic tests in
crates/victory-shader/src/emit/mod.rscovering 32-bit and FP16 mixed center+centroid reads (in both orders), centroid-only preservation, and rejection of incompatible mixes:cargo test -p victory-shader --locked --lib emit::tests -- --test-threads=1: 21 passed, 0 failed (validated withdxil.dllanddxc -dumpbin)cargo test -p victory-shader --locked --lib emit::lower::tests -- --test-threads=1: 33 passed, 0 failedcargo test -p victory-shader --locked --lib emit::diff_tests -- --test-threads=1: 5 passed, 0 failedcargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--no-default-features): cleancargo test -p xtask --locked policy::tests::repository_passes_policy: passed (emit/lower.rs= 523,522 B < 524,288 B)@Dukestar69 on GitHub · 2026-11-26 10:49 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-shader --lib interpolation -- --test-threads=1: 9/9 passed (includingmixed_input_interpolation_center_and_centroid,mixed_input_interpolation_center_and_centroid_f16,centroid_only_interpolation_uses_load_input, andmixed_input_interpolation_incompatible_modes_fail).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly uses
evalCentroidwhen a pixel input mixes center and centroid reads while keepingloadInputfor centroid-only inputs.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@steven-seagull27 on GitHub · 2026-11-26 11:24 UTC · original
I rendered 12 mixed center/centroid variants on
5b4f321and compared each resolved RGBA32F pixel with a native HLSL shader usingEvaluateAttributeCentroidon the same adapter. All 12 matched bit for bit on the RTX 5080, Windows WARP, and WARP 1.0.22. The parent (63bcca4) refused all 12 before creating a graphics pipeline withone input interpolated two ways.The eight FP32 cases covered perspective and noperspective, both instruction orders, and the same or different channels of one attribute. The four FP16 cases covered both interpolation modes and both packing layouts, with explicit nearest-even rounding in the reference. Each 32×32 draw had 401 fully covered pixels and 72 partially covered pixels at 4× MSAA. On the RTX, for example, pixel
(1,2)had two covered samples. The resolved center and centroid channels read0.5057649and0.5169407; forcing both channels to center produced0.5057649twice.The test-only commit keeps one FP32 regression with independent native, center-only, and coverage draws. Replacing the translated centroid read with a center load made the test fail at
(1,2)on both the RTX and Windows WARP. To run it on this PR with the Windows SDK’s PC DXC:Synthetic geometry and shader inputs. AI-assisted with Codex.
@oni-swr on GitHub · 2026-11-26 11:28 UTC · original
WARP verification of #3160 at
5b4f321d(software adapter only; no physical GPU used). AI-assisted: Claude Code (Claude Sonnet 5.5).Setup. The head is one commit on top of
main63bcca4(merge-base =63bcca4); I confirmed the head SHA matches before and after testing. Windows 11 (26100), rustc/cargo 1.98.1,VICTORY_D3D12_WARP=1(WARP,d3d10warp.dll10.0.26100.9818),VICTORY_DXIL= Windows SDK 10.0.26100.0 x64dxil.dll1.8.2502.11, and the same SDK'sdxc.exe1.8.2502.11 was present, so thedump_dxilassertions in the tests ran. Every cargo command used-j 4,--locked, a separate target dir.Results
cargo test -p victory-shader --lib --locked mixed_input_interpolation -- --test-threads=1-> 3 passed (..._center_and_centroid,..._center_and_centroid_f16,..._incompatible_modes_fail).... centroid_only_interpolation-> 1 passed (centroid_only_interpolation_uses_load_input,cfg(windows)).cargo test -p victory-shader --lib --locked -- --test-threads=1-> 306 passed, 0 failed, 3 ignored. Baselinemain63bcca4, same command and environment: 302 passed, 0 failed, 3 ignored. The difference is exactly the 4 new tests; no failure to attribute.lower.rstaken from63bcca4, tests kept):mixed_input_interpolation_center_and_centroidand..._f16fail (panics atemit/mod.rs:1672and:1713); the other interpolation tests (includingcentroid_only_...and..._incompatible_modes_fail, which pin existing behaviour) still pass. So the two new behavioural tests do detect the change.Diff review. I found no concrete defect. The planning pass (
plan_interp_modes) declares a row that is read both at center and at centroid as center, and the centroid reads are then emitted asevalCentroid.f32in the entry block; perspective-sample, linear-centroid and flat mixes are still refused with the old error (covered by the third test). The tests' dump file name is now unique per call (removes a race between parallel tests on the shared temp file). Observations, not defects: inputs read inside a lowered section (asplan_interp_modesskips) still fall back to the "one input interpolated two ways" refusal, and the tests check the signature read mask and the emitted DXIL text, not rendered output.Not tested
evalCentroid; WARP's rasterizer is not a stand-in for hardware centroid sampling.victory-gpu,victory),cargo clippy,cargo fmt --check, release profile, the ignored tests.5b4f321d17tocb96b3a249@fuzeofficlal on GitHub · 2026-11-26 11:48 UTC · original
Re-pushed identical tree (
5b4f321d->cb96b3a2) to re-trigger CI after an unrelated flaky failure inframe::tests::waits_end_on_ticks_and_count_frames.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.