Hogwarts Legacy (PPSA01603): boot to gameplay, fix skin shading and the startup freeze #1297

Open
github-bot wants to merge 7 commits from github-bot/gh-1297 into main AGit
Owner

@⁠netwarex on GitHub · 2026-10-09 11:50 UTC · original
netwarex:boot-hogwarts-legacy-PPSA01603 → main · +377 −43 · 8 files · 7 commits · open

Hogwarts Legacy (PPSA01603, 01.000.005) stopped after the legal notice on
current main (compatibility list: "logo", issues #64 and #209). With this PR
it boots, passes the first-start screens, the main menu and character
creation, and plays the opening cutscenes and the first in-game areas.

Seven commits, one problem each, in the order the game hits them:

  1. shader: support gathers from GPU-selected image descriptor tables
  2. renderer: accept HTILE depth textures with DCC block sizes or RT swizzle
  3. texture cache: skip out-of-range image clears instead of aborting
  4. shader: apply texel offsets of image_sample_*_o instructions
  5. renderer: apply recognized uniform buffer fills on the CPU
  6. shader: share runtime-value validation while extracting a resource plan
  7. renderer: release 64 KiB blocks on guest write faults

Commits 4 to 7 are not Hogwarts-specific; they change shared paths that
other games use too.

1. Gathers from GPU-selected image tables

Symptom: fatal error right after the legal notice:
image.indirect_root == memory.resource && inst.GetOpcode() != ValueOpcode::ImageSampleRaw
in ResourceMaterialization.cpp (compute shader 0x67ae1be64bed0890).

Cause: since 7804eef, TryMakeFiniteImage turns finite GPU-selected image
descriptors into indirect images for both ImageSampleRaw and
ImageGatherRaw users, but only the sample path is materialized and emitted.

Change: the gather emitter uses the same flattened-SRT lookup as indirect
samples and switches over the candidates (per-candidate coordinate, existing
dynamic-mip switch). Indirect 1D gathers fail the shader cleanly. The check
accepts gathers and names the opcode if anything else reaches it.

2. HTILE depth textures

Symptom: after the first-start screens:
unsupported sampled depth image: resource=1 encoding=0 view=1 ... dwords=...,91b00204,00000000,00700000,002b0000,...
(64x64 D32 shadow texture, sampled with compare).

Cause: IsSupportedDepthTextureEncoding requires HTILE metadata control to
be exactly 0x280000 and tile mode kDepth. The game also sets the DCC
block-size fields (word 6 bits 15-18) and the 64 KiB render-target swizzle
(0x1b).

Change: ignore the DCC block-size bits and accept kRenderTarget as well as
kDepth. Depth textures without HTILE are already accepted with any tile
mode; the texture resolves to the host depth image that was rendered.

3. Out-of-range image clears

Symptom: the first seconds of the first in-game scene abort in
TextureCache::ClearImage (combined range check).

Cause: the colour-metadata fast-clear path issues a colour clear, per
slice, on an 8x8 D32 cube depth image (shadow cube map) that the game also
reads as a colour texture.

Change: skip a clear whose aspect, mip or layer range does not fit the
image and log the first 32 (TextureCache: skipped out-of-range clear: ...). An invalid
command buffer or a stencil-association image stays fatal. This is
deliberately conservative; a narrower fix would be to not run the colour
fast-clear for depth images at all. Happy to change it to that if you prefer.

4. Texel offsets on image samples

Symptom: skin (faces, hands) renders pale grey-white; everything else is
correct.

Cause: the SPIR-V emitter ignored the offset of image_sample*_o; only
gathers used it. UE4's checkerboard subsurface rendering stores diffuse and
specular on alternating pixels, and its recombine pass rebuilds the missing
half from four neighbours sampled with offsets. Without offsets all five
samples read the centre texel (verified with RenderDoc's shader debugger:
identical coordinates), half of the skin pixels kept raw diffuse lighting
without albedo, and TAA averaged the checkerboard into grey.

Change: Vulkan allows only constant ConstOffset on sample instructions,
so the offset is applied as coord += offset / textureSize(lod) (per
candidate for GPU-selected images; cube images unchanged). The size query
clamps the LOD to the last level and is decorated NonUniform for
runtime-selected descriptor slots, as MakeSampledImage does. Exact for
explicit-LOD and level-zero samples; implicit-LOD samples use the level-0
texel size.

5. Uniform buffer fills on the CPU

Symptom: ~15 synchronous GPU readbacks per frame from
TextureCache::MaterializeColorClear.

Cause: the game clears DCC/CMASK metadata with small compute fill shaders.
The uniform-fill fast path only handles fills that exactly cover an image, so
these ran on the GPU, left the metadata GPU-modified, and every colour target
lookup then read it back with a full GPU wait.

Change: a recognized uniform fill of plain, mapped buffer memory (no image
data overlaps, <= 4 MiB) is written to guest memory in command order
(InvalidateMemory + WriteBacking, as MaterializeColorClear does) and the
dispatch is skipped. Earlier GPU work still sees the old data because the
buffer cache uploads CPU changes at the next GPU use.

Measured: intro sequence 20.8 -> 23-24 FPS.

6. Shared validation in ExtractResourcePlan

Symptom: ~28 s freeze at frame ~469 on every launch while ~650 shaders are
prepared; picture and music stop.

Cause: ExtractResourcePlan calls ValidateRuntimeValue for every
ReadFirstLane it clones, and each call built a fresh RuntimeValidator with
fresh hash sets over heavily overlapping subgraphs (profile: hash-set inserts
and malloc/free ~40% of the GPU thread). The game's RenderThread waits for
that thread in RenderContext::UnmapMemory, which also blocked the audio
streaming thread.

Change: RuntimeValidationSession (RAII, thread-local) lets all
validations of one read-only program share one validator per value type,
which memoizes uniform verdicts per (instruction, EXEC mask) and valid
dependency verdicts. Cycles are cut as before (optimistically for dependency
checks, pessimistically for uniform checks); the validator tracks the
shallowest stack depth each cut reaches (Tarjan low-link), caches a verdict
only once its cycles are closed, and resolves pending dependency verdicts
when their cycle root finishes (kept if the root is valid, dropped if not).
A reused verdict is therefore the one a fresh validation would compute.
Clone memoizes its ReadConst/ReadFirstLane/Phi redirects. Passes that
rewrite IR do not use the session.

Measured: longest freeze 28.4 s -> 1.1 s; frame 700 after 20.6 s instead
of 51 s.

7. 64 KiB blocks on guest write faults

Symptom: in game ~64,000 write faults/s over ~13,000 distinct 4 KiB pages,
~90,000 mprotect calls/s, heavy TLB shootdowns on every core.

Change: on a write fault, release the whole aligned 64 KiB block in one
InvalidateMemory call when it is mapped, holds no GPU-modified data and no
cached image; otherwise per page as before.

Measured: write faults -> 8,000-20,000/s, TLB flushes halved or better.
In-game FPS is unchanged by this commit (~6-7 FPS in the first cave); the
remaining limit there is per-draw work on the GPU thread (~40 us x ~3,000
draws per frame, while the GPU itself needs ~33 ms per frame).

Platforms

  • Linux: built and tested (see Testing).
  • Windows and macOS: not built locally. The changes are shared code with
    no platform-specific parts. CI will need your approval to run.

Testing

  • Linux build with the CI toolchain (Ubuntu 24.04, clang, Qt 6.10.3), on
    7b9997b.
  • Unit tests built and run with these commits applied:
    resource_tracking, resource_materialization, memory_tracker,
    page_manager, scalar_provenance, shader_vertex_metadata pass;
    shader_recompiler_compute passes on an RX 7900 XTX (RADV, Mesa 26.1.6)
    except GpuTilerCpuParity (detile bytes family=4 bpe=1), which fails the
    same way on unpatched 7b9997b.
  • Note: on Linux (clang + libstdc++ 13) tests/ResourceMaterializationTests.cpp
    line 246 (indirect_descriptor.emplace()) does not compile on main,
    because the nested IndirectDescriptor is not default-constructible inside
    std::optional::emplace() there. I assigned IndirectDescriptor {} locally
    to run the suite; that edit is not part of this PR.
  • Hogwarts Legacy (PPSA01603, 01.000.005), RX 7900 XTX, Mesa 26.1.6: boot,
    first-start screens, main menu, character creation, opening cutscenes and
    the first playable area; skin shading verified against RenderDoc captures.
    No fatal errors in the log.
  • Changed lines formatted with clang-format 22.1.3, as pinned in
    .pre-commit-config.yaml.

AI use

The investigation and the changes were developed with an AI assistant
(Claude): reproducing the crashes, RenderDoc and perf analysis, writing the
patches, and drafting this description.

With own words: Hogwarts Legacy crashed before right on the Disclaimer. Now the fixes went one by one, to reach the setup screen, then to reach main menu, after game scene. Skin tones which has been adressed. Also there was an initial stuck around 28s at frame 463-464, which has been reduced to 1s. All this has been hand tested.

The FPS is still low, but now the game boots at least and usable in game.

**@⁠netwarex** on GitHub · 2026-10-09 11:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297) `netwarex:boot-hogwarts-legacy-PPSA01603` → `main` · +377 −43 · 8 files · 7 commits · open Hogwarts Legacy (PPSA01603, 01.000.005) stopped after the legal notice on current main (compatibility list: "logo", issues #64 and #209). With this PR it boots, passes the first-start screens, the main menu and character creation, and plays the opening cutscenes and the first in-game areas. Seven commits, one problem each, in the order the game hits them: 1. `shader: support gathers from GPU-selected image descriptor tables` 2. `renderer: accept HTILE depth textures with DCC block sizes or RT swizzle` 3. `texture cache: skip out-of-range image clears instead of aborting` 4. `shader: apply texel offsets of image_sample_*_o instructions` 5. `renderer: apply recognized uniform buffer fills on the CPU` 6. `shader: share runtime-value validation while extracting a resource plan` 7. `renderer: release 64 KiB blocks on guest write faults` Commits 4 to 7 are not Hogwarts-specific; they change shared paths that other games use too. ## 1. Gathers from GPU-selected image tables **Symptom:** fatal error right after the legal notice: `image.indirect_root == memory.resource && inst.GetOpcode() != ValueOpcode::ImageSampleRaw` in `ResourceMaterialization.cpp` (compute shader 0x67ae1be64bed0890). **Cause:** since 7804eef, `TryMakeFiniteImage` turns finite GPU-selected image descriptors into indirect images for both `ImageSampleRaw` and `ImageGatherRaw` users, but only the sample path is materialized and emitted. **Change:** the gather emitter uses the same flattened-SRT lookup as indirect samples and switches over the candidates (per-candidate coordinate, existing dynamic-mip switch). Indirect 1D gathers fail the shader cleanly. The check accepts gathers and names the opcode if anything else reaches it. ## 2. HTILE depth textures **Symptom:** after the first-start screens: `unsupported sampled depth image: resource=1 encoding=0 view=1 ... dwords=...,91b00204,00000000,00700000,002b0000,...` (64x64 D32 shadow texture, sampled with compare). **Cause:** `IsSupportedDepthTextureEncoding` requires HTILE metadata control to be exactly `0x280000` and tile mode `kDepth`. The game also sets the DCC block-size fields (word 6 bits 15-18) and the 64 KiB render-target swizzle (`0x1b`). **Change:** ignore the DCC block-size bits and accept `kRenderTarget` as well as `kDepth`. Depth textures without HTILE are already accepted with any tile mode; the texture resolves to the host depth image that was rendered. ## 3. Out-of-range image clears **Symptom:** the first seconds of the first in-game scene abort in `TextureCache::ClearImage` (combined range check). **Cause:** the colour-metadata fast-clear path issues a colour clear, per slice, on an 8x8 D32 cube depth image (shadow cube map) that the game also reads as a colour texture. **Change:** skip a clear whose aspect, mip or layer range does not fit the image and log the first 32 (`TextureCache: skipped out-of-range clear: ...`). An invalid command buffer or a stencil-association image stays fatal. This is deliberately conservative; a narrower fix would be to not run the colour fast-clear for depth images at all. Happy to change it to that if you prefer. ## 4. Texel offsets on image samples **Symptom:** skin (faces, hands) renders pale grey-white; everything else is correct. **Cause:** the SPIR-V emitter ignored the offset of `image_sample*_o`; only gathers used it. UE4's checkerboard subsurface rendering stores diffuse and specular on alternating pixels, and its recombine pass rebuilds the missing half from four neighbours sampled with offsets. Without offsets all five samples read the centre texel (verified with RenderDoc's shader debugger: identical coordinates), half of the skin pixels kept raw diffuse lighting without albedo, and TAA averaged the checkerboard into grey. **Change:** Vulkan allows only constant `ConstOffset` on sample instructions, so the offset is applied as `coord += offset / textureSize(lod)` (per candidate for GPU-selected images; cube images unchanged). The size query clamps the LOD to the last level and is decorated `NonUniform` for runtime-selected descriptor slots, as `MakeSampledImage` does. Exact for explicit-LOD and level-zero samples; implicit-LOD samples use the level-0 texel size. ## 5. Uniform buffer fills on the CPU **Symptom:** ~15 synchronous GPU readbacks per frame from `TextureCache::MaterializeColorClear`. **Cause:** the game clears DCC/CMASK metadata with small compute fill shaders. The uniform-fill fast path only handles fills that exactly cover an image, so these ran on the GPU, left the metadata GPU-modified, and every colour target lookup then read it back with a full GPU wait. **Change:** a recognized uniform fill of plain, mapped buffer memory (no image data overlaps, <= 4 MiB) is written to guest memory in command order (`InvalidateMemory` + `WriteBacking`, as `MaterializeColorClear` does) and the dispatch is skipped. Earlier GPU work still sees the old data because the buffer cache uploads CPU changes at the next GPU use. **Measured:** intro sequence 20.8 -> 23-24 FPS. ## 6. Shared validation in ExtractResourcePlan **Symptom:** ~28 s freeze at frame ~469 on every launch while ~650 shaders are prepared; picture and music stop. **Cause:** `ExtractResourcePlan` calls `ValidateRuntimeValue` for every `ReadFirstLane` it clones, and each call built a fresh `RuntimeValidator` with fresh hash sets over heavily overlapping subgraphs (profile: hash-set inserts and malloc/free ~40% of the GPU thread). The game's RenderThread waits for that thread in `RenderContext::UnmapMemory`, which also blocked the audio streaming thread. **Change:** `RuntimeValidationSession` (RAII, thread-local) lets all validations of one read-only program share one validator per value type, which memoizes uniform verdicts per (instruction, EXEC mask) and valid dependency verdicts. Cycles are cut as before (optimistically for dependency checks, pessimistically for uniform checks); the validator tracks the shallowest stack depth each cut reaches (Tarjan low-link), caches a verdict only once its cycles are closed, and resolves pending dependency verdicts when their cycle root finishes (kept if the root is valid, dropped if not). A reused verdict is therefore the one a fresh validation would compute. `Clone` memoizes its ReadConst/ReadFirstLane/Phi redirects. Passes that rewrite IR do not use the session. **Measured:** longest freeze 28.4 s -> 1.1 s; frame 700 after 20.6 s instead of 51 s. ## 7. 64 KiB blocks on guest write faults **Symptom:** in game ~64,000 write faults/s over ~13,000 distinct 4 KiB pages, ~90,000 mprotect calls/s, heavy TLB shootdowns on every core. **Change:** on a write fault, release the whole aligned 64 KiB block in one `InvalidateMemory` call when it is mapped, holds no GPU-modified data and no cached image; otherwise per page as before. **Measured:** write faults -> 8,000-20,000/s, TLB flushes halved or better. In-game FPS is unchanged by this commit (~6-7 FPS in the first cave); the remaining limit there is per-draw work on the GPU thread (~40 us x ~3,000 draws per frame, while the GPU itself needs ~33 ms per frame). ## Platforms - **Linux:** built and tested (see Testing). - **Windows and macOS:** not built locally. The changes are shared code with no platform-specific parts. CI will need your approval to run. ## Testing - Linux build with the CI toolchain (Ubuntu 24.04, clang, Qt 6.10.3), on 7b9997b. - Unit tests built and run with these commits applied: `resource_tracking`, `resource_materialization`, `memory_tracker`, `page_manager`, `scalar_provenance`, `shader_vertex_metadata` pass; `shader_recompiler_compute` passes on an RX 7900 XTX (RADV, Mesa 26.1.6) except `GpuTilerCpuParity` (`detile bytes family=4 bpe=1`), which fails the same way on unpatched 7b9997b. - Note: on Linux (clang + libstdc++ 13) `tests/ResourceMaterializationTests.cpp` line 246 (`indirect_descriptor.emplace()`) does not compile on main, because the nested `IndirectDescriptor` is not default-constructible inside `std::optional::emplace()` there. I assigned `IndirectDescriptor {}` locally to run the suite; that edit is not part of this PR. - Hogwarts Legacy (PPSA01603, 01.000.005), RX 7900 XTX, Mesa 26.1.6: boot, first-start screens, main menu, character creation, opening cutscenes and the first playable area; skin shading verified against RenderDoc captures. No fatal errors in the log. - Changed lines formatted with clang-format 22.1.3, as pinned in `.pre-commit-config.yaml`. ## AI use The investigation and the changes were developed with an AI assistant (Claude): reproducing the crashes, RenderDoc and perf analysis, writing the patches, and drafting this description. With own words: Hogwarts Legacy crashed before right on the Disclaimer. Now the fixes went one by one, to reach the setup screen, then to reach main menu, after game scene. Skin tones which has been adressed. Also there was an initial stuck around 28s at frame 463-464, which has been reduced to 1s. All this has been hand tested. The FPS is still low, but now the game boots at least and usable in game.
Since 7804eef the resource tracker lowers finite GPU-selected image
descriptors to an indirect image with one binding per candidate for both
ImageSampleRaw and ImageGatherRaw users, but only the sample path was
materialized and emitted. A gather on such an image hit a fatal check in
ApplyResourceSpecialization.

Emit indirect gathers like indirect samples: look up the selected
candidate through the flattened-SRT mapping and switch over the
candidates, with a per-candidate coordinate and the existing dynamic-mip
switch. Indirect 1D gathers fail the shader cleanly. The fatal check now
accepts gathers and names the opcode when another one reaches it.

Seen in Hogwarts Legacy (PPSA01603) right after the disclaimer.
IsSupportedDepthTextureEncoding required HTILE metadata control to be
exactly 0x280000 and the tile mode to be kDepth. Hogwarts Legacy samples a
64x64 D32 depth texture (shadow compare) whose descriptor also sets the
DCC block-size fields (word 6 bits 15-18, 0x2b0000) and the 64 KiB
render-target swizzle (0x1b), and the emulator exited with
"unsupported sampled depth image".

The DCC block sizes have no meaning for HTILE depth, and depth textures
without HTILE are already accepted with any tile mode: the texture
resolves to the host depth image that was rendered, so the guest swizzle
does not change what is sampled. Ignore those bits and accept
kRenderTarget as well as kDepth.
ClearImage aborted when the requested aspect, mip or layer range did not
fit the image. Hogwarts Legacy reaches it in its first in-game scene
through the colour metadata fast-clear path: a colour clear on an 8x8
D32 cube depth image (shadow cube map) that the game also reads as a
colour texture.

Skip such a clear and log it with the range and image description; an
invalid command buffer or a stencil-association image stays fatal.
The SPIR-V emitter ignored the texel offset of image samples; only
gathers used it. Vulkan accepts only constant offsets (ConstOffset) on
sample instructions, while GCN takes them from a VGPR, so the offset was
silently dropped and every sample read the centre texel.

UE4's checkerboard subsurface scattering stores diffuse and specular
lighting on alternating pixels and rebuilds the missing half from four
neighbours sampled with offsets. Without offsets all five samples hit the
same texel, half of the skin pixels kept raw diffuse lighting without
albedo, and TAA blended the result into grey skin (Hogwarts Legacy).

Add offset / textureSize(lod) to the normalized coordinate (per candidate
for GPU-selected images; cube images unchanged). Exact for explicit-LOD
and level-zero samples; implicit-LOD samples use the level-0 texel size.
Games clear DCC/CMASK metadata with small compute fill shaders. The
recompiler already recognizes uniform fills, but the fast path only
handles fills that exactly cover an image, so these ran on the GPU, left
the metadata GPU-modified, and every later colour-target lookup in
MaterializeColorClear had to read it back with a full GPU wait (~15 per
frame in Hogwarts Legacy).

When the fill targets plain buffer memory (no image data overlaps,
<= 4 MiB), write the value into guest memory in command order
(InvalidateMemory + WriteBacking, the same pattern MaterializeColorClear
uses) and skip the dispatch. GPU work recorded earlier still sees the old
data because the buffer cache uploads CPU changes at the next GPU use.

Measured in the Hogwarts Legacy intro: 20.8 -> 23-24 FPS.
ExtractResourcePlan calls ValidateRuntimeValue for every ReadFirstLane
node it clones, and each call built a fresh RuntimeValidator with fresh
hash sets. The subgraphs overlap heavily, so the same values were
revalidated thousands of times: hash-set inserts and malloc/free were
~40% of the GPU thread while Hogwarts Legacy prepared ~650 shaders, a
~28 s freeze on every launch. The game's RenderThread waits for that
thread in RenderContext::UnmapMemory, which also stalled the audio
streaming thread (music stopped).

Add RuntimeValidationSession (RAII, thread-local): while it is alive, all
validations of one read-only program share a validator that memoizes
uniform verdicts per (instruction, EXEC mask). Verdicts reached through a
cycle cut-off are not cached. Clone also memoizes its ReadConst,
ReadFirstLane and Phi redirects. Passes that rewrite IR do not use the
session.

Measured: longest freeze 28.4 s -> 1.0 s.
Games rewrite large heaps every frame, a few 4 KiB pages per 64 KiB block
at a time. KytyPS5 re-arms write protection per page after each upload,
so every page faults again individually: in Hogwarts Legacy ~64,000 write
faults/s over ~13,000 pages, each a signal, an mprotect and a TLB
shootdown on every core.

On a write fault, release the whole aligned 64 KiB block in one
InvalidateMemory call when it is mapped, holds no GPU-modified data and
no cached image; otherwise invalidate the faulting page as before.
Released neighbours are only uploaded unchanged at the next sync.

Measured: write faults 64,000 -> 8,000-19,000/s, TLB flushes /2 to /4.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:52:02 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 11:56 UTC · original · edited 2026-10-09 12:56 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae8e5bfb-c600-4d70-80cc-4ea405e235be

📥 Commits

Reviewing files that changed from the base of the PR and between c8f9d77f0e310ccf87821939e72191c3db67c109 and 90e8c1fec2.


📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/cache/textureCache.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

Walkthrough

The renderer changes adjust depth metadata checks, invalid image-clear handling, eligible CPU buffer fills, and write-fault cache invalidation. The shader changes add non-cube sample offsets and indirect gather emission. The runtime validation changes add per-thread validation sessions, cycle-aware verdict caching, instruction-result reuse, and support for indirect images used by raw gathers.

Suggested reviewers: nmzik


Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 90e8c

Out-of-range base-mip clears are skipped rather than aborting. No actionable merge-blocking risk remains from the reviewed changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the primary outcomes: booting Hogwarts Legacy to gameplay, fixing skin shading, and reducing the startup freeze.
Description check Passed The description directly explains the seven changes, their symptoms, causes, testing, and reported results for the Hogwarts Legacy compatibility fix.
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.


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

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-09 11:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297#issuecomment-6080360267) · edited 2026-10-09 12:56 UTC <!-- 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/1297?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `ae8e5bfb-c600-4d70-80cc-4ea405e235be` <hr> </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between c8f9d77f0e310ccf87821939e72191c3db67c109 and 90e8c1fec227ca1747c7385cad94f8fbc7e4cd32. <hr> </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` <hr> </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. <hr> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The renderer changes adjust depth metadata checks, invalid image-clear handling, eligible CPU buffer fills, and write-fault cache invalidation. The shader changes add non-cube sample offsets and indirect gather emission. The runtime validation changes add per-thread validation sessions, cycle-aware verdict caching, instruction-result reuse, and support for indirect images used by raw gathers. **Suggested reviewers:** `nmzik` <hr> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"90e8c1fec227ca1747c7385cad94f8fbc7e4cd32" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `90e8c` <!-- final_review_risk_coverage:{"sourceCommitId":"90e8c1fec227ca1747c7385cad94f8fbc7e4cd32","coveredCommitId":"90e8c1fec227ca1747c7385cad94f8fbc7e4cd32","kind":"reviewed"} --> Out-of-range base-mip clears are skipped rather than aborting. No actionable merge-blocking risk remains from the reviewed changes. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 8 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly summarizes the primary outcomes: booting Hogwarts Legacy to gameplay, fixing skin shading, and reducing the startup freeze. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the seven changes, their symptoms, causes, testing, and reported results for the Hogwarts Legacy compatibility fix. | | 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. | <hr> </details> <hr> </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 --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1297)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) <hr> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 11:56 UTC · original
On src/graphics/host_gpu/renderer/cache/textureCache.cpp line 1606 (outdated):

@@ -1599,11 +1602,31 @@ void TextureCache::ClearImage(CommandBuffer& command, ImageId id, vk::Format for
 	const auto layers = image.info.IsVolume()
 	                        ? std::max(image.info.extent.depth >> range.baseMipLevel, 1u)
 	                        : image.backing.layers;
-	EXIT_IF(command.IsInvalid() || image.depth_id || !range.aspectMask || range.levelCount == 0 ||
-	        range.levelCount > image.info.resources.levels - range.baseMipLevel ||
-	        range.layerCount == 0 || range.baseArrayLayer >= layers ||
-	        range.layerCount > layers - range.baseArrayLayer ||
-	        (range.aspectMask & aspects) != range.aspectMask);
+	EXIT_IF(command.IsInvalid() || image.depth_id);
+	if (!range.aspectMask || range.levelCount == 0 ||

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Include the base mip in the skipped-clear check.

Line 1601 still calls EXIT_IF when range.baseMipLevel >= image.info.resources.levels. An out-of-range base mip therefore aborts before the new diagnostic and return path runs. Move that check into the skip condition. Check the base mip before subtracting it from resources.levels.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 11:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297#discussion_r4229827854) On `src/graphics/host_gpu/renderer/cache/textureCache.cpp` line 1606 (outdated): ```diff @@ -1599,11 +1602,31 @@ void TextureCache::ClearImage(CommandBuffer& command, ImageId id, vk::Format for const auto layers = image.info.IsVolume() ? std::max(image.info.extent.depth >> range.baseMipLevel, 1u) : image.backing.layers; - EXIT_IF(command.IsInvalid() || image.depth_id || !range.aspectMask || range.levelCount == 0 || - range.levelCount > image.info.resources.levels - range.baseMipLevel || - range.layerCount == 0 || range.baseArrayLayer >= layers || - range.layerCount > layers - range.baseArrayLayer || - (range.aspectMask & aspects) != range.aspectMask); + EXIT_IF(command.IsInvalid() || image.depth_id); + if (!range.aspectMask || range.levelCount == 0 || ``` **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** **Include the base mip in the skipped-clear check.** Line 1601 still calls `EXIT_IF` when `range.baseMipLevel >= image.info.resources.levels`. An out-of-range base mip therefore aborts before the new diagnostic and return path runs. Move that check into the skip condition. Check the base mip before subtracting it from `resources.levels`. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d6263e3ed37986cf2b0a6bc2 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 11:56 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66fa6bf8-d5dc-4937-aa8d-08423d6d5766
📥 Commits

Reviewing files that changed from the base of the PR and between 7b9997baea and c8f9d77f0e310ccf87821939e72191c3db67c109.

📒 Files selected for processing (8)
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 11:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297#pullrequestreview-5469686915) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `66fa6bf8-d5dc-4937-aa8d-08423d6d5766` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7b9997baea0d385e9e8fc2bd3abeb02110bc4148 and c8f9d77f0e310ccf87821939e72191c3db67c109. </details> <details> <summary>📒 Files selected for processing (8)</summary> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/renderCompute.cpp` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.h` </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. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=7e253314-7405-422f-afad-8589a5c168d0 attempt=8845134b-369a-45cd-8ff4-58f3042a6128 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-11 16:58 UTC · original · edited 2026-10-11 17:05 UTC

@⁠netwarex Thanks for contribution. Credited & pushed changes to main. I'll try to find general solution for 145ba3e1d1. Dont close PR

984cfcebd1 df0412afb5 f28c0fccb2 4c87dbebb2

**@⁠Nmzik** on GitHub · 2026-10-11 16:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297#issuecomment-6111433659) · edited 2026-10-11 17:05 UTC @⁠netwarex Thanks for contribution. Credited & pushed changes to main. I'll try to find general solution for 145ba3e1d1b9f707765d771594fc64fc1c83d1ff. Dont close PR 984cfcebd141b211aa9e0a8cde63b0ebe652d07a df0412afb510213be45021ce4d3e73fd91085643 f28c0fccb22fd6b323a0d9dc7265dc3f6da092c1 4c87dbebb2cd58d402b1eda55c051b4e5fea3aba
Author
Owner

@⁠netwarex on GitHub · 2026-10-14 12:53 UTC · original

@⁠Nmzik Thanks! I have tested. I have a stuck which as been fixed with my commits, and research showing this:

On main 9e41d83, Hogwarts Legacy (PPSA01603) stalls for 1+ minute around frame 513–556 while compiling a compute shader. 1cfb952 did not stall there.

The GPU thread is stuck in:

FoldWorklist::QueueUsers
ConstantPropagationPass
TranslateProgram
ProgramCache::Get<ShaderComputeInputInfo>
RenderExecutor::DispatchDirect
CommandProcessor::DispatchDirect

Since df08b83, each fold that changes an instruction re-queues the full transitive closure of its users, so the pass becomes roughly quadratic on large UE4 compute shaders.

As a local test I folded each instruction once again, as before df08b83: no re-queue after a change, and none in the PHI normalization loop. With that, the stall is gone and the game continues normally. That drops the late folds df08b83 added, so I'm not proposing it as the fix. Could the re-queue be limited to direct users, or to a small depth for the nested pattern folds?

**@⁠netwarex** on GitHub · 2026-10-14 12:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1297#issuecomment-6168801458) @⁠Nmzik Thanks! I have tested. I have a stuck which as been fixed with my commits, and research showing this: On main 9e41d83, Hogwarts Legacy (PPSA01603) stalls for 1+ minute around frame 513–556 while compiling a compute shader. 1cfb952 did not stall there. The GPU thread is stuck in: ``` FoldWorklist::QueueUsers ConstantPropagationPass TranslateProgram ProgramCache::Get<ShaderComputeInputInfo> RenderExecutor::DispatchDirect CommandProcessor::DispatchDirect ``` Since df08b83, each fold that changes an instruction re-queues the full transitive closure of its users, so the pass becomes roughly quadratic on large UE4 compute shaders. As a local test I folded each instruction once again, as before df08b83: no re-queue after a change, and none in the PHI normalization loop. With that, the stall is gone and the game continues normally. That drops the late folds df08b83 added, so I'm not proposing it as the fix. Could the re-queue be limited to direct users, or to a small depth for the nested pattern folds?
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h
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/1297/head:github-bot/gh-1297'
git switch 'github-bot/gh-1297'

Merge

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