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

Open
github-bot wants to merge 1 commit from github-bot/gh-2181 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 08:09 UTC · original
0xkn0wh3r3:recomp/early-depth-before-shader → main · +117 −12 · 8 files · 1 commits · open

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 code only gains early_depth: false in 19 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.
  • On 3913c6f (rebased on main 2898511): cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1360 passed, 5 failed, 46 ignored, across every test binary (the lib's unit tests: 1281 passed, 5 failed, 26 ignored).
  • The 5 failures fail the same way on main (2898511) 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 (29): 21 GPU checks with no wave64; 3 per-lane-form checks refused by design (#1426 semantics); ir_text_assembles_signs_and_runs (no dxil.dll); pso_measurement_compiles_an_exact_synthetic_record (needs Developer Mode); the debug-layer title runs, dred off and on (no xgameruntime.dll); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

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 (3913c6f): to be rerun after the rebase onto main 2898511. The run of the pre-rebase head f0d7b14 (same title, 60 s) showed 1630 frames, no crash or device removal, 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. The pre-rebase 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.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 08:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2181) `0xkn0wh3r3:recomp/early-depth-before-shader` → `main` · +117 −12 · 8 files · 1 commits · open 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 code only gains `early_depth: false` in 19 `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`. - On 3913c6f (rebased on main 2898511): `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 1360 passed, 5 failed, 46 ignored, across every test binary (the lib's unit tests: 1281 passed, 5 failed, 26 ignored). - The 5 failures fail the same way on `main` (2898511) 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 (29): 21 GPU checks with `no wave64`; 3 per-lane-form checks refused by design (#1426 semantics); `ir_text_assembles_signs_and_runs` (no dxil.dll); `pso_measurement_compiles_an_exact_synthetic_record` (needs Developer Mode); the debug-layer title runs, dred off and on (no xgameruntime.dll); `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). **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 (3913c6f): to be rerun after the rebase onto main 2898511. The run of the pre-rebase head f0d7b14 (same title, 60 s) showed 1630 frames, no crash or device removal, 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. The pre-rebase 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:22:18 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 08:36 UTC · original

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.

**@⁠luckyteagirl** on GitHub · 2026-11-25 08:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2181#issuecomment-7157255225) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 15:39 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 15:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/2181#issuecomment-7167185413) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 08:15 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 08:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2181#issuecomment-7186372764) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/dxil/core_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2181/head:github-bot/gh-2181'
git switch 'github-bot/gh-2181'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2181'
git switch 'github-bot/gh-2181'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2181'
git switch 'github-bot/gh-2181'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2181'
git switch 'main'
git merge --squash 'github-bot/gh-2181'
git switch 'main'
git merge --ff-only 'github-bot/gh-2181'
git switch 'main'
git merge 'github-bot/gh-2181'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.