shader: compare k32UInt textures as float depth #1867

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

@⁠Nawid3333 on GitHub · 2026-10-23 17:15 UTC · original
Nawid3333:fix/k32uint-compare → main · +108 −6 · 5 files · 1 commits · open

Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) stops with (Crispy81's log in #1792):

shader resource specialization failed: sampled image descriptor 43 uses unsupported format 20: root=0 source=1 first_use_pc=0xb6c r128=false words=403d1d00,c1400000,0000c000,90900004,00000000,00700000,00000000,00000000 ...

What is wrong

The instruction at 0xb6c is image_sample_c_lz (a depth compare, as in a shadow lookup). Its T# is a 4x4 2D texture with format 20 (k32UInt) and 64 KiB standard tiling, not a depth surface. Kyty only allows compares on float textures, so the specialization fails and the game stops.

What changes

For a depth compare through a k32UInt T#, the resource now uses k32Float: in BuildResourceSpecialization (numeric class), in ImageHeapKind (image-heap entries) and in ResolveTexture (the format the texture cache sees). Expanded indirect entries such as the game's descriptor 43 of root 0 are copies of their root, so they take the same path. The texture cache then compares against the D32Sfloat copy of the memory it already makes for k32Float compares. This reuses the existing k32Float compare path; it is a choice, not confirmed hardware behaviour: I don't know what RDNA2 returns for a compare on an integer format, or what this texture holds.

Only resources with depth_compare and format k32UInt are affected (the new IR::CompareFormat). For those, image-heap entries that used to read as null now bind a D32 texture, and as for k32Float compares, the texture cache can hold a D32 image over memory that is also used as a k32UInt image. Texels whose bits are a float in [0,1] compare as that depth; other bit patterns (above 1.0 or NaN) depend on VK_EXT_depth_range_unrestricted, which Kyty enables when the device has it.

Tests

  • CheckComparisonDepthTexture gets a k32UInt case with the game's T# words 1-3 (4x4 2D, 64 KiB tiling); every texel holds the bits of 0.4f, compared against the five existing references and one equal to the texel. It checks the specialization (depth compare, float numeric class), that the texture cache makes a D32Sfloat copy with guest format k32Float, and the six compare results. The test binds the T# directly. Without the change it fails with the same kind of error as the game (sampled image descriptor 0 uses unsupported format 20, words 1-3 c1400000,0000c000,90900004); with it, it passes on an RX 9070 XT and the Ryzen 7600X iGPU (Windows 11, driver 26.8.1).
  • ResourceTrackingTests' image-heap check expected a k32UInt compare entry to read as null; it now expects the float kind, and checks with k32SInt that other integer entries still read as null.
  • The 13 ctest programs CI runs pass locally, and shader_cfg_tests passes.
  • Fork CI (Windows, Linux, macOS): https://github.com/Nawid3333/KytyPS5/actions/runs/39988770637

Not tested in the game yet: the first-launch menus need hand input I can't give here. @⁠Crispy81, could you try the Windows build of this PR with Black Flag and say where it stops now?

AI use: Claude Code wrote this change and the test with me, and checked the descriptor fields; I reviewed the diff and the test results.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-23 17:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1867) `Nawid3333:fix/k32uint-compare` → `main` · +108 −6 · 5 files · 1 commits · open Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) stops with (Crispy81's log in #1792): ``` shader resource specialization failed: sampled image descriptor 43 uses unsupported format 20: root=0 source=1 first_use_pc=0xb6c r128=false words=403d1d00,c1400000,0000c000,90900004,00000000,00700000,00000000,00000000 ... ``` **What is wrong** The instruction at 0xb6c is `image_sample_c_lz` (a depth compare, as in a shadow lookup). Its T# is a 4x4 2D texture with format 20 (k32UInt) and 64 KiB standard tiling, not a depth surface. Kyty only allows compares on float textures, so the specialization fails and the game stops. **What changes** For a depth compare through a k32UInt T#, the resource now uses k32Float: in `BuildResourceSpecialization` (numeric class), in `ImageHeapKind` (image-heap entries) and in `ResolveTexture` (the format the texture cache sees). Expanded indirect entries such as the game's descriptor 43 of root 0 are copies of their root, so they take the same path. The texture cache then compares against the D32Sfloat copy of the memory it already makes for k32Float compares. This reuses the existing k32Float compare path; it is a choice, not confirmed hardware behaviour: I don't know what RDNA2 returns for a compare on an integer format, or what this texture holds. Only resources with `depth_compare` and format k32UInt are affected (the new `IR::CompareFormat`). For those, image-heap entries that used to read as null now bind a D32 texture, and as for k32Float compares, the texture cache can hold a D32 image over memory that is also used as a k32UInt image. Texels whose bits are a float in [0,1] compare as that depth; other bit patterns (above 1.0 or NaN) depend on `VK_EXT_depth_range_unrestricted`, which Kyty enables when the device has it. **Tests** - `CheckComparisonDepthTexture` gets a k32UInt case with the game's T# words 1-3 (4x4 2D, 64 KiB tiling); every texel holds the bits of 0.4f, compared against the five existing references and one equal to the texel. It checks the specialization (depth compare, float numeric class), that the texture cache makes a D32Sfloat copy with guest format k32Float, and the six compare results. The test binds the T# directly. Without the change it fails with the same kind of error as the game (`sampled image descriptor 0 uses unsupported format 20`, words 1-3 `c1400000,0000c000,90900004`); with it, it passes on an RX 9070 XT and the Ryzen 7600X iGPU (Windows 11, driver 26.8.1). - `ResourceTrackingTests`' image-heap check expected a k32UInt compare entry to read as null; it now expects the float kind, and checks with k32SInt that other integer entries still read as null. - The 13 ctest programs CI runs pass locally, and `shader_cfg_tests` passes. - Fork CI (Windows, Linux, macOS): https://github.com/Nawid3333/KytyPS5/actions/runs/39988770637 Not tested in the game yet: the first-launch menus need hand input I can't give here. @⁠Crispy81, could you try the Windows build of this PR with Black Flag and say where it stops now? AI use: Claude Code wrote this change and the test with me, and checked the descriptor fields; I reviewed the diff and the test results. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Assassin's Creed Black Flag Resynced (PPSA28183) samples a 4x4 k32UInt texture with
IMAGE_SAMPLE_C_LZ (a shadow compare) and stopped with "sampled image descriptor 43 uses
unsupported format 20": a compare needs a float depth image. For a depth compare through a
k32UInt T#, the resource now uses k32Float (specialization, image-heap kinds and ResolveTexture),
so the texture cache compares against the D32Sfloat copy it already makes for k32Float.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:07:26 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-23 17:22 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 9dcff95e80 and b586514b38.

📒 Files selected for processing: 5
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • tests/ResourceTrackingTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

CompareFormat maps depth-comparison images with k32UInt format to k32Float. Resource classification and texture resolution use this mapping, while the depth-bits format selection remains unchanged. Tests update heap-kind expectations and add a GPU test that checks comparison results and D32 backing.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b5865

No merge-blocking issue is identified; normal validation can proceed.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the k32UInt depth-comparison failure, the implemented format handling, and the associated tests.
Title check Passed The title is concise, specific, and accurately summarizes the main change: treating k32UInt textures as float depth for comparison.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 Cppcheck (2.22.0)
tests/ResourceTrackingTests.cpp

Cppcheck timed out; analysis of this file is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-23 17:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1867#issuecomment-6370688482) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1867?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/9dcff95e809ec43ba66f56648164070f4b16348f/.coderabbit.yaml>) - **Commit**: [9dcff95](<https://github.com/KytyPS5/KytyPS5/commit/9dcff95e809ec43ba66f56648164070f4b16348f>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `51cb2280-8633-4bbe-bac4-a899e0237dd8` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 9dcff95e809ec43ba66f56648164070f4b16348f and b586514b381e23f339bd6b0d42adfb13b6f9802b. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 5</strong></summary> <dl> <dd> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `tests/ResourceTrackingTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> `CompareFormat` maps depth-comparison images with `k32UInt` format to `k32Float`. Resource classification and texture resolution use this mapping, while the depth-bits format selection remains unchanged. Tests update heap-kind expectations and add a GPU test that checks comparison results and D32 backing. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"b586514b381e23f339bd6b0d42adfb13b6f9802b" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>b5865</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `b5865` --> <!-- final_review_risk_coverage:{"sourceCommitId":"b586514b381e23f339bd6b0d42adfb13b6f9802b","coveredCommitId":"b586514b381e23f339bd6b0d42adfb13b6f9802b","kind":"reviewed"} --> No merge-blocking issue is identified; normal validation can proceed. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the k32UInt depth-comparison failure, the implemented format handling, and the associated tests. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title is concise, specific, and accurately summarizes the main change: treating k32UInt textures as float depth for comparison. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- This is an auto-generated comment: all tool run failures by coderabbit.ai --> > [!WARNING] > Some tools did not complete. Review the errors below. > > <details> > <summary><strong>🔧 Cppcheck (2.22.0)</strong></summary> > <dl> > <dd> > > <details> > <summary><strong>tests/ResourceTrackingTests.cpp</strong></summary> > <dl> > <dd> > > Cppcheck timed out; analysis of this file is incomplete > > </dd> > </dl> > </details> > > </dd> > </dl> > </details> <!-- end of auto-generated comment: all tool run failures by coderabbit.ai --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1867)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-29 05:23 UTC · original

Game test (Assassin's Creed Black Flag Resynced, PPSA28183): Crispy81 ran a build of this PR (b586514) and posted the result on #1792 (#1792).

  • Before, on 68af8de, the game stopped with sampled image descriptor 43 uses unsupported format 20 in pixel shader 0x079e2c9885c6ba38 (image_sample_c_lz at pc 0xb6c).
  • With this PR, the same shader translates (SPIR-V EmitProgram ... words=135024), his log has no specialization failure, and the game gets to the menus and the loading screen.

At the loading screen it then exits for a different reason. I reproduced that here: a stack overflow (0xC00000FD) while a compute shader is translated, in Tracker::CollectScalarRead. #1967 fixes it; with both, the game reaches the Difficulty Tuning menu of a new game.

shadPS4 makes the same choice: a compare (_C) sample marks its image as depth, and an R32_UINT image is then created as D32_SFLOAT (PromoteFormatToDepth, github.com/shadps4-emu/shadPS4@0614ce324b/src/video_core/renderer_vulkan/liverpool_to_vk.h (L136)).

**@⁠Nawid3333** on GitHub · 2026-10-29 05:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1867#issuecomment-6488724189) Game test (Assassin's Creed Black Flag Resynced, PPSA28183): Crispy81 ran a build of this PR (b586514) and posted the result on #1792 (https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1792). - Before, on 68af8de, the game stopped with `sampled image descriptor 43 uses unsupported format 20` in pixel shader 0x079e2c9885c6ba38 (`image_sample_c_lz` at pc 0xb6c). - With this PR, the same shader translates (`SPIR-V EmitProgram ... words=135024`), his log has no specialization failure, and the game gets to the menus and the loading screen. At the loading screen it then exits for a different reason. I reproduced that here: a stack overflow (`0xC00000FD`) while a compute shader is translated, in `Tracker::CollectScalarRead`. #1967 fixes it; with both, the game reaches the Difficulty Tuning menu of a new game. shadPS4 makes the same choice: a compare (`_C`) sample marks its image as depth, and an R32_UINT image is then created as D32_SFLOAT (`PromoteFormatToDepth`, https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/video_core/renderer_vulkan/liverpool_to_vk.h#L136).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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