shader: compare k32UInt textures as float depth #1867
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1867
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1867"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Nawid3333 on GitHub · 2026-10-23 17:15 UTC · original
Nawid3333:fix/k32uint-compare→main· +108 −6 · 5 files · 1 commits · openAssassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) stops with (Crispy81's log in #1792):
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), inImageHeapKind(image-heap entries) and inResolveTexture(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_compareand format k32UInt are affected (the newIR::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 onVK_EXT_depth_range_unrestricted, which Kyty enables when the device has it.Tests
CheckComparisonDepthTexturegets 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-3c1400000,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.shader_cfg_testspasses.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
@coderabbitai[bot] on GitHub · 2026-10-23 17:22 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
51cb2280-8633-4bbe-bac4-a899e0237dd8📥 Commits
Reviewing files that changed from the base of the PR and between
9dcff95e80andb586514b38.📒 Files selected for processing: 5
src/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpptests/ResourceTrackingTests.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
CompareFormatmaps depth-comparison images withk32UIntformat tok32Float. 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:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
b5865No merge-blocking issue is identified; normal validation can proceed.
Pre-merge checks:
4 ·
1
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.
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 helpto get the list of available commands.@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).sampled image descriptor 43 uses unsupported format 20in pixel shader 0x079e2c9885c6ba38 (image_sample_c_lzat pc 0xb6c).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, inTracker::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)).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.