Repository navigation
Shaders: PSV0 says a pixel shader runs per sample when an input does - #381
Merged
Merged
Conversation
The pipeline state validation part left PSInfo.SampleFrequency at 0. DXC sets it when a pixel input is interpolated per sample (modes 6 and 7, which our lowering gives to PERSP_SAMPLE and LINEAR_SAMPLE barycentrics) or is SV_SampleIndex, and the validator compares the whole runtime info with what it derives from the module. The flag is now set for such pixel shaders.
muhammed-aksoy
pushed a commit
to muhammed-aksoy/VIctory
that referenced
this pull request
Nov 24, 2026
edsuuu
referenced
this pull request
in edsuuu/VI-BR-PORT
Nov 24, 2026
… an input does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Thanks @Dufftwt for this PSV0 metadata fix. I tested head Result: 1 passed, 0 failed (69 filtered out). The test emits a shader with sample-interpolated inputs and verifies the PSV0 sample-frequency flag. It checks container metadata generation, not pixel execution on a GPU. |
|
Measured on the full retail shader pack (26,503 containers) with
|
suirentakamura
pushed a commit
to suirentakamura/VIctory
that referenced
this pull request
Nov 24, 2026
Shaders: PSV0 says a pixel shader runs per sample when an input does
itsonlysimbo
pushed a commit
to itsonlysimbo/VIctory
that referenced
this pull request
Nov 24, 2026
Shaders: PSV0 says a pixel shader runs per sample when an input does
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
Every translated shader carries a
PSV0(pipeline state validation) part. Its runtime info for a pixel shader starts withPSInfo { DepthOutput, SampleFrequency }.container::psvsetsDepthOutput(byte 0) but always leavesSampleFrequency(byte 1) at 0.DXC sets
SampleFrequency = 1whenever a pixel shader input is interpolated per sample (interpolation mode 6LinearSampleor 7LinearNoperspectiveSample) or isSV_SampleIndex(DxilPipelineStateValidation.cpp,SetShaderProps, pixel case). Our lowering does produce such inputs: barycentrics fromPERSP_SAMPLE/LINEAR_SAMPLE(SPI_PS_INPUT_ADDRbits 0 and 3) get modes 6 and 7 (lower.rs).For those shaders the part contradicts the module:
What the fix does
For a pixel shader,
psvsetsSampleFrequencyto 1 when any input element has interpolation mode 6 or 7, or isSV_SampleIndex(semantic kind 12), as DXC does. It's 0 otherwise.How it behaves after the fix
Pixel shaders that interpolate at sample positions declare it in
PSV0, so they match what DXC would produce. Every other shader'sPSV0is byte-for-byte unchanged.Tests
The new test
sample_interpolated_inputs_set_psv_sample_frequency(inemit/mod.rs) translates a pixel shader that interpolates one input (v_interp_p1/p2_f32) twice:SPI_PS_INPUT_ADDRbit 1), whereSampleFrequencymust be 0;Where
dxil.dllis available, as on GitHub's Windows runner, the test also passes the shader through the validator, asstub_pipeline_is_createdandconstant_color_validatesalready do.I ran
cargo test --workspaceon GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml, and the shader crate's tests on Linux:dxil.dllaccepts both shaders.victory-shaderhas 70 passed, the other crates have 0 failed.main: the check fails (left: 0, right: 1). For the sample-rate shader,dxil.dllreports:--test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (Tests: victory-shader tests crash (0xC0000005) when several tests use WARP devices in parallel #181, Shaders: share and serialize WARP host operations across threads #244).Not tested: a title's sample-rate pixel shaders on a GPU.
Related: #136 and #306 edit
psv()elsewhere, and neither sets this field. This PR merges cleanly with both.