Skip to content

Recompiler: console pixel shaders tested depth-first keep early depth - #2181

Open
0xkn0wh3r3 wants to merge 1 commit into
xcl-dev:mainfrom
0xkn0wh3r3:recomp/early-depth-before-shader
Open

0xkn0wh3r3 wants to merge 1 commit into
xcl-dev:mainfrom
0xkn0wh3r3:recomp/early-depth-before-shader

Conversation

@0xkn0wh3r3

@0xkn0wh3r3 0xkn0wh3r3 commented Nov 25, 2026 •

Copy link
Copy Markdown

A console pixel shader compiled with [earlydepthstencil] runs with DB_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_control reads DB_SHADER_CONTROL, the dword after SPI_PS_INPUT_ENA in the FSSM's PS input table (+0x114, plus the sub-version shift), into the new PsInterface::early_depth. It is read only where ps_input_table recognised the table.
  • crates/xcl/src/gpu/recomp/emit.rs: such pixel shaders get [earlydepthstencil] on main.
  • crates/xcl/src/gpu/dxil/kernel.rs: the direct DXIL path passes the bit to StageInfo::Pixel (it was hard-coded to false), which sets ForceEarlyDepthStencil (shader flag bit 3).
  • Tests: 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) and dxil::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 an SV_Depth export; DXC accepts the two together). Both fail with the three runtime lines reverted. The other test files only gain early_depth: false in PsInterface literals.

The translator's source id covers these files, so cached translations are made again.

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2124), AMD Ryzen 9 7900X, Windows 11 build 26300, Rust 1.90.0, debug build; DXC 1.8.2502.11 from the Windows SDK, no dxil.dll.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 1095 passed, 5 failed, 26 ignored.
  • The 5 failures fail the same way on 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) and hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory.
  • SKIPPED (25): 20 GPU checks with 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

  • main:
xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5070 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1241 (PresentX 1241)
presents per 2 s (last 3): 2 16 18
device removals: 0
crashes: 0
peak commit: 27084 MB
  • this PR's head:
xcl-smoke v1
commit: f0d7b14ff3c5016f58fdc0c4fc18602e94bc731a
gpu: NVIDIA GeForce RTX 5070 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17418 MB

Not tested

  • Whether title 419239bf has pixel shaders with DEPTH_BEFORE_SHADER set 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 the main run, but that is one run each and is not claimed as an effect of this change.
  • The +0x114 offset is not checked on real FSSMs (no XCL_SAMPLE_* data here). It is the dword after SPI_PS_INPUT_ENA, whose place the existing comment says was checked on three titles.
  • No GPU test draws behind a depth buffer: runner has no depth-tested draw. The tests check the HLSL attribute and the DXIL flag, not the hardware's behaviour.
  • AMD GPUs, wave64 GPU tests (skipped here), the retail title.

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the tests and this description.

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.
@0xkn0wh3r3
0xkn0wh3r3 marked this pull request as ready for review November 25, 2026 08:18
@luckyteagirl

Copy link
Copy Markdown

Independent native Windows check of exact head f0d7b14ff3c5016f58fdc0c4fc18602e94bc731a (base 568e7db7729c8fa6c8f0f4b32d798faaf11462bb), clean worktree.

Environment: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. I set the matching XCL_DXC_DIR and XCL_REQUIRE_GPU=wave64.

Focused tests: Both cargo test --locked -p xcl --lib -j 2 <filter> -- --test-threads=1 --show-output runs passed with 1 passed, 0 failed, 0 ignored each and no SKIPPED notices:

  • ps_depth_before_shader_from_the_input_table: verifies the DB_SHADER_CONTROL bit extraction across the table sub-versions and absent-table cases.
  • early_depth_pixel_shaders_test_depth_first_on_both_paths: validates the HLSL attribute and direct-DXIL early-depth flag with this DXC/DXIL version, including the depth-export case exercised by the test.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants