renderer: ignore inactive stencil registers for depth-only targets #425

Manually merged
github merged 1 commit from gh-pr/425/head into gh-pr/425/base 2026-11-26 09:20:13 +00:00
Owner

@⁠Techx3 on GitHub · 2026-08-31 13:06 UTC · original
Techx3:techx3/depth-only-inactive-stencil → main · +22 −15 · 3 files · 1 commits · merged 2026-08-31 18:39 UTC

Summary

Treat DB_STENCIL_INFO.format == kInvalid as the absence of a stencil plane when resolving a depth-only attachment. Retained stencil base addresses, Hi-Stencil compatibility and valid texture-compatibility state must not create a stencil attachment or abort a depth-only draw.

This is general register-state handling, not a Bendy-specific workaround: there are no game IDs, shader hashes or lighting changes. The present-stencil branch is unchanged; missing or misaligned stencil backing, mismatched writable bases and invalid compression combinations remain fatal. Invalid register encodings and depth-address validation remain checked too.

The existing lowering already masks stencil testing, clears, guest ranges, Vulkan aspects and compressed-stencil metadata when the stencil format is invalid. The change removes the contradictory rejection of residual fields and retains a one-time diagnostic.

Public reference: AMD PAL's DepthStencilView::WriteCommandsCommon disables stencil by setting its format to zero for depth-only usage without clearing the other stencil state.

Validation

  • Built the isolated Release emulator and test executable on Windows with clang-cl.
  • Before the renderer change, the new fixture reproduced the exact stencil state without an active stencil attachment fatal (exit 321).
  • After the change: 13/13 focused CTests pass (7 new depth/stencil tests plus image-view, storage/sampled, depth-readback footprint, HTile-clear, scheduler and command-lane regressions).
  • Positive Vulkan fixture: 32 inactive-state combinations + 2 active-stencil cases pass, including actual D16/D32F depth clear/readback. Repeated successfully with VK_LAYER_KHRONOS_validation; no Vulkan validation errors reported.
  • All six negative cases check both the precise fatal diagnostic and exit status; they do not accept arbitrary crashes.
  • Initial runs encountered guest-memory reservation failures while another emulator was open. The complete passing rerun was performed with that session closed; no memory settings or product allocation behavior changed.
  • git diff --check passes. Full-game and non-Windows runtime compatibility are not claimed.

The added tests cover D16/D32F, HTile on/off, all combinations of stale stencil addresses/Hi-Stencil/texture-compatibility state, real Vulkan depth clears/readback, valid active stencil, and exact fatal guards for invalid active stencil/depth states.

Scope

Independent branch from official main, not stacked on the lighting changes in #423 or #424. Their isolated Bendy startup attempts stopped at the check corrected here. Full-game compatibility is not claimed.

No Inspector, diagnostic tooling, captured game shaders, SDK files, HDR display presentation, FSR, import stubs or unrelated renderer/shader changes.

**@⁠Techx3** on GitHub · 2026-08-31 13:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/425) `Techx3:techx3/depth-only-inactive-stencil` → `main` · +22 −15 · 3 files · 1 commits · merged 2026-08-31 18:39 UTC ## Summary Treat `DB_STENCIL_INFO.format == kInvalid` as the absence of a stencil plane when resolving a depth-only attachment. Retained stencil base addresses, Hi-Stencil compatibility and valid texture-compatibility state must not create a stencil attachment or abort a depth-only draw. This is general register-state handling, not a Bendy-specific workaround: there are no game IDs, shader hashes or lighting changes. The present-stencil branch is unchanged; missing or misaligned stencil backing, mismatched writable bases and invalid compression combinations remain fatal. Invalid register encodings and depth-address validation remain checked too. The existing lowering already masks stencil testing, clears, guest ranges, Vulkan aspects and compressed-stencil metadata when the stencil format is invalid. The change removes the contradictory rejection of residual fields and retains a one-time diagnostic. Public reference: AMD PAL's [DepthStencilView::WriteCommandsCommon](https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/hw/gfxip/gfx9/gfx9DepthStencilView.cpp) disables stencil by setting its format to zero for depth-only usage without clearing the other stencil state. ## Validation - Built the isolated Release emulator and test executable on Windows with clang-cl. - Before the renderer change, the new fixture reproduced the exact `stencil state without an active stencil attachment` fatal (exit 321). - After the change: **13/13 focused CTests pass** (7 new depth/stencil tests plus image-view, storage/sampled, depth-readback footprint, HTile-clear, scheduler and command-lane regressions). - Positive Vulkan fixture: **32 inactive-state combinations + 2 active-stencil cases pass**, including actual D16/D32F depth clear/readback. Repeated successfully with `VK_LAYER_KHRONOS_validation`; no Vulkan validation errors reported. - All six negative cases check both the precise fatal diagnostic and exit status; they do not accept arbitrary crashes. - Initial runs encountered guest-memory reservation failures while another emulator was open. The complete passing rerun was performed with that session closed; no memory settings or product allocation behavior changed. - `git diff --check` passes. Full-game and non-Windows runtime compatibility are not claimed. The added tests cover D16/D32F, HTile on/off, all combinations of stale stencil addresses/Hi-Stencil/texture-compatibility state, real Vulkan depth clears/readback, valid active stencil, and exact fatal guards for invalid active stencil/depth states. ## Scope Independent branch from official `main`, not stacked on the lighting changes in #423 or #424. Their isolated Bendy startup attempts stopped at the check corrected here. Full-game compatibility is not claimed. No Inspector, diagnostic tooling, captured game shaders, SDK files, HDR display presentation, FSR, import stubs or unrelated renderer/shader changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:20:12 +00:00
github manually merged commit d16f0612aa into gh-pr/425/base 2026-11-26 09:20:13 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.