Shaders: PSV0 says a pixel shader runs per sample when an input does #381
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/381"
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?
Imported from Marvisak/VIctory. Originally posted by Dufftwt on 2026-11-24T02:48:21Z.
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 (#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.upstream-sync referenced this pull request2026-11-24 06:53:40 +00:00
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:19:33Z.
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.
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T07:47:15Z.
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.