graphics: bind GPU-indexed T# tables as sampled image arrays #1257

Closed
github-bot wants to merge 1 commit from gh-pr/1257/head into gh-pr/1257/base
Owner

@⁠TheCruZ on GitHub · 2026-10-08 20:49 UTC · original
pr/bindless-image-tables → main · +979 −117 · 27 files · 1 commits · closed without merging

Summary

Makes the ray-hit shading compute shader of Grand Theft Auto V (PPSA04263) in Fidelity mode (ray tracing) supported: cs 0xc6c91cf1882cdc3b samples material textures whose T#s it reads from a 65536-entry descriptor heap at an index taken from GPU-written material records. With the current image-table lookup it fails with sampled image descriptor 9813 uses unsupported format 60, and the ray-traced reflections and shadows cannot be shaded.

Problem

Indirect images could only probe host-readable material keys and bind at most 64 candidates through a switch. Upstream cd066010 replaced that probing with a direct image-table lookup that makes every distinct T# of a bounded table its own specialized image. On GTA V's ray tracing heaps that lookup took ~9800 table words as candidate T#s, some of which are not images the root's view can read, and failed.

Change

Resource tracking. When the key is not a probeable material word, the table itself is kept (also through a masked table offset, and when several image instructions share one T# load). Scalar 32-byte T# tables that are not indexed by the workgroup, including those whose key is a plain material word (the four roots of c6c9 that used to probe their keys), take this table path; the direct lookup keeps the other tables.

Materialization. The table is read, its valid T#s are deduplicated into slots (reused while the table is unchanged), and an entry-to-slot mapping is appended to the flattened SRT. The slots follow the resources of the root's image binding, sized to a power-of-two capacity.

Shader. The shader computes entry = key & mask, loads its slot and samples the element of a sampled image array with NonUniform indexing (shaderSampledImageArrayNonUniformIndexing and shaderSampledImageArrayDynamicIndexing are enabled when available).

Host binding. Each slot is resolved through the texture cache; T#s the root's view cannot read, or whose guest memory is gone, bind null images. Slot resolution runs under a new Common::SoftExitScope, which turns a fatal error of the current thread into a Common::SoftExitError, so a T# the texture cache cannot use binds a null image instead of terminating (WriteBacking is no longer noexcept, so its failure reaches the scope too). A pipeline whose sampled images exceed the device's per-set or per-stage limits or the descriptor pool's budget exits with a message instead of creating an invalid layout. Table elements resolve through TextureCache::FindImageSpeculative, which declines depth/color recreations (a few heap T#s alias depth buffers the frame renders to, and converting them cost two recreations per frame). Elements whose image an earlier rebind replaced are rediscovered before their views are acquired.

Cost. The shader binds five roots of 4096 elements each; resolving all of them on every dispatch took 17% of the GPU thread. RenderExecutor keeps each element's resolution by T#, shared by roots with the same view, and resolves it again only when an image overlapping its memory was registered or unregistered (a per-page epoch in the texture cache, plus a global image-set epoch that skips the per-range check while no image changed), when the guest backing changed (new kernel BackingEpoch), or always when it has DCC metadata. Elements declined by the texture cache are revalidated against the guest range the lookup examined. A table element whose memory is not readable on the guest side is still accepted when a GPU-written image covers it (TextureCache::IsRegionGpuModified).

Relation to #811, #852 and #1118

Those PRs generalize the indirect image planner (address-backed tables, bounded and mixed candidates, more table shapes) while keeping one specialized image per candidate T#. This PR adds a different binding for large GPU-indexed T# tables (a sampled image array indexed per lane), so it touches the same planner code in ResourceTracking.cpp and will likely conflict textually with them; I can rebase on whichever lands first.

Testing

  • Grand Theft Auto V (PPSA04263), Fidelity mode: cs 0xc6c91cf1882cdc3b runs and ray-traced reflections are shaded; played in my fork with this change (together with my other Fidelity fixes, e.g. #931).
  • resource_tracking_tests: new TestBindlessImageTable case; passes.
  • shader_recompiler_compute_tests: CheckImageSamplerSpecialization now expects GPU-selected material T#s to bind the T# table (one image table whose mapping covers every entry) and compiles and validates the resulting SPIR-V. The default run and --indirect-image-only pass.
  • resource_materialization_tests, memory_tracker_tests, page_manager_tests, shader_cfg_tests and virtual_memory_allocation_tests pass.
  • Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090.

AI usage

AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my GTA V fork, i will be bringing PRs here after test them enough.

**@⁠TheCruZ** on GitHub · 2026-10-08 20:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257) `pr/bindless-image-tables` → `main` · +979 −117 · 27 files · 1 commits · closed without merging ## Summary Makes the ray-hit shading compute shader of Grand Theft Auto V (PPSA04263) in Fidelity mode (ray tracing) supported: `cs 0xc6c91cf1882cdc3b` samples material textures whose T#s it reads from a 65536-entry descriptor heap at an index taken from GPU-written material records. With the current image-table lookup it fails with `sampled image descriptor 9813 uses unsupported format 60`, and the ray-traced reflections and shadows cannot be shaded. ## Problem Indirect images could only probe host-readable material keys and bind at most 64 candidates through a switch. Upstream cd066010 replaced that probing with a direct image-table lookup that makes every distinct T# of a bounded table its own specialized image. On GTA V's ray tracing heaps that lookup took ~9800 table words as candidate T#s, some of which are not images the root's view can read, and failed. ## Change **Resource tracking.** When the key is not a probeable material word, the table itself is kept (also through a masked table offset, and when several image instructions share one T# load). Scalar 32-byte T# tables that are not indexed by the workgroup, including those whose key is a plain material word (the four roots of c6c9 that used to probe their keys), take this table path; the direct lookup keeps the other tables. **Materialization.** The table is read, its valid T#s are deduplicated into slots (reused while the table is unchanged), and an entry-to-slot mapping is appended to the flattened SRT. The slots follow the resources of the root's image binding, sized to a power-of-two capacity. **Shader.** The shader computes `entry = key & mask`, loads its slot and samples the element of a sampled image array with `NonUniform` indexing (`shaderSampledImageArrayNonUniformIndexing` and `shaderSampledImageArrayDynamicIndexing` are enabled when available). **Host binding.** Each slot is resolved through the texture cache; T#s the root's view cannot read, or whose guest memory is gone, bind null images. Slot resolution runs under a new `Common::SoftExitScope`, which turns a fatal error of the current thread into a `Common::SoftExitError`, so a T# the texture cache cannot use binds a null image instead of terminating (`WriteBacking` is no longer `noexcept`, so its failure reaches the scope too). A pipeline whose sampled images exceed the device's per-set or per-stage limits or the descriptor pool's budget exits with a message instead of creating an invalid layout. Table elements resolve through `TextureCache::FindImageSpeculative`, which declines depth/color recreations (a few heap T#s alias depth buffers the frame renders to, and converting them cost two recreations per frame). Elements whose image an earlier rebind replaced are rediscovered before their views are acquired. **Cost.** The shader binds five roots of 4096 elements each; resolving all of them on every dispatch took 17% of the GPU thread. `RenderExecutor` keeps each element's resolution by T#, shared by roots with the same view, and resolves it again only when an image overlapping its memory was registered or unregistered (a per-page epoch in the texture cache, plus a global image-set epoch that skips the per-range check while no image changed), when the guest backing changed (new kernel `BackingEpoch`), or always when it has DCC metadata. Elements declined by the texture cache are revalidated against the guest range the lookup examined. A table element whose memory is not readable on the guest side is still accepted when a GPU-written image covers it (`TextureCache::IsRegionGpuModified`). ## Relation to #811, #852 and #1118 Those PRs generalize the indirect image planner (address-backed tables, bounded and mixed candidates, more table shapes) while keeping one specialized image per candidate T#. This PR adds a different binding for large GPU-indexed T# tables (a sampled image array indexed per lane), so it touches the same planner code in `ResourceTracking.cpp` and will likely conflict textually with them; I can rebase on whichever lands first. ## Testing - Grand Theft Auto V (PPSA04263), Fidelity mode: `cs 0xc6c91cf1882cdc3b` runs and ray-traced reflections are shaded; played in my fork with this change (together with my other Fidelity fixes, e.g. #931). - `resource_tracking_tests`: new `TestBindlessImageTable` case; passes. - `shader_recompiler_compute_tests`: `CheckImageSamplerSpecialization` now expects GPU-selected material T#s to bind the T# table (one image table whose mapping covers every entry) and compiles and validates the resulting SPIR-V. The default run and `--indirect-image-only` pass. - `resource_materialization_tests`, `memory_tracker_tests`, `page_manager_tests`, `shader_cfg_tests` and `virtual_memory_allocation_tests` pass. - Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090. ## AI usage AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my [GTA V fork](https://github.com/TheCruZ/KytyPS5-GTA), i will be bringing PRs here after test them enough.
GTA V (PPSA04263) CS 0xc6c91cf1882cdc3b shades ray hits by sampling
material textures whose T#s it reads from a 65536-entry descriptor heap
at an index taken from GPU-written material records. Indirect images
could only probe host-readable material keys and bind at most 64
candidates through a switch, so the shader was unsupported.

When the key is not a probeable material word, resource tracking now
keeps the table itself (also through a masked table offset, and when
several image instructions share one T# load). Materialization reads
the table, deduplicates its valid T#s into slots (reusing them while
the table is unchanged) and appends an entry-to-slot mapping to the
flattened SRT. The slots follow the resources of the root's image
binding, sized to a power-of-two capacity; the shader computes entry
= key & mask, loads its slot and samples the element with NonUniform
indexing. The host resolves each slot through the texture cache and
binds T#s the root's view cannot read, or whose guest memory is gone,
as null images. A pipeline whose sampled images exceed the device's
per-set or per-stage limits or the descriptor pool exits with a message
instead of creating an invalid layout.

Slot resolution runs under a Common::SoftExitScope, which turns a fatal
error of the current thread into a Common::SoftExitError, so a T# the
texture cache cannot use binds a null image instead of terminating
(WriteBacking is no longer noexcept, so its failure reaches the scope
too). Table elements resolve through TextureCache::FindImageSpeculative,
which declines depth/color recreations (a few heap T#s alias depth
buffers the frame renders to, and converting them cost two recreations
per frame).

The shader binds five roots of 4096 elements each; resolving all of them
on every dispatch took 17% of the GPU thread. RenderExecutor keeps each
element's resolution by T#, shared by roots with the same view, and
resolves it again only when an image overlapping its memory was
registered or unregistered (a per-page epoch in the texture cache, and a
global image-set epoch that skips the per-range check while no image
changed), when the guest backing changed (kernel BackingEpoch), or
always when it has DCC metadata. Elements declined by the texture cache
are revalidated against the guest range the lookup examined. The table
words are read into a reused buffer.

Upstream (cd066010) replaced the probing of material keys with a direct
image-table lookup that makes every distinct T# of a bounded table its own
specialized image. On GTA V's ray tracing heaps it took ~9800 table words
for candidate T#s and failed ("sampled image descriptor 9813 uses
unsupported format 60"). Scalar 32-byte T# tables that are not indexed by
the workgroup, including those whose key is a plain material word (the
four roots of c6c9 that used to probe their keys), take the table path
above; the direct lookup keeps the other tables.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:50:20 +00:00
github-bot closed this pull request 2026-11-26 09:50:20 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 20:55 UTC · original · edited 2026-10-08 21:41 UTC

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b578908-39ed-4bfa-bc5a-36d397b6d591
📥 Commits

Reviewing files that changed from the base of the PR and between 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 and 4d0b7f2acd.

📒 Files selected for processing (5)
  • src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptorHeap.h
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/kernel/memory.cpp
  • src/kernel/memory.h
📝 Walkthrough

Walkthrough

The change adds bindless image-table tracking and materialization, then uses table mappings to select sampled-image descriptors at runtime. The renderer resolves and caches table images, with image and backing epochs used for refresh checks. Speculative texture lookup can reject depth-overlap candidates. The change also adds soft-exit exceptions, backing-readability checks, and supported Vulkan sampled-image array indexing features.

Suggested reviewers: nmzik, senaxx, claxten10

Priority: ➖ Normal

Change: Feature

Merge Risk: 🟡 Moderate · up to 1d3a5

The new bindless texture-table path can fail pipeline creation on GPUs with lower sampled-image limits. A failed lookup can also leave the texture cache in an inconsistent state. Both should be fixed or explicitly accepted before merging.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 12.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 22 files. (3 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: binding GPU-indexed T# tables as sampled image arrays.
Description check ✅ Passed The description is directly related to the changeset. It explains the GPU-indexed T# table problem, resource tracking, shader indexing, host binding, caching, testing, and expected GTA V support.
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 22 files. (3 skipped: 2 unsupported, 1 too large.)

  • Autopilot · 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-08 20:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#issuecomment-6068876355) · edited 2026-10-08 21:41 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/1257?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 --> <!-- This is an auto-generated comment: rate limited by coderabbit.ai --> > [!WARNING] > ## Review limit reached > > You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. > > **Next included review available in 7 minutes.** > > [Check out review usage here](https://app.coderabbit.ai/dashboard/review-capacity?orgId=d7cf2749-f181-4119-ba0c-ad79606afdfe). > > <details> > <summary>View limit details</summary> > > **Limit details:** You’ve used all 8 included reviews currently available. > > [Learn how review limits work](https://docs.coderabbit.ai/management/plans#rate-limits). > > **Review configuration:** > > <details> > <summary>⚙️ Run configuration</summary> > > - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml > - **Review profile**: CHILL > - **Plan**: Advanced > - **Run ID**: `1b578908-39ed-4bfa-bc5a-36d397b6d591` > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 and 4d0b7f2acd921d5bdbcb18f3576579440efe8b3a. > > </details> > > <details> > <summary>📒 Files selected for processing (5)</summary> > > * `src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp` > * `src/graphics/host_gpu/renderer/pipeline/descriptorHeap.h` > * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` > * `src/kernel/memory.cpp` > * `src/kernel/memory.h` > > </details> > > </details> <!-- end of auto-generated comment: rate limited by coderabbit.ai --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change adds bindless image-table tracking and materialization, then uses table mappings to select sampled-image descriptors at runtime. The renderer resolves and caches table images, with image and backing epochs used for refresh checks. Speculative texture lookup can reject depth-overlap candidates. The change also adds soft-exit exceptions, backing-readability checks, and supported Vulkan sampled-image array indexing features. **Suggested reviewers:** `nmzik`, `senaxx`, `claxten10` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8" --> **Change:** Feature <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **🟡 Moderate** · up to `1d3a5` <!-- final_review_risk_coverage:{"sourceCommitId":"1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8","coveredCommitId":"1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8","kind":"reviewed"} --> The new bindless texture-table path can fail pipeline creation on GPUs with lower sampled-image limits. A failed lookup can also leave the texture cache in an inconsistent state. Both should be fixed or explicitly accepted before merging. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 12.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 22 files. (3 skipped:… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ✅ Passed | The title clearly and concisely describes the main change: binding GPU-indexed T# tables as sampled image arrays. | | Description check | ✅ Passed | The description is directly related to the changeset. It explains the GPU-indexed T# table problem, resource tracking, shader indexing, host binding, caching, testing, and expected GTA V support. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 12.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 87 functions across 22 files. (3 skipped: 2 unsupported, 1 too large.) </details> </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">Autopilot</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=1257)! 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) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -14,0 +29,4 @@
if (g_soft_exit_depth > 0) {
throw SoftExitError(fmt::format("{} ({}:{})", text, file, line));
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 20:55 UTC · original · edited 2026-10-08 21:14 UTC

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

set -o pipefail
printf '%s\n' '--- changed files ---'
git diff --stat 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8
printf '%s\n' '--- assert diff ---'
git diff --unified=80 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/common/assert.cpp
printf '%s\n' '--- texture-cache symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTableTexture' . || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'FindImageSpeculative' . || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTexture' . || test "$?" -eq 1
printf '%s\n' '--- soft-exit symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'SoftExitScope' . || test "$?" -eq 1
rg -n -E --glob '*.{cpp,h,hpp}' -- 'EXIT_IF|EXIT\\(' src | head -200

Repository: KytyPS5/KytyPS5

Length of output: 11022


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- changed files ---'
git diff --stat 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8
printf '%s\n' '--- assert diff ---'
git diff --unified=80 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/common/assert.cpp
printf '%s\n' '--- texture-cache symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTableTexture' . || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'FindImageSpeculative' . || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTexture' . || test "$?" -eq 1
printf '%s\n' '--- soft-exit symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'SoftExitScope' . || test "$?" -eq 1
rg -n -E --glob '*.{cpp,h,hpp}' -- 'EXIT_IF|EXIT\(' src | head -200

Repository: KytyPS5/KytyPS5

Length of output: 11022


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- descriptors 480-780 ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '480,780p'
printf '%s\n' '--- texture cache 1240-1385 ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1385p'
printf '%s\n' '--- texture cache mutation symbols and EXIT sites ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'InsertImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'FreeImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ExpandImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n -n --glob '*.{cpp,h,hpp}' -- '(EXIT_IF|EXIT|NOT_IMPLEMENTED|ASSERT)' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
printf '%s\n' '--- relevant PR diff ---'
git diff --unified=35 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42590


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- descriptors 480-780 ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '480,780p'
printf '%s\n' '--- texture cache 1240-1385 ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1385p'
printf '%s\n' '--- texture cache mutation symbols and EXIT sites ---'
rg -n -F --glob '*.{cpp,h,hpp}' -- 'InsertImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'FreeImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n -F --glob '*.{cpp,h,hpp}' -- 'ExpandImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
rg -n --glob '*.{cpp,h,hpp}' -- '(EXIT_IF|EXIT|NOT_IMPLEMENTED|ASSERT)' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
printf '%s\n' '--- relevant PR diff ---'
git diff --unified=35 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 43585


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- FindImageImpl complete candidate block ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1300,1515p'
printf '%s\n' '--- named mutation definitions and callers ---'
rg -n -F -- 'InsertImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'FreeImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'ExpandImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'ResolveDepthOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- cache assertions/exits ---'
rg -n -- '(EXIT_IF|EXIT_NOT_IMPLEMENTED|EXIT|ASSERT|ASSERT_IF)' src/graphics/host_gpu/renderer/cache/textureCache.cpp || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 14534


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- cache insertion/free helpers ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '210,355p'
printf '%s\n' '--- overlap helpers ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '680,960p'
printf '%s\n' '--- materialization and post-lookup helpers ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '960,1235p'

Repository: KytyPS5/KytyPS5

Length of output: 34699


Keep SoftExitError out of mutating texture-cache code.

ResolveTableTexture keeps SoftExitScope active for the full ResolveTexture call. FindImageSpeculative can then enter ResolveOverlap while holding m_lock. Non-depth overlap branches call ExpandImage, which inserts an image before initialization, copying, and freeing. Those later operations contain EXIT paths. MaterializeColorClear also mutates image metadata before validation checks that can exit.

A soft failure can therefore unwind to ResolveTableTexture after partial cache updates. Complete failure-prone validation before cache mutation, or make speculative lookup and materialization rollback-safe before catching SoftExitError. Do not keep the current soft-exit scope across mutating cache work.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 20:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224037436) · edited 2026-10-08 21:14 UTC **🗄️ Data Integrity & Integration** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- changed files ---' git diff --stat 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 printf '%s\n' '--- assert diff ---' git diff --unified=80 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/common/assert.cpp printf '%s\n' '--- texture-cache symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTableTexture' . || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'FindImageSpeculative' . || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTexture' . || test "$?" -eq 1 printf '%s\n' '--- soft-exit symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'SoftExitScope' . || test "$?" -eq 1 rg -n -E --glob '*.{cpp,h,hpp}' -- 'EXIT_IF|EXIT\\(' src | head -200 ``` Repository: KytyPS5/KytyPS5 Length of output: 11022 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- changed files ---' git diff --stat 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 printf '%s\n' '--- assert diff ---' git diff --unified=80 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/common/assert.cpp printf '%s\n' '--- texture-cache symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTableTexture' . || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'FindImageSpeculative' . || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'ResolveTexture' . || test "$?" -eq 1 printf '%s\n' '--- soft-exit symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'SoftExitScope' . || test "$?" -eq 1 rg -n -E --glob '*.{cpp,h,hpp}' -- 'EXIT_IF|EXIT\(' src | head -200 ``` Repository: KytyPS5/KytyPS5 Length of output: 11022 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- descriptors 480-780 ---' nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '480,780p' printf '%s\n' '--- texture cache 1240-1385 ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1385p' printf '%s\n' '--- texture cache mutation symbols and EXIT sites ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'InsertImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'FreeImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'ExpandImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n -n --glob '*.{cpp,h,hpp}' -- '(EXIT_IF|EXIT|NOT_IMPLEMENTED|ASSERT)' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 printf '%s\n' '--- relevant PR diff ---' git diff --unified=35 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42590 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- descriptors 480-780 ---' nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '480,780p' printf '%s\n' '--- texture cache 1240-1385 ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1385p' printf '%s\n' '--- texture cache mutation symbols and EXIT sites ---' rg -n -F --glob '*.{cpp,h,hpp}' -- 'InsertImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'FreeImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n -F --glob '*.{cpp,h,hpp}' -- 'ExpandImage' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 rg -n --glob '*.{cpp,h,hpp}' -- '(EXIT_IF|EXIT|NOT_IMPLEMENTED|ASSERT)' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 printf '%s\n' '--- relevant PR diff ---' git diff --unified=35 58978d154a57cb5f4d68867c8e966af42fc7770c 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 43585 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- FindImageImpl complete candidate block ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1300,1515p' printf '%s\n' '--- named mutation definitions and callers ---' rg -n -F -- 'InsertImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'FreeImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'ExpandImage(' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'ResolveDepthOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- cache assertions/exits ---' rg -n -- '(EXIT_IF|EXIT_NOT_IMPLEMENTED|EXIT|ASSERT|ASSERT_IF)' src/graphics/host_gpu/renderer/cache/textureCache.cpp || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 14534 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- cache insertion/free helpers ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '210,355p' printf '%s\n' '--- overlap helpers ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '680,960p' printf '%s\n' '--- materialization and post-lookup helpers ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '960,1235p' ``` Repository: KytyPS5/KytyPS5 Length of output: 34699 --- </details> **Keep `SoftExitError` out of mutating texture-cache code.** `ResolveTableTexture` keeps `SoftExitScope` active for the full `ResolveTexture` call. `FindImageSpeculative` can then enter `ResolveOverlap` while holding `m_lock`. Non-depth overlap branches call `ExpandImage`, which inserts an image before initialization, copying, and freeing. Those later operations contain `EXIT` paths. `MaterializeColorClear` also mutates image metadata before validation checks that can exit. A soft failure can therefore unwind to `ResolveTableTexture` after partial cache updates. Complete failure-prone validation before cache mutation, or make speculative lookup and materialization rollback-safe before catching `SoftExitError`. Do not keep the current soft-exit scope across mutating cache work. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4a62319c2dc72eb7997fc6ff --> <!-- This is an auto-generated reply by CodeRabbit -->
@ -457,0 +473,4 @@
uint32_t ImageTableCapacity(size_t slots) {
return std::bit_ceil(std::max<uint32_t>(static_cast<uint32_t>(slots), 256u));
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 20:55 UTC · original · edited 2026-10-08 21:41 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -n -C3 'maxPerStageDescriptorSampledImages|table_capacity|SampledImage' src/graphics/host_gpu src/graphics/presentation

Repository: KytyPS5/KytyPS5

Length of output: 9905


🏁 Script executed:

set -e
printf '%s\n' '--- ResourceMaterialization.cpp relevant definitions ---'
rg -n -C8 -F -- 'ImageTableCapacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
rg -n -C10 -F -- 'table_capacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp src/graphics/host_gpu/renderer/pipeline
printf '%s\n' '--- descriptor layout and pool ---'
rg -n -C12 -F -- 'DescriptorPoolSizes' src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp
rg -n -C12 -F -- 'table_capacity' src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
printf '%s\n' '--- device limits and descriptor indexing ---'
rg -n -C8 -F -- 'maxPerStageDescriptorSampledImages' src
rg -n -C8 -F -- 'maxPerStageDescriptor' src/graphics
rg -n -C8 -F -- 'eSampledImage' src/graphics/host_gpu/renderer/pipeline | head -240

Repository: KytyPS5/KytyPS5

Length of output: 17667


🏁 Script executed:

set -e
printf '%s\n' '--- ResourceMaterialization.cpp ---'
rg -n -C10 -F -- 'ImageTableCapacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
rg -n -C10 -F -- 'table_capacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp src/graphics/host_gpu/renderer/pipeline
printf '%s\n' '--- descriptor pool/layout ---'
rg -n -C12 -F -- 'DescriptorPoolSizes' src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp
rg -n -C12 -F -- 'eSampledImage' src/graphics/host_gpu/renderer/pipeline | head -240
printf '%s\n' '--- Vulkan limits ---'
rg -n -C8 -F -- 'maxPerStageDescriptorSampledImages' src || test $? -eq 1
rg -n -C8 -F -- 'maxPerStageDescriptor' src/graphics || test $? -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 21400


🏁 Script executed:

set -e
printf '%s\n' '--- descriptor layout construction ---'
rg -n -C12 'createDescriptorSetLayout|DescriptorSetLayoutBinding|descriptorCount|table_capacity|TableResolution' src/graphics/host_gpu/renderer/pipeline src/graphics/host_gpu/renderer
printf '%s\n' '--- physical-device properties and limits ---'
rg -n -C10 'getPhysicalDeviceProperties|getProperties|limits|descriptorIndexing|maxPerStageDescriptorSampledImages|descriptorBinding' src/graphics/host_gpu src/graphics/presentation

Repository: KytyPS5/KytyPS5

Length of output: 41490


🏁 Script executed:

set -e
rg -n -C18 -F -- 'NativeDescriptorCount' src/graphics/host_gpu/renderer/pipeline src/graphics/shader

Repository: KytyPS5/KytyPS5

Length of output: 19528


Guard bindless table descriptors against device limits.

ImageTableCapacity can select capacities above a device's maxPerStageDescriptorSampledImages. NativeDescriptorCount passes the resulting table count to the sampled-image descriptor layout, and CreateDescriptorLayout does not check that limit before calling createDescriptorSetLayout. A device with a lower limit can therefore fail pipeline creation. Also check the aggregate sampled-image count against the 65,536-descriptor pool budget when a layout contains multiple table ranges. Use the existing non-table path or return a controlled failure when either limit is exceeded.

✅ Confirmed as addressed by @⁠TheCruZ

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 20:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224037448) · edited 2026-10-08 21:41 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash rg -n -C3 'maxPerStageDescriptorSampledImages|table_capacity|SampledImage' src/graphics/host_gpu src/graphics/presentation ``` Repository: KytyPS5/KytyPS5 Length of output: 9905 --- 🏁 Script executed: ```bash set -e printf '%s\n' '--- ResourceMaterialization.cpp relevant definitions ---' rg -n -C8 -F -- 'ImageTableCapacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp rg -n -C10 -F -- 'table_capacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp src/graphics/host_gpu/renderer/pipeline printf '%s\n' '--- descriptor layout and pool ---' rg -n -C12 -F -- 'DescriptorPoolSizes' src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp rg -n -C12 -F -- 'table_capacity' src/graphics/host_gpu/renderer/pipeline/descriptors.cpp printf '%s\n' '--- device limits and descriptor indexing ---' rg -n -C8 -F -- 'maxPerStageDescriptorSampledImages' src rg -n -C8 -F -- 'maxPerStageDescriptor' src/graphics rg -n -C8 -F -- 'eSampledImage' src/graphics/host_gpu/renderer/pipeline | head -240 ``` Repository: KytyPS5/KytyPS5 Length of output: 17667 --- 🏁 Script executed: ```bash set -e printf '%s\n' '--- ResourceMaterialization.cpp ---' rg -n -C10 -F -- 'ImageTableCapacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp rg -n -C10 -F -- 'table_capacity' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp src/graphics/host_gpu/renderer/pipeline printf '%s\n' '--- descriptor pool/layout ---' rg -n -C12 -F -- 'DescriptorPoolSizes' src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp rg -n -C12 -F -- 'eSampledImage' src/graphics/host_gpu/renderer/pipeline | head -240 printf '%s\n' '--- Vulkan limits ---' rg -n -C8 -F -- 'maxPerStageDescriptorSampledImages' src || test $? -eq 1 rg -n -C8 -F -- 'maxPerStageDescriptor' src/graphics || test $? -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 21400 --- 🏁 Script executed: ```bash set -e printf '%s\n' '--- descriptor layout construction ---' rg -n -C12 'createDescriptorSetLayout|DescriptorSetLayoutBinding|descriptorCount|table_capacity|TableResolution' src/graphics/host_gpu/renderer/pipeline src/graphics/host_gpu/renderer printf '%s\n' '--- physical-device properties and limits ---' rg -n -C10 'getPhysicalDeviceProperties|getProperties|limits|descriptorIndexing|maxPerStageDescriptorSampledImages|descriptorBinding' src/graphics/host_gpu src/graphics/presentation ``` Repository: KytyPS5/KytyPS5 Length of output: 41490 --- 🏁 Script executed: ```bash set -e rg -n -C18 -F -- 'NativeDescriptorCount' src/graphics/host_gpu/renderer/pipeline src/graphics/shader ``` Repository: KytyPS5/KytyPS5 Length of output: 19528 --- </details> **Guard bindless table descriptors against device limits.** `ImageTableCapacity` can select capacities above a device's `maxPerStageDescriptorSampledImages`. `NativeDescriptorCount` passes the resulting table count to the sampled-image descriptor layout, and `CreateDescriptorLayout` does not check that limit before calling `createDescriptorSetLayout`. A device with a lower limit can therefore fail pipeline creation. Also check the aggregate sampled-image count against the 65,536-descriptor pool budget when a layout contains multiple table ranges. Use the existing non-table path or return a controlled failure when either limit is exceeded. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:64c0b63b31ce5688cccee533 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠TheCruZ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 20:55 UTC · original · reviewed

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/ShaderRecompilerComputeTests.cpp (1)

39269-39270: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Check the materialized entry-to-slot mapping.

The new assertion checks only the mapping length. CheckIndirectImageKeySwitch samples with a manually populated mapping, so an incorrect mapping produced here could pass both tests. Assert the slots for the duplicate, wrapped key, and out-of-range key. Feed the produced mapping into a GPU sample test to check the materialization-to-sampling contract.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e7fba2b-ac24-4c54-9d9b-5bbdad8876b6
📥 Commits

Reviewing files that changed from the base of the PR and between 2f4b8a335d and 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8.

📒 Files selected for processing (25)
  • CMakeLists.txt
  • src/common/assert.cpp
  • src/common/assert.h
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.h
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterAnalysis.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/ir/ResourceSnapshot.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/BindingLayout.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.h
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • src/kernel/memory.cpp
  • src/kernel/memory.h
  • src/kernel/memoryAddressSpace.inc
  • 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; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 20:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#pullrequestreview-5462736167) · **reviewed** **Actionable comments posted: 2** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp (1)</summary><blockquote> `39269-39270`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **🏗️ Heavy lift** **Check the materialized entry-to-slot mapping.** The new assertion checks only the mapping length. `CheckIndirectImageKeySwitch` samples with a manually populated mapping, so an incorrect mapping produced here could pass both tests. Assert the slots for the duplicate, wrapped key, and out-of-range key. Feed the produced mapping into a GPU sample test to check the materialization-to-sampling contract. <!-- cr-comment:v1:a6a1326870e9968c8ab1b176 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `7e7fba2b-ac24-4c54-9d9b-5bbdad8876b6` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 2f4b8a335d5e27a5153bdea670bd877a061e37b1 and 1d3a50e7eeb1ad55a57bff3600b944228b8e6ce8. </details> <details> <summary>📒 Files selected for processing (25)</summary> * `CMakeLists.txt` * `src/common/assert.cpp` * `src/common/assert.h` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.h` * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAnalysis.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/ir/ResourceSnapshot.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/BindingLayout.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.h` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `src/kernel/memory.cpp` * `src/kernel/memory.h` * `src/kernel/memoryAddressSpace.inc` * `tests/ResourceTrackingTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=807474fe-230b-41ab-9e9e-c2681d6a941a attempt=bbbd1180-30ab-433d-9e9f-ef88ccaef1ce batch=1/1 -->
@ -457,0 +473,4 @@
uint32_t ImageTableCapacity(size_t slots) {
return std::bit_ceil(std::max<uint32_t>(static_cast<uint32_t>(slots), 256u));
}
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:14 UTC · original

Fixed in f78d0ab: CreateDescriptorLayout now counts the sampled images of the layout (in total and per stage) and exits with a message naming the counts when they exceed maxDescriptorSetSampledImages, maxPerStageDescriptorSampledImages or the descriptor pool's sampled-image budget (now DescriptorHeap::MaxSampledImages, the same constant the pool uses), instead of creating an invalid layout. There is no non-table path that can run these shaders (that is what this PR adds), so a clear failure is the fallback.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224200183) Fixed in f78d0ab: `CreateDescriptorLayout` now counts the sampled images of the layout (in total and per stage) and exits with a message naming the counts when they exceed `maxDescriptorSetSampledImages`, `maxPerStageDescriptorSampledImages` or the descriptor pool's sampled-image budget (now `DescriptorHeap::MaxSampledImages`, the same constant the pool uses), instead of creating an invalid layout. There is no non-table path that can run these shaders (that is what this PR adds), so a clear failure is the fallback.
@ -14,0 +29,4 @@
if (g_soft_exit_depth > 0) {
throw SoftExitError(fmt::format("{} ({}:{})", text, file, line));
}
}
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:14 UTC · original

I'm keeping the scope as it is. Everything that can be rejected from the T# and the backing alone (ImageTableSlotCompatible, readable backing, format and dimension checks in ResolveTexture) happens before the texture cache is touched, so the common rejections never reach mutating code. The scope only matters for errors further down, inside the cache, and those were fatal before this PR: without it the same failure terminates the emulator. Making every cache mutation that has an EXIT after it transactional (ExpandImage, overlap merging, clear materialization) is a large change to the texture cache that is outside this PR; in the worst case a failed element leaves an extra image registered over memory the shader does not read through that slot, which the cache already handles like any other overlap.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224200381) I'm keeping the scope as it is. Everything that can be rejected from the T# and the backing alone (`ImageTableSlotCompatible`, readable backing, format and dimension checks in `ResolveTexture`) happens before the texture cache is touched, so the common rejections never reach mutating code. The scope only matters for errors further down, inside the cache, and those were fatal before this PR: without it the same failure terminates the emulator. Making every cache mutation that has an `EXIT` after it transactional (`ExpandImage`, overlap merging, clear materialization) is a large change to the texture cache that is outside this PR; in the worst case a failed element leaves an extra image registered over memory the shader does not read through that slot, which the cache already handles like any other overlap.
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:15 UTC · original

@⁠coderabbitai About the nitpick on the mapping assertion in ShaderRecompilerComputeTests: I'm leaving it as is in this PR. The slot mapping that materialization produces is checked entry by entry in ResourceTrackingTests (duplicates share a slot, null and invalid T#s map to the null slot), and the GPU case covers the shader side of the same layout; wiring the produced mapping into a GPU sample test would mostly duplicate those two.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#issuecomment-6069187006) @⁠coderabbitai About the nitpick on the mapping assertion in `ShaderRecompilerComputeTests`: I'm leaving it as is in this PR. The slot mapping that materialization produces is checked entry by entry in `ResourceTrackingTests` (duplicates share a slot, null and invalid T#s map to the null slot), and the GPU case covers the shader side of the same layout; wiring the produced mapping into a GPU sample test would mostly duplicate those two.
@ -457,0 +473,4 @@
uint32_t ImageTableCapacity(size_t slots) {
return std::bit_ceil(std::max<uint32_t>(static_cast<uint32_t>(slots), 256u));
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:15 UTC · original

@TheCruZ, thanks for the fix and clarification. The checks you describe cover the per-stage limit, descriptor-set limit, and sampled-image pool budget. Using DescriptorHeap::MaxSampledImages for both the check and the pool keeps the budget consistent.

A clear failure is appropriate because these GPU-indexed shaders have no working non-table path.


✏️ Learnings added
Learnt from: TheCruZ
Repo: KytyPS5/KytyPS5 PR: 1257
File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476
Timestamp: 2026-10-08T21:14:54.534Z
Learning: In KytyPS5/KytyPS5, the GPU-indexed T# shaders supported by the bindless sampled-image-table implementation have no working non-table fallback. If their descriptor layout exceeds device limits or the sampled-image pool budget, a clear failure is the appropriate fallback.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224204671) `@TheCruZ`, thanks for the fix and clarification. The checks you describe cover the per-stage limit, descriptor-set limit, and sampled-image pool budget. Using `DescriptorHeap::MaxSampledImages` for both the check and the pool keeps the budget consistent. A clear failure is appropriate because these GPU-indexed shaders have no working non-table path. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: TheCruZ Repo: KytyPS5/KytyPS5 PR: 1257 File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476 Timestamp: 2026-10-08T21:14:54.534Z Learning: In KytyPS5/KytyPS5, the GPU-indexed T# shaders supported by the bindless sampled-image-table implementation have no working non-table fallback. If their descriptor layout exceeds device limits or the sampled-image pool budget, a clear failure is the appropriate fallback. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Bindless%20tables%20can%20exceed%20Vulkan%E2%80%99s%20per-stage%2C%20per-set%2C%20or%20pool%20limits%20and%20break%20pipeline%20creation.%20%40coderabbitai%20recommends%20validating%20counts%20and%20failing%20clearly%E2%80%94try%20it%20for%20actionable%20code%20reviews%20%F0%9F%9B%A1%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1257%23discussion_r4224037448)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
@ -14,0 +29,4 @@
if (g_soft_exit_depth > 0) {
throw SoftExitError(fmt::format("{} ({}:{})", text, file, line));
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:15 UTC · original

@TheCruZ, thanks for the clarification. Ordinary T# and backing rejections occur before texture-cache access. The remaining concern is recovery after a cache-internal failure, not those early rejections.

I understand your decision to retain SoftExitScope and keep transactional cache changes outside this PR. I will not press for that change here.

Would you like a follow-up issue for exception safety in speculative texture-cache lookup?


✏️ Learnings added
Learnt from: TheCruZ
Repo: KytyPS5/KytyPS5 PR: 1257
File: src/common/assert.cpp:28-32
Timestamp: 2026-10-08T21:15:02.068Z
Learning: In KytyPS5's C++ renderer, ResolveTableTexture in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp intentionally keeps SoftExitScope active across ResolveTexture to recover from cache-internal errors that previously terminated the emulator. The maintainer states that ImageTableSlotCompatible, readable-backing checks, and ResolveTexture format and dimension checks reject ordinary T# candidates before texture-cache access. Transactional recovery for cache mutations is outside the bindless-image-table PR's intended scope.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224204954) `@TheCruZ`, thanks for the clarification. Ordinary T# and backing rejections occur before texture-cache access. The remaining concern is recovery after a cache-internal failure, not those early rejections. I understand your decision to retain `SoftExitScope` and keep transactional cache changes outside this PR. I will not press for that change here. Would you like a follow-up issue for exception safety in speculative texture-cache lookup? --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: TheCruZ Repo: KytyPS5/KytyPS5 PR: 1257 File: src/common/assert.cpp:28-32 Timestamp: 2026-10-08T21:15:02.068Z Learning: In KytyPS5's C++ renderer, ResolveTableTexture in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp intentionally keeps SoftExitScope active across ResolveTexture to recover from cache-internal errors that previously terminated the emulator. The maintainer states that ImageTableSlotCompatible, readable-backing checks, and ResolveTexture format and dimension checks reject ordinary T# candidates before texture-cache access. Transactional recovery for cache mutations is outside the bindless-image-table PR's intended scope. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:15 UTC · original

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd -t f '^(ShaderRecompilerComputeTests|ResourceTrackingTests)\.cpp$'
ast-grep outline tests/ResourceTrackingTests.cpp --match 'TestBindlessImageTable' --view expanded
ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match 'Image|Sample' --view expanded
rg -n -C 12 'mapping|table_capacity|TestBindlessImageTable' tests/ResourceTrackingTests.cpp tests/ShaderRecompilerComputeTests.cpp

Length of output: 201110


@TheCruZ Thanks for clarifying. TestBindlessImageTable checks the exact slot mapping and its refresh after descriptor changes. That supports keeping the mapping-size assertion in ShaderRecompilerComputeTests.cpp as is. I withdraw the nitpick.


✏️ Learnings added
Learnt from: TheCruZ
URL: https://github.com/KytyPS5/KytyPS5/pull/1257

Timestamp: 2026-10-08T21:15:42.926Z
Learning: In this C++ repository, bindless T# table test coverage is split across tests/ResourceTrackingTests.cpp and tests/ShaderRecompilerComputeTests.cpp. TestBindlessImageTable checks exact materialized slot mappings, descriptor deduplication, null-slot mapping, and mapping refresh. The author identifies the GPU case as complementary shader-side coverage and considers feeding the produced mapping into another GPU sample test largely duplicate coverage. Evaluate these tests together before requesting stronger mapping assertions in ShaderRecompilerComputeTests.cpp.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#issuecomment-6069197751) <!-- This is an auto-generated reply by CodeRabbit --> > [!TIP] > For best results, initiate chat on the files or code changes. <details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ```shell #!/bin/bash set -euo pipefail fd -t f '^(ShaderRecompilerComputeTests|ResourceTrackingTests)\.cpp$' ast-grep outline tests/ResourceTrackingTests.cpp --match 'TestBindlessImageTable' --view expanded ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match 'Image|Sample' --view expanded rg -n -C 12 'mapping|table_capacity|TestBindlessImageTable' tests/ResourceTrackingTests.cpp tests/ShaderRecompilerComputeTests.cpp ``` Length of output: 201110 --- </details> `@TheCruZ` Thanks for clarifying. `TestBindlessImageTable` checks the exact slot mapping and its refresh after descriptor changes. That supports keeping the mapping-size assertion in `ShaderRecompilerComputeTests.cpp` as is. I withdraw the nitpick. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: TheCruZ URL: https://github.com/KytyPS5/KytyPS5/pull/1257 Timestamp: 2026-10-08T21:15:42.926Z Learning: In this C++ repository, bindless T# table test coverage is split across tests/ResourceTrackingTests.cpp and tests/ShaderRecompilerComputeTests.cpp. TestBindlessImageTable checks exact materialized slot mappings, descriptor deduplication, null-slot mapping, and mapping refresh. The author identifies the GPU case as complementary shader-side coverage and considers feeding the produced mapping into another GPU sample test largely duplicate coverage. Evaluate these tests together before requesting stronger mapping assertions in ShaderRecompilerComputeTests.cpp. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> _You are interacting with an AI system._
@ -457,0 +473,4 @@
uint32_t ImageTableCapacity(size_t slots) {
return std::bit_ceil(std::max<uint32_t>(static_cast<uint32_t>(slots), 256u));
}
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:41 UTC · original

Follow-up in 4d0b7f2a: GTA V's ray tracing table needs ~82000 sampled images in one set, more than the 65536 a pool held, so the pool now holds 262144 sampled images and the layout check still fails clearly above that.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224426630) Follow-up in 4d0b7f2a: GTA V's ray tracing table needs ~82000 sampled images in one set, more than the 65536 a pool held, so the pool now holds 262144 sampled images and the layout check still fails clearly above that.
@ -457,0 +473,4 @@
uint32_t ImageTableCapacity(size_t slots) {
return std::bit_ceil(std::max<uint32_t>(static_cast<uint32_t>(slots), 256u));
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:42 UTC · original

@TheCruZ, thanks for the update. The new 262,144 sampled-image pool budget covers GTA V’s reported requirement of about 82,000 sampled images in one set. Keeping the device-limit checks and the shared DescriptorHeap::MaxSampledImages check preserves clear failure when a layout exceeds either limit.


✏️ Learnings added
Learnt from: TheCruZ
Repo: KytyPS5/KytyPS5 PR: 1257
File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476
Timestamp: 2026-10-08T21:42:01.091Z
Learning: In KytyPS5/KytyPS5, GTA V's ray-tracing bindless T# workload requires about 82,000 sampled-image descriptors in one descriptor set. A 65,536-descriptor sampled-image pool cannot accommodate this workload.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: TheCruZ
Repo: KytyPS5/KytyPS5 PR: 1257
File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476
Timestamp: 2026-10-08T21:14:56.893Z
Learning: In KytyPS5/KytyPS5, the GPU-indexed T# shaders supported by the bindless sampled-image-table implementation have no working non-table fallback. If their descriptor layout exceeds device limits or the sampled-image pool budget, a clear failure is the appropriate fallback.

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#discussion_r4224430197) `@TheCruZ`, thanks for the update. The new 262,144 sampled-image pool budget covers GTA V’s reported requirement of about 82,000 sampled images in one set. Keeping the device-limit checks and the shared `DescriptorHeap::MaxSampledImages` check preserves clear failure when a layout exceeds either limit. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: TheCruZ Repo: KytyPS5/KytyPS5 PR: 1257 File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476 Timestamp: 2026-10-08T21:42:01.091Z Learning: In KytyPS5/KytyPS5, GTA V's ray-tracing bindless T# workload requires about 82,000 sampled-image descriptors in one descriptor set. A 65,536-descriptor sampled-image pool cannot accommodate this workload. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <details> <summary>🧠 Learnings used</summary> ``` Learnt from: TheCruZ Repo: KytyPS5/KytyPS5 PR: 1257 File: src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp:474-476 Timestamp: 2026-10-08T21:14:56.893Z Learning: In KytyPS5/KytyPS5, the GPU-indexed T# shaders supported by the bindless sampled-image-table implementation have no working non-table fallback. If their descriptor layout exceeds device limits or the sampled-image pool budget, a clear failure is the appropriate fallback. ``` </details> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-09 01:32 UTC · original

Thanks for this, it's a clean way to handle large GPU-indexed heaps. I went through the diff at 4d0b7f2a. The SPIR-V side looks right to me: sized array, NonUniform on the index, pointer, image and sampled image, and the index can't leave the array because capacity >= slots and the entry is clamped. A few things I think are worth fixing before it lands:

1. Linux/macOS: a soft exit inside the texture cache leaves m_lock held.
On GCC/Clang everything except common, descriptors.cpp and pipelineCache.cpp is built with -fno-exceptions (src/utils.cmake:99/104). ResolveTableTexture → FindImageSpeculative → FindImageImpl takes std::scoped_lock lock {m_lock} (textureCache.cpp ~1322) and can EXIT under it, for example "unresolvable equal-address image overlap" (~895) or image creation. When that throws SoftExitError, it unwinds through -fno-exceptions frames that have no cleanup pads. So the lock's destructor never runs, the catch in descriptors.cpp succeeds, and the next texture-cache call spins forever. Main prints a fatal error at that point instead. Windows is fine because clang-cl keeps /EHsc. I checked the mechanism with a 3-TU model (RAII guard in a -fno-exceptions TU between thrower and catcher): the guard is not released. Smallest fix is adding textureCache.cpp to the -fexceptions list:

	set_source_files_properties(
		"${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/pipeline/descriptors.cpp"
		"${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp"
		"${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/cache/textureCache.cpp"
		PROPERTIES COMPILE_OPTIONS -fexceptions)

Another option is to suspend the soft scope around the FindImage* call, so cache-internal errors stay fatal like on main.

2. Non-update-after-bind limits on MoltenVK and some drivers.
The new layout check correctly uses maxPerStageDescriptorSampledImages / maxDescriptorSetSampledImages. But MoltenVK reports those as 128 or 256 per stage (5× that per set), and raises only the update-after-bind limits to 1e6 with Tier-2 argument buffers (MVKDevice.mm). gpuinfo also has ~200 Windows reports at 200. Since ImageTableCapacity has a floor of 256, every table pipeline exits on those devices. And table_array now replaces the direct-lookup and key-probe paths for scalar stride-32 tables of any size, so shaders that worked there before would start exiting. Could table bindings use UPDATE_AFTER_BIND | PARTIALLY_BOUND (with an update-after-bind pool, checked against the UAB limits)? If not, could the old paths stay as the fallback when the device limit is too small?

3. Pool budget for every game.
DescriptorPoolSizes now gives every pool 262144 sampled images (was 8192), and several pools are alive while ticks retire. On drivers that allocate pool memory up front from pPoolSizes, that is a lot of memory per pool for games that never use tables. With an ~82k-descriptor layout, a pool also holds only 3 sets. So it switches every 3 dispatches, m_sets.clear() drops the other layouts' batches, and Allocate re-tries 32→16→8→4 before 2 succeed. A separate heap for table layouts, sized from the layout, would keep the general pool at 8192 and avoid the churn.

4. Small: vulkanWindow.cpp.
shaderSampledImageArrayNonUniformIndexing is already required by RequiredVulkan12Features() (checked at device selection), so that assignment and half the warning are no-ops. shaderSampledImageArrayDynamicIndexing is only enabled if supported, while the module always declares SampledImageArrayDynamicIndexing for table bindings. It's probably simplest to make it required too.

Also a heads-up: main gained Nmzik's SPIR-V emitter refactor today. git merge-tree shows conflicts in descriptors.cpp, render.h, spirvEmitterImage.cpp, spirvEmitterModule.cpp, ShaderIR.h, and BindingLayout.cpp was deleted on main (e1ac893a), so the table-range allocation needs a new home. #1258 will need the same rebase.

I compile-checked the changed files with an x86_64 Clang cross build. I couldn't run the test suites in my environment.

Written with AI assistance.

**@⁠overlordxrz-source** on GitHub · 2026-10-09 01:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1257#issuecomment-6072427259) Thanks for this, it's a clean way to handle large GPU-indexed heaps. I went through the diff at 4d0b7f2a. The SPIR-V side looks right to me: sized array, `NonUniform` on the index, pointer, image and sampled image, and the index can't leave the array because `capacity >= slots` and the entry is clamped. A few things I think are worth fixing before it lands: **1. Linux/macOS: a soft exit inside the texture cache leaves `m_lock` held.** On GCC/Clang everything except `common`, `descriptors.cpp` and `pipelineCache.cpp` is built with `-fno-exceptions` (`src/utils.cmake:99/104`). `ResolveTableTexture` → `FindImageSpeculative` → `FindImageImpl` takes `std::scoped_lock lock {m_lock}` (textureCache.cpp ~1322) and can `EXIT` under it, for example "unresolvable equal-address image overlap" (~895) or image creation. When that throws `SoftExitError`, it unwinds through `-fno-exceptions` frames that have no cleanup pads. So the lock's destructor never runs, the `catch` in descriptors.cpp succeeds, and the next texture-cache call spins forever. Main prints a fatal error at that point instead. Windows is fine because clang-cl keeps `/EHsc`. I checked the mechanism with a 3-TU model (RAII guard in a `-fno-exceptions` TU between thrower and catcher): the guard is not released. Smallest fix is adding `textureCache.cpp` to the `-fexceptions` list: ```cmake set_source_files_properties( "${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/pipeline/descriptors.cpp" "${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp" "${KYTY_SOURCE_DIR}/graphics/host_gpu/renderer/cache/textureCache.cpp" PROPERTIES COMPILE_OPTIONS -fexceptions) ``` Another option is to suspend the soft scope around the `FindImage*` call, so cache-internal errors stay fatal like on main. **2. Non-update-after-bind limits on MoltenVK and some drivers.** The new layout check correctly uses `maxPerStageDescriptorSampledImages` / `maxDescriptorSetSampledImages`. But MoltenVK reports those as 128 or 256 per stage (5× that per set), and raises only the *update-after-bind* limits to 1e6 with Tier-2 argument buffers (MVKDevice.mm). gpuinfo also has ~200 Windows reports at 200. Since `ImageTableCapacity` has a floor of 256, every table pipeline exits on those devices. And `table_array` now replaces the direct-lookup and key-probe paths for scalar stride-32 tables of any size, so shaders that worked there before would start exiting. Could table bindings use `UPDATE_AFTER_BIND | PARTIALLY_BOUND` (with an update-after-bind pool, checked against the UAB limits)? If not, could the old paths stay as the fallback when the device limit is too small? **3. Pool budget for every game.** `DescriptorPoolSizes` now gives *every* pool 262144 sampled images (was 8192), and several pools are alive while ticks retire. On drivers that allocate pool memory up front from `pPoolSizes`, that is a lot of memory per pool for games that never use tables. With an ~82k-descriptor layout, a pool also holds only 3 sets. So it switches every 3 dispatches, `m_sets.clear()` drops the other layouts' batches, and `Allocate` re-tries 32→16→8→4 before 2 succeed. A separate heap for table layouts, sized from the layout, would keep the general pool at 8192 and avoid the churn. **4. Small: `vulkanWindow.cpp`.** `shaderSampledImageArrayNonUniformIndexing` is already required by `RequiredVulkan12Features()` (checked at device selection), so that assignment and half the warning are no-ops. `shaderSampledImageArrayDynamicIndexing` is only enabled if supported, while the module always declares `SampledImageArrayDynamicIndexing` for table bindings. It's probably simplest to make it required too. Also a heads-up: main gained Nmzik's SPIR-V emitter refactor today. `git merge-tree` shows conflicts in descriptors.cpp, render.h, spirvEmitterImage.cpp, spirvEmitterModule.cpp, ShaderIR.h, and `BindingLayout.cpp` was deleted on main (e1ac893a), so the table-range allocation needs a new home. #1258 will need the same rebase. I compile-checked the changed files with an x86_64 Clang cross build. I couldn't run the test suites in my environment. Written with AI assistance.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.