tests: resolve the host depth-stencil format against device support #930

Closed
github-bot wants to merge 3 commits from gh-pr/930/head into gh-pr/930/base
Owner

@⁠theantipopau on GitHub · 2026-09-29 21:58 UTC · original
theantipopau:depth-stencil-device-format → main · +77 −28 · 1 files · 3 commits · closed without merging

What

Follow-up to #875. That PR stopped the suite from aborting on a GPU missing the production
rasterization features, but the suite still aborted on this machine — later, in a different
place, and for a different reason:

image format does not support required usage: format=129 type=1 usage=0x23 flags=0x0 samples=2
 in src/graphics/host_gpu/renderer/image/image.cpp:704

format=129 is VK_FORMAT_D24_UNORM_S8_UINT. Image::Image calls EXIT when
vkGetPhysicalDeviceImageFormatProperties rejects the configuration, so this is not a test
failure — it terminates the process, and every case after it never runs.

Two checks hardcode D24S8 as the host format: CheckUnifiedImageViewCache (1 sample) and
CheckUnifiedTextureCacheFlow (2 samples, plus a D16-fallback case that also lands on D24S8).
Neither consults device capability.

Evidence

Querying the local device for every attachment usage and sample count combination:

format DEPTH_STENCIL_ATTACHMENT COLOR_ATTACHMENT
D16_UNORM 1/2/4/8 –
D16_UNORM_S8_UINT 1/2/4/8 –
D24_UNORM_S8_UINT none none
D32_SFLOAT 1/2/4/8 –
D32_SFLOAT_S8_UINT 1/2/4/8 –

D24S8 is rejected for every usage subset and every sample count — including empty usage at
one sample — while the surrounding colour and depth formats behave normally, so this is a real
driver gap rather than a bad query. D32_SFLOAT_S8_UINT is the same shape (depth + stencil,
8 bytes per texel) and is supported at all sample counts.

The fix

VulkanHarness::SupportedDepthStencilFormat(preferred, samples) returns the first format the
device can attach as depth-stencil at that sample count, preferring the one the check
intended
, falling back to D32_SFLOAT_S8_UINT and then D16_UNORM_S8_UINT.

On a device that supports D24S8 — which is most of them — the helper returns
eD24UnormS8Uint and every line below behaves exactly as before. The fallback only engages
where the hardcoded format would otherwise have killed the process. When no depth-stencil
format is available at all the affected sub-case is counted as a skip through the existing
SkipRasterizationCases counter rather than aborting.

CheckUnifiedTextureCacheFlow resolves the format once at the top, because the depth-dependent
work is spread through the whole check; the 2-sample site re-resolves for e2 specifically.
CheckUnifiedImageViewCache guards only its depth/stencil aspect sub-block so the colour, 1D
and volume view coverage after it still runs.

Testing

shader_recompiler_compute_tests builds clean. Before the change the run died at
image.cpp:704 after NativeIndirectDispatch; after it the suite proceeds through all the
host and compute cases and reports the pre-existing shader mismatches (for example
VectorFractF16CapturedAndEdges, unchanged from the failure inventory in #875).

No game was run for this one — it only changes which host format a test allocates, and no
emulator code path is touched.

Note for reviewers

The deeper issue is that Image::Image treats an unsupported image configuration as fatal. The
sibling path in the same function already degrades gracefully — when a block-compressed format
lacks storage support it logs one warning and carries on. I kept this PR test-side and am not
proposing a product change here: falling back on a guest-requested depth format is a real
rendering-correctness decision that deserves its own discussion, and no game on this machine
exercises it.

**@⁠theantipopau** on GitHub · 2026-09-29 21:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930) `theantipopau:depth-stencil-device-format` → `main` · +77 −28 · 1 files · 3 commits · closed without merging ## What Follow-up to #875. That PR stopped the suite from aborting on a GPU missing the production rasterization features, but the suite still aborted on this machine — later, in a different place, and for a different reason: ``` image format does not support required usage: format=129 type=1 usage=0x23 flags=0x0 samples=2 in src/graphics/host_gpu/renderer/image/image.cpp:704 ``` `format=129` is `VK_FORMAT_D24_UNORM_S8_UINT`. `Image::Image` calls `EXIT` when `vkGetPhysicalDeviceImageFormatProperties` rejects the configuration, so this is not a test failure — it terminates the process, and every case after it never runs. Two checks hardcode `D24S8` as the host format: `CheckUnifiedImageViewCache` (1 sample) and `CheckUnifiedTextureCacheFlow` (2 samples, plus a D16-fallback case that also lands on D24S8). Neither consults device capability. ## Evidence Querying the local device for every attachment usage and sample count combination: | format | `DEPTH_STENCIL_ATTACHMENT` | `COLOR_ATTACHMENT` | | --- | --- | --- | | `D16_UNORM` | 1/2/4/8 | – | | `D16_UNORM_S8_UINT` | 1/2/4/8 | – | | **`D24_UNORM_S8_UINT`** | **none** | **none** | | `D32_SFLOAT` | 1/2/4/8 | – | | `D32_SFLOAT_S8_UINT` | 1/2/4/8 | – | `D24S8` is rejected for *every* usage subset and *every* sample count — including empty usage at one sample — while the surrounding colour and depth formats behave normally, so this is a real driver gap rather than a bad query. `D32_SFLOAT_S8_UINT` is the same shape (depth + stencil, 8 bytes per texel) and is supported at all sample counts. ## The fix `VulkanHarness::SupportedDepthStencilFormat(preferred, samples)` returns the first format the device can attach as depth-stencil at that sample count, **preferring the one the check intended**, falling back to `D32_SFLOAT_S8_UINT` and then `D16_UNORM_S8_UINT`. On a device that supports `D24S8` — which is most of them — the helper returns `eD24UnormS8Uint` and every line below behaves exactly as before. The fallback only engages where the hardcoded format would otherwise have killed the process. When no depth-stencil format is available at all the affected sub-case is counted as a skip through the existing `SkipRasterizationCases` counter rather than aborting. `CheckUnifiedTextureCacheFlow` resolves the format once at the top, because the depth-dependent work is spread through the whole check; the 2-sample site re-resolves for `e2` specifically. `CheckUnifiedImageViewCache` guards only its depth/stencil aspect sub-block so the colour, 1D and volume view coverage after it still runs. ## Testing `shader_recompiler_compute_tests` builds clean. Before the change the run died at `image.cpp:704` after `NativeIndirectDispatch`; after it the suite proceeds through all the host and compute cases and reports the pre-existing shader mismatches (for example `VectorFractF16CapturedAndEdges`, unchanged from the failure inventory in #875). No game was run for this one — it only changes which host format a test allocates, and no emulator code path is touched. ## Note for reviewers The deeper issue is that `Image::Image` treats an unsupported image configuration as fatal. The sibling path in the same function already degrades gracefully — when a block-compressed format lacks storage support it logs one warning and carries on. I kept this PR test-side and am not proposing a product change here: falling back on a guest-requested depth format is a real rendering-correctness decision that deserves its own discussion, and no game on this machine exercises it.
Image::Image exits the process when vkGetPhysicalDeviceImageFormatProperties
rejects the requested configuration, so a check that hardcodes
VK_FORMAT_D24_UNORM_S8_UINT kills the whole suite on a driver that cannot
attach it. Ask the device for a usable format first, preferring the one the
check intended, and skip the affected sub-cases when none is available.

Co-Authored-By: Codebuff <[email protected]>
Co-Authored-By: Codebuff <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:37:09 +00:00
github-bot closed this pull request 2026-11-26 09:37:09 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-29 22:03 UTC · original · edited 2026-10-06 04:44 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: 40eaace9-97fe-40dd-a289-5f54be08666e
📥 Commits

Reviewing files that changed from the base of the PR and between 7a15b84c9f and 9192a95861.

📒 Files selected for processing (1)
  • tests/ShaderRecompilerComputeTests.cpp

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


📝 Walkthrough

Walkthrough

The tests now select depth/stencil formats based on required image usage and sample-count support. They skip cases when no suitable format is available. Depth/stencil image and view descriptors use the selected format, including the fallback descriptor.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Other

Merge Risk: 🟡 Moderate · up to 9192a

On devices without two-sample depth-stencil support, this test can leave GPU state behind when it skips, potentially affecting later cases. Move the support check before resource setup before merging.

Architecture Summary

Architecture risk: 🔵 Low · up to 9192a

The change affects 1 system.

Changed systems: tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: VulkanHarness adds a depth/stencil format selector that checks the preferred format, then D32S8 and D16S8, for depth-stencil attachment, sampled, transfer-source, and transfer-destination usage with the requested sample count; it returns eUndefined if no candidate qualifies.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: The depth/stencil view test now selects a supported single-sample format, skips one rasterization case when none is available, and otherwise uses the selected format to create and inspect the image. Previously it always used D24S8.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: CheckUnifiedTextureCacheFlow now selects a supported single-sample depth/stencil format before proceeding; if none is available, it records one skipped rasterization case and returns.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: The multisample depth test now selects a format supporting two samples from the previously selected host format and its fallbacks. If none qualifies, it skips one rasterization case and returns; both the image and view use the selected format instead of hardcoded D24S8.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: selecting a depth-stencil format supported by the device.
Description check ✅ Passed The description explains the unsupported D24S8 failure and how the tests select supported formats or skip affected cases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.

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-09-29 22:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#issuecomment-5899907020) · edited 2026-10-06 04:44 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/930?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**: `40eaace9-97fe-40dd-a289-5f54be08666e` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7a15b84c9f1a328f724be6cbb52741c16dd6554d and 9192a958618e48ac07ec6a9ab0fb3544eb8afd0e. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The tests now select depth/stencil formats based on required image usage and sample-count support. They skip cases when no suitable format is available. Depth/stencil image and view descriptors use the selected format, including the fallback descriptor. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"9192a958618e48ac07ec6a9ab0fb3544eb8afd0e" --> **Change:** Other <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟡 Moderate_ · up to `9192a` <!-- final_review_risk_coverage:{"sourceCommitId":"9192a958618e48ac07ec6a9ab0fb3544eb8afd0e","coveredCommitId":"9192a958618e48ac07ec6a9ab0fb3544eb8afd0e","kind":"reviewed"} --> On devices without two-sample depth-stencil support, this test can leave GPU state behind when it skips, potentially affecting later cases. Move the support check before resource setup before merging. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Architecture Summary **Architecture risk:** _🔵 Low_ · up to `9192a` The change affects 1 system. **Changed systems:** `tests` **Architecture concerns** No architecture-level concerns identified. <details> <summary>Review details</summary> **Systems and components** - _observed_ — tests (service) was modified; 1 changed file maps to changed impact. **Before / after behavior** - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: `VulkanHarness` adds a depth/stencil format selector that checks the preferred format, then D32S8 and D16S8, for depth-stencil attachment, sampled, transfer-source, and transfer-destination usage with the requested sample count; it returns `eUndefined` if no candidate qualifies. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: The depth/stencil view test now selects a supported single-sample format, skips one rasterization case when none is available, and otherwise uses the selected format to create and inspect the image. Previously it always used D24S8. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: `CheckUnifiedTextureCacheFlow` now selects a supported single-sample depth/stencil format before proceeding; if none is available, it records one skipped rasterization case and returns. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: The multisample depth test now selects a format supporting two samples from the previously selected host format and its fallbacks. If none qualifies, it skips one rasterization case and returns; both the image and view use the selected format instead of hardcoded D24S8. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly identifies the main change: selecting a depth-stencil format supported by the device. | | Description check | ✅ Passed | The description explains the unsupported D24S8 failure and how the tests select supported formats or skip affected cases. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0… | | 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. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=930)! 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 -->
@ -6229,0 +6273,4 @@
if (ms_depth_format == vk::Format::eUndefined) {
SkipRasterizationCases(1);
return;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-29 22:03 UTC · original

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- focused function ---'
sed -n '5620,5745p' tests/ShaderRecompilerComputeTests.cpp
printf '%s\n' '--- declarations and cleanup references ---'
rg -n -C 4 'InstallGpuResources|InitializeGpu|ShutdownGpu|MapMemory|UnmapMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|class RenderContext|struct RenderContext|~RenderContext|class Resources|struct Resources' tests/ShaderRecompilerComputeTests.cpp tests include src 2>/dev/null | sed -n '1,260p'
printf '%s\n' '--- files defining directly bound symbols ---'
rg -l 'InstallGpuResources|KernelReleaseDirectMemory|KernelMapDirectMemory|class RenderContext|struct RenderContext|~RenderContext' . --glob '!build/**' --glob '!node_modules/**' | sed -n '1,120p'

Repository: KytyPS5/KytyPS5

Length of output: 29911


🏁 Script executed:

set -eu
sed -n '5620,5745p' tests/ShaderRecompilerComputeTests.cpp
rg -n -C 4 'InstallGpuResources|InitializeGpu|ShutdownGpu|MapMemory|UnmapMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|~RenderContext' . --glob '!build/**' --glob '!node_modules/**' | sed -n '1,320p'

Repository: KytyPS5/KytyPS5

Length of output: 35642


🏁 Script executed:

set -eu
printf '%s\n' '--- function declaration and prologue ---'
rg -n -B 8 -A 35 'ms_depth_format|unequal-sample|SkipRasterizationCases' tests/ShaderRecompilerComputeTests.cpp | sed -n '1,180p'
printf '%s\n' '--- direct cleanup and GPU-resource bindings ---'
rg -n -C 8 'InstallGpuResources|KernelAllocateDirectMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|InitializeGpu|ShutdownGpu' tests/ShaderRecompilerComputeTests.cpp src/graphics/host_gpu/renderer/renderContext.h src/graphics/host_gpu/renderer/renderContext.cpp src/kernel/memory.h src/kernel/memory.cpp src/libs/libKernel.cpp | sed -n '1,280p'
printf '%s\n' '--- context ownership declarations ---'
sed -n '1,240p' src/graphics/host_gpu/renderer/renderContext.h
rg -n -C 12 'RenderContext::~RenderContext|RenderContext::ShutdownGpu|RenderContext::InitializeGpu|RenderContext::MapMemory|RenderContext::UnmapMemory|InstallGpuResources' src/graphics/host_gpu/renderer/renderContext.cpp src/graphics/host_gpu/renderer/renderContext.h src/libs/libKernel.cpp src/kernel/memory.cpp | sed -n '1,300p'

Repository: KytyPS5/KytyPS5

Length of output: 40738


🏁 Script executed:

set -eu
printf '%s\n' '--- focused test cleanup references ---'
python3 - <<'PY'
from pathlib import Path
p = Path('tests/ShaderRecompilerComputeTests.cpp')
lines = p.read_text().splitlines()
for i, line in enumerate(lines, 1):
    if 4700 <= i <= 6100 and any(x in line for x in (
        'InstallGpuResources', 'InitializeGpu', 'ShutdownGpu', 'MapMemory',
        'UnmapMemory', 'KernelMunmap', 'KernelReleaseDirectMemory',
        'KernelAllocateDirectMemory', 'KernelMapDirectMemory')):
        lo=max(1,i-2); hi=min(len(lines),i+2)
        print(f'--- {lo}-{hi} ---')
        for n in range(lo,hi+1):
            print(f'{n}:{lines[n-1]}')
PY
printf '%s\n' '--- nearby function declarations ---'
sed -n '4680,4740p' tests/ShaderRecompilerComputeTests.cpp
rg -n '^  void Check|^  \};|^};' tests/ShaderRecompilerComputeTests.cpp | awk -F: '$1 >= 4700 && $1 <= 6200' | sed -n '1,100p'

Repository: KytyPS5/KytyPS5

Length of output: 4512


Move the 2-sample format check before resource allocation.

When 2-sample support is unavailable, this return occurs after direct-memory allocation, fixed mapping, InitializeGpu, InstallGpuResources(&resources), and resources.MapMemory. RenderContext::~RenderContext does call ShutdownGpu, but it does not release the direct memory or clear the installed GPU-resource pointer. The return leaves the fixed mapping and a dangling installed pointer that can affect later cases.

Resolve the format beside host_depth_stencil, before creating the context or allocating resources.

Suggested fix
     const auto host_depth_stencil = SupportedDepthStencilFormat(
         vk::Format::eD24UnormS8Uint, vk::SampleCountFlagBits::e1);
-    if (host_depth_stencil == vk::Format::eUndefined) {
+    const auto ms_depth_format =
+        host_depth_stencil == vk::Format::eUndefined
+            ? vk::Format::eUndefined
+            : SupportedDepthStencilFormat(host_depth_stencil,
+                                          vk::SampleCountFlagBits::e2);
+    if (ms_depth_format == vk::Format::eUndefined) {
       SkipRasterizationCases(1);
       return;
     }

Remove the later format lookup and early return. Keep only ms_depth_desc.info.pixel_format = ms_depth_format at that location.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-29 22:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#discussion_r4138806982) _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash set -eu printf '%s\n' '--- focused function ---' sed -n '5620,5745p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- declarations and cleanup references ---' rg -n -C 4 'InstallGpuResources|InitializeGpu|ShutdownGpu|MapMemory|UnmapMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|class RenderContext|struct RenderContext|~RenderContext|class Resources|struct Resources' tests/ShaderRecompilerComputeTests.cpp tests include src 2>/dev/null | sed -n '1,260p' printf '%s\n' '--- files defining directly bound symbols ---' rg -l 'InstallGpuResources|KernelReleaseDirectMemory|KernelMapDirectMemory|class RenderContext|struct RenderContext|~RenderContext' . --glob '!build/**' --glob '!node_modules/**' | sed -n '1,120p' ``` Repository: KytyPS5/KytyPS5 Length of output: 29911 --- 🏁 Script executed: ```bash set -eu sed -n '5620,5745p' tests/ShaderRecompilerComputeTests.cpp rg -n -C 4 'InstallGpuResources|InitializeGpu|ShutdownGpu|MapMemory|UnmapMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|~RenderContext' . --glob '!build/**' --glob '!node_modules/**' | sed -n '1,320p' ``` Repository: KytyPS5/KytyPS5 Length of output: 35642 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- function declaration and prologue ---' rg -n -B 8 -A 35 'ms_depth_format|unequal-sample|SkipRasterizationCases' tests/ShaderRecompilerComputeTests.cpp | sed -n '1,180p' printf '%s\n' '--- direct cleanup and GPU-resource bindings ---' rg -n -C 8 'InstallGpuResources|KernelAllocateDirectMemory|KernelMapDirectMemory|KernelMunmap|KernelReleaseDirectMemory|InitializeGpu|ShutdownGpu' tests/ShaderRecompilerComputeTests.cpp src/graphics/host_gpu/renderer/renderContext.h src/graphics/host_gpu/renderer/renderContext.cpp src/kernel/memory.h src/kernel/memory.cpp src/libs/libKernel.cpp | sed -n '1,280p' printf '%s\n' '--- context ownership declarations ---' sed -n '1,240p' src/graphics/host_gpu/renderer/renderContext.h rg -n -C 12 'RenderContext::~RenderContext|RenderContext::ShutdownGpu|RenderContext::InitializeGpu|RenderContext::MapMemory|RenderContext::UnmapMemory|InstallGpuResources' src/graphics/host_gpu/renderer/renderContext.cpp src/graphics/host_gpu/renderer/renderContext.h src/libs/libKernel.cpp src/kernel/memory.cpp | sed -n '1,300p' ``` Repository: KytyPS5/KytyPS5 Length of output: 40738 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- focused test cleanup references ---' python3 - <<'PY' from pathlib import Path p = Path('tests/ShaderRecompilerComputeTests.cpp') lines = p.read_text().splitlines() for i, line in enumerate(lines, 1): if 4700 <= i <= 6100 and any(x in line for x in ( 'InstallGpuResources', 'InitializeGpu', 'ShutdownGpu', 'MapMemory', 'UnmapMemory', 'KernelMunmap', 'KernelReleaseDirectMemory', 'KernelAllocateDirectMemory', 'KernelMapDirectMemory')): lo=max(1,i-2); hi=min(len(lines),i+2) print(f'--- {lo}-{hi} ---') for n in range(lo,hi+1): print(f'{n}:{lines[n-1]}') PY printf '%s\n' '--- nearby function declarations ---' sed -n '4680,4740p' tests/ShaderRecompilerComputeTests.cpp rg -n '^ void Check|^ \};|^};' tests/ShaderRecompilerComputeTests.cpp | awk -F: '$1 >= 4700 && $1 <= 6200' | sed -n '1,100p' ``` Repository: KytyPS5/KytyPS5 Length of output: 4512 --- </details> **Move the 2-sample format check before resource allocation.** When 2-sample support is unavailable, this return occurs after direct-memory allocation, fixed mapping, `InitializeGpu`, `InstallGpuResources(&resources)`, and `resources.MapMemory`. `RenderContext::~RenderContext` does call `ShutdownGpu`, but it does not release the direct memory or clear the installed GPU-resource pointer. The return leaves the fixed mapping and a dangling installed pointer that can affect later cases. Resolve the format beside `host_depth_stencil`, before creating the context or allocating resources. <details> <summary>Suggested fix</summary> ```diff const auto host_depth_stencil = SupportedDepthStencilFormat( vk::Format::eD24UnormS8Uint, vk::SampleCountFlagBits::e1); - if (host_depth_stencil == vk::Format::eUndefined) { + const auto ms_depth_format = + host_depth_stencil == vk::Format::eUndefined + ? vk::Format::eUndefined + : SupportedDepthStencilFormat(host_depth_stencil, + vk::SampleCountFlagBits::e2); + if (ms_depth_format == vk::Format::eUndefined) { SkipRasterizationCases(1); return; } ``` Remove the later format lookup and early return. Keep only `ms_depth_desc.info.pixel_format = ms_depth_format` at that location. </details> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a3e3dfd8b85d5b12780b4829 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-29 22:03 UTC · original · reviewed

Actionable comments posted: 1

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

1839-1861: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Confirm the helper is only called after EnsureRuntimeContext().

SupportedDepthStencilFormat uses m_runtime_context without calling EnsureRuntimeContext(). Both current callers initialize the context first, so this is correct today.

The method is public. A future caller that skips the initialization would query an empty context. Call EnsureRuntimeContext() inside the helper. The method is const, so the call needs a non-const helper or a mutable context.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 165871d9-9be0-4116-8320-05dd9bf33cff

📥 Commits

Reviewing files that changed from the base of the PR and between 05057c9441 and 2482d13957.

📒 Files selected for processing (1)
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-09-29 22:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#pullrequestreview-5359093926) · **reviewed** **Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp (1)</summary><blockquote> `1839-1861`: _📐 Maintainability & Code Quality_ | _🔵 Trivial_ | _💤 Low value_ **Confirm the helper is only called after `EnsureRuntimeContext()`.** `SupportedDepthStencilFormat` uses `m_runtime_context` without calling `EnsureRuntimeContext()`. Both current callers initialize the context first, so this is correct today. The method is public. A future caller that skips the initialization would query an empty context. Call `EnsureRuntimeContext()` inside the helper. The method is `const`, so the call needs a non-const helper or a `mutable` context. <!-- cr-comment:v1:c8b5df0c0bcfed14f8a3045b --> </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**: `165871d9-9be0-4116-8320-05dd9bf33cff` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 05057c9441dbf3972d49f9143b90213a43a01a00 and 2482d13957bdccd4c005ac2b9152dfbab30d88d4. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠theantipopau on GitHub · 2026-09-29 23:07 UTC · original

Updated failure inventory

With this change the suite runs to completion on my GPU instead of dying at image.cpp:704, so
it is worth restating where the remaining failures actually are. Measured on AMD hardware,
subgroup_size == 64, with #930, #933 and #934 all applied locally:

17 graphics cases skipped   (device rasterization features unavailable, see #875)
4 failures:
  BufferStoreFormatXyzwFloat16ConvertsComponents   1 ULP low
  FloatInlineConstantF16UsesNumericValue           1 ULP low
  VectorFractF16CapturedAndEdges                   1 ULP on several captured edges
  DsAppendAllocatesAcrossWaves32                   allocation histogram collapses

For reference, before #930 the run aborted at CheckUnifiedTextureCacheFlow and nothing after
it ran at all.

The three float16 ones

All three differ by one unit in the last place, in the low direction:

FloatInlineConstantF16UsesNumericValue
  expected [0xaaaa4200, 0x3c004200, 0xbbbb3118]
  actual   [0xaaaa4200, 0x3c004200, 0xbbbb3117]

BufferStoreFormatXyzwFloat16ConvertsComponents
  expected [0xc0003c04, 0x34003800, 0x4200c400, 0x40000000]
  actual   [0xc0003c03, 0x34003800, 0x4200c400, 0x40000000]

VectorFractF16CapturedAndEdges is the same shape but on hardware-captured edge values. The
values involved are subnormal-adjacent, which is where f16 conversion rounding differs between
round-to-nearest-even and the flush-to-zero behaviour of the guest. I read these as expectations
captured from hardware that the SPIR-V path cannot reproduce exactly, rather than as defects in
the conversion, so I have left them alone — changing them would paper over the difference rather
than explain it.

DsAppendAllocatesAcrossWaves32

This one looks like a genuine defect rather than a stale expectation. Details are in #934: the
recompiler never declares SubgroupSizeControl, so on a GPU whose subgroups are 64 wide, a
wave32 shader gets a subgroup twice the guest wave width, and everything that assumes
SubgroupLocalInvocationId is the wave lane stops being true.

Cases that turned out to be wrong expectations, now fixed

Two of the failures I listed earlier were not emulator bugs at all, and are corrected in #933:

  • BranchVccnzUsesWaveMask asserted an all-uniform result for a per-lane branch.
  • BranchVccnzUsesCarryProducedWaveMask used V_CMP_F_U32, whose implicit src2 of 0 is the
    "always false" predicate, so it never actually supplied the carry-in it was written to test.

And BufferStoreFormatXAddTidUsesLaneIndex (#934) had an expectation that depended on the host
choosing 32-wide subgroups, which nothing guarantees.

**@⁠theantipopau** on GitHub · 2026-09-29 23:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#issuecomment-5900784615) ## Updated failure inventory With this change the suite runs to completion on my GPU instead of dying at `image.cpp:704`, so it is worth restating where the remaining failures actually are. Measured on AMD hardware, `subgroup_size == 64`, with #930, #933 and #934 all applied locally: ``` 17 graphics cases skipped (device rasterization features unavailable, see #875) 4 failures: BufferStoreFormatXyzwFloat16ConvertsComponents 1 ULP low FloatInlineConstantF16UsesNumericValue 1 ULP low VectorFractF16CapturedAndEdges 1 ULP on several captured edges DsAppendAllocatesAcrossWaves32 allocation histogram collapses ``` For reference, before #930 the run aborted at `CheckUnifiedTextureCacheFlow` and nothing after it ran at all. ### The three float16 ones All three differ by one unit in the last place, in the low direction: ``` FloatInlineConstantF16UsesNumericValue expected [0xaaaa4200, 0x3c004200, 0xbbbb3118] actual [0xaaaa4200, 0x3c004200, 0xbbbb3117] BufferStoreFormatXyzwFloat16ConvertsComponents expected [0xc0003c04, 0x34003800, 0x4200c400, 0x40000000] actual [0xc0003c03, 0x34003800, 0x4200c400, 0x40000000] ``` `VectorFractF16CapturedAndEdges` is the same shape but on hardware-captured edge values. The values involved are subnormal-adjacent, which is where f16 conversion rounding differs between round-to-nearest-even and the flush-to-zero behaviour of the guest. I read these as expectations captured from hardware that the SPIR-V path cannot reproduce exactly, rather than as defects in the conversion, so I have left them alone — changing them would paper over the difference rather than explain it. ### `DsAppendAllocatesAcrossWaves32` This one looks like a genuine defect rather than a stale expectation. Details are in #934: the recompiler never declares `SubgroupSizeControl`, so on a GPU whose subgroups are 64 wide, a wave32 shader gets a subgroup twice the guest wave width, and everything that assumes `SubgroupLocalInvocationId` is the wave lane stops being true. ### Cases that turned out to be wrong expectations, now fixed Two of the failures I listed earlier were not emulator bugs at all, and are corrected in #933: - `BranchVccnzUsesWaveMask` asserted an all-uniform result for a per-lane branch. - `BranchVccnzUsesCarryProducedWaveMask` used `V_CMP_F_U32`, whose implicit `src2` of 0 is the "always false" predicate, so it never actually supplied the carry-in it was written to test. And `BufferStoreFormatXAddTidUsesLaneIndex` (#934) had an expectation that depended on the host choosing 32-wide subgroups, which nothing guarantees.
Author
Owner

@⁠MuteRex on GitHub · 2026-10-21 13:42 UTC · original

Retested on current main (4644c52, 2026-10-21) on AMD RDNA4, and this is still needed. I'm asking for it to be reopened.

Hardware: RX 9060 XT (RADV GFX1200), Mesa 26.0.8, Ubuntu 26.04, kernel 7.0.0-38

On current main, the hardcoded D24S8 now breaks 6 test cases, up from 3 when this PR was opened. All of them die at image.cpp:725 with image format does not support required usage: format=129 type=1 usage=0x23:

  • texture_cache_layered_image, texture_cache_image_views, texture_cache_storage_sampled (samples=1)
  • texture_cache_image_overlap, texture_cache_htile_clear, buffer_cache_ranges (samples=2)

RADV on GFX1200 doesn't support VK_FORMAT_D24_UNORM_S8_UINT for that usage, while D32_SFLOAT_S8_UINT is supported (checked with a small vkGetPhysicalDeviceImageFormatProperties program, included).

Build Result
main 4644c52 12 failed / 57
main 4644c52 + this PR 6 failed / 57 (all 6 D24S8 cases pass)

The diff no longer applies cleanly to main. One hunk in tests/ShaderRecompilerComputeTests.cpp conflicted because of context drift. I re-placed it at the same spot (right after EnsureRuntimeContext() in that harness function), and that rebased diff is in the zip. The remaining failures are unrelated: gpu_tiler (fixed by #795), shader_recompiler_compute (BoundedRecordBufferAccess32), and 4 emulator CLI tests that only show "Not Run" because I built kyty_tests without the emulator.

Logs for all three runs, the rebased diff and the format check are attached.

AI assistance (Claude) was used to rebase the diff, run the suites and summarise the logs. I ran the tests on my own hardware and reviewed the results.

kytyps5-rdna4-pr-tests.zip

**@⁠MuteRex** on GitHub · 2026-10-21 13:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#issuecomment-6317573303) Retested on current main (4644c52, 2026-10-21) on AMD RDNA4, and this is still needed. I'm asking for it to be reopened. **Hardware:** RX 9060 XT (RADV GFX1200), Mesa 26.0.8, Ubuntu 26.04, kernel 7.0.0-38 On current main, the hardcoded D24S8 now breaks **6** test cases, up from 3 when this PR was opened. All of them die at `image.cpp:725` with `image format does not support required usage: format=129 type=1 usage=0x23`: - `texture_cache_layered_image`, `texture_cache_image_views`, `texture_cache_storage_sampled` (samples=1) - `texture_cache_image_overlap`, `texture_cache_htile_clear`, `buffer_cache_ranges` (samples=2) RADV on GFX1200 doesn't support `VK_FORMAT_D24_UNORM_S8_UINT` for that usage, while `D32_SFLOAT_S8_UINT` is supported (checked with a small `vkGetPhysicalDeviceImageFormatProperties` program, included). | Build | Result | |---|---| | main 4644c52 | 12 failed / 57 | | main 4644c52 + this PR | 6 failed / 57 (all 6 D24S8 cases pass) | The diff no longer applies cleanly to main. One hunk in `tests/ShaderRecompilerComputeTests.cpp` conflicted because of context drift. I re-placed it at the same spot (right after `EnsureRuntimeContext()` in that harness function), and that rebased diff is in the zip. The remaining failures are unrelated: `gpu_tiler` (fixed by #795), `shader_recompiler_compute` (`BoundedRecordBufferAccess32`), and 4 emulator CLI tests that only show "Not Run" because I built `kyty_tests` without the emulator. Logs for all three runs, the rebased diff and the format check are attached. *AI assistance (Claude) was used to rebase the diff, run the suites and summarise the logs. I ran the tests on my own hardware and reviewed the results.* [kytyps5-rdna4-pr-tests.zip](https://github.com/user-attachments/files/33771483/kytyps5-rdna4-pr-tests.zip)
Author
Owner

@⁠theantipopau on GitHub · 2026-10-22 03:24 UTC · original

@⁠MuteRex thanks for the retest — that is exactly the failure mode this was meant to fix, and your numbers (12 failed / 57 on main, 6 of them cleared by this change) are now recorded in the continuation PR.

GitHub refuses to reopen this one: gh pr reopen 930 returns reopenPullRequest: Could not open the pull request after the branch was force-pushed to rebase it. I rebased the identical change onto current main (7b7f9a70) and opened #1811 with that branch, so the work is reviewable there rather than lost in this closed thread. The only difference from the diff you tested is formatting at the rebased hunk.

Your point about the remaining failures still stands: with #1811 applied the run should stop aborting on D24S8 and report the real failures instead. If you are willing, a rerun of shader_recompiler_compute_tests against #1811 would confirm the six D24S8 aborts are gone on RADV; the other failures you listed (gpu_tiler, BoundedRecordBufferAccess32) are tracked separately.

**@⁠theantipopau** on GitHub · 2026-10-22 03:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/930#issuecomment-6331898711) @⁠MuteRex thanks for the retest — that is exactly the failure mode this was meant to fix, and your numbers (12 failed / 57 on `main`, 6 of them cleared by this change) are now recorded in the continuation PR. GitHub refuses to reopen this one: `gh pr reopen 930` returns `reopenPullRequest: Could not open the pull request` after the branch was force-pushed to rebase it. I rebased the identical change onto current `main` (7b7f9a70) and opened #1811 with that branch, so the work is reviewable there rather than lost in this closed thread. The only difference from the diff you tested is formatting at the rebased hunk. Your point about the remaining failures still stands: with #1811 applied the run should stop aborting on D24S8 and report the real failures instead. If you are willing, a rerun of `shader_recompiler_compute_tests` against #1811 would confirm the six D24S8 aborts are gone on RADV; the other failures you listed (`gpu_tiler`, `BoundedRecordBufferAccess32`) are tracked separately.

Pull request closed

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