Shaders: PSV0 says a pixel shader runs per sample when an input does #381
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!381
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/381/head"
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?
@Dufftwt on GitHub · 2026-11-24 02:48 UTC · original
Dufftwt:fix/psv-sample-frequency→main· +85 −0 · 2 files · 1 commits · merged 2026-11-24 08:09 UTCWhat'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 (#181, #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.@jeremygold02 on GitHub · 2026-11-24 04:19 UTC · original
Thanks @Dufftwt for this PSV0 metadata fix. I tested head
404d7fd9bd9ee4f1d1a54eca9e8fed369ae29f83with: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.
@slint6614-dev on GitHub · 2026-11-24 07:47 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate, against maind2a4bae(emitted / validated). Windows 11, dxil.dll from SDK 10.0.26100.cargo test -p victory-shaderpasses on all four.