Repository navigation
Recompiler: console pixel shaders tested depth-first keep early depth - #2181
0xkn0wh3r3 wants to merge 1 commit into
Conversation
A console pixel shader compiled with [earlydepthstencil] runs with DB_SHADER_CONTROL.DEPTH_BEFORE_SHADER (bit 12) set: depth and stencil are tested before it runs, so it runs only for pixels that pass, even when it writes memory. XCL never read the register, so the PC ran such shaders for hidden pixels too and kept their memory writes (work the console skips, and writes it never makes). DB_SHADER_CONTROL is the dword after SPI_PS_INPUT_ENA in the FSSM's PS input table (+0x114 from the table, + the sub-version shift); the same place VIctory's FSSM layout gives it. The bit is read only where the input table was recognised. Pixel shaders with it get [earlydepthstencil] on the HLSL path and ForceEarlyDepthStencil (shader flag bit 3) on the direct DXIL path, which had it hard-coded to false. DXC accepts the attribute together with an SV_Depth export. The translator's source id covers these files, so cached translations are made again.
|
Independent native Windows check of exact head Environment: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver Focused tests: Both
Scope: These are translation and shader-compiler tests. They do not create a depth-tested GPU draw or prove that hidden pixels suppress memory writes on the RX 6800M. I did not run the full workspace suite or a retail-title smoke on this branch. AI use: OpenAI Codex reviewed the changed translation paths, ran the two focused tests, checked the logs and exact revision, and prepared this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
A console pixel shader compiled with
[earlydepthstencil]runs withDB_SHADER_CONTROL.DEPTH_BEFORE_SHADER(bit 12) set, so the console tests depth and stencil before it runs and it runs only for pixels that pass, even when it writes memory. XCL never read the register: on PC such shaders ran for hidden pixels too and kept their memory writes. This reads the bit and gives those shaders early depth on both translation paths.What is in it
crates/xcl/src/gpu/recomp/mod.rs:ps_shader_controlreadsDB_SHADER_CONTROL, the dword afterSPI_PS_INPUT_ENAin the FSSM's PS input table (+0x114, plus the sub-version shift), into the newPsInterface::early_depth. It is read only whereps_input_tablerecognised the table.crates/xcl/src/gpu/recomp/emit.rs: such pixel shaders get[earlydepthstencil]onmain.crates/xcl/src/gpu/dxil/kernel.rs: the direct DXIL path passes the bit toStageInfo::Pixel(it was hard-coded tofalse), which sets ForceEarlyDepthStencil (shader flag bit 3).recomp::attribute_tests::ps_depth_before_shader_from_the_input_table(both table sub-versions, the bit alone and with other bits, no bit, no recognised table) anddxil::core_tests::early_depth_pixel_shaders_test_depth_first_on_both_paths(the HLSL attribute and the DXIL flag on both paths, with and without anSV_Depthexport; DXC accepts the two together). Both fail with the three runtime lines reverted. The other test files only gainearly_depth: falseinPsInterfaceliterals.The translator's source id covers these files, so cached translations are made again.
Tested
dxil.dll.cargo build --workspace && cargo test --workspace -- --test-threads=4: 1095 passed, 5 failed, 26 ignored.main(568e7db) on this machine:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3}(CreateComputePipelineState: out of memory, 0x8007000E, on the same seeds) andhle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory.no wave64, 3 per-lane-form checks refused by design (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics),ir_text_assembles_signs_and_runs(no dxil.dll),pso_measurement_compiles_an_exact_synthetic_record(needs Developer Mode).Regression run
Not tested
DEPTH_BEFORE_SHADERset was not checked: the regression run shows nothing broke, not that the fix takes effect. Its PR run showed more frames and a lower peak commit than themainrun, but that is one run each and is not claimed as an effect of this change.XCL_SAMPLE_*data here). It is the dword afterSPI_PS_INPUT_ENA, whose place the existing comment says was checked on three titles.runnerhas no depth-tested draw. The tests check the HLSL attribute and the DXIL flag, not the hardware's behaviour.AI use