renderer: drop compare state when a compare sampler is paired with a colour view #1625

Open
github-bot wants to merge 2 commits from github-bot/gh-1625 into main AGit
Owner

@⁠ricardocacco on GitHub · 2026-10-17 22:39 UTC · original
ricardocacco:guard-compare-sampler → main · +37 −3 · 1 files · 2 commits · open

What happens

On Astro Bot (PPSA21567) the recompiler emits a compute shader whose descriptor set pairs a depth-comparison sampler with a colour image view (VK_FORMAT_R32_SFLOAT). The validation layer reports, at vkCmdDispatch:

VUID-vkCmdDispatch-None-06479

which is precisely that rule: a comparison sampler may only be combined with a depth/stencil image view. The sample itself is undefined either way, but on this machine the illegal combination ends in an NVIDIA device lost (nvlddmkm Event ID 153, "Error occurred on GPUID: 100", same second) and the renderer surfaces it as

Not implemented (result != vk::Result::eSuccess) in src/graphics/host_gpu/renderer/masterSemaphore.cpp:53

i.e. EXIT_NOT_IMPLEMENTED(result != vk::Result::eSuccess) after device.waitSemaphores(&wait_info, UINT64_MAX) stops returning eSuccess. Nothing in that message names the binding, which is what makes the failure expensive to diagnose.

What this patch does

ShaderInfo::sampled_pairs already carries the exact image/sampler pairing for each compiled program. RenderExecutor::PrepareBindings now walks that list: if a sampler with depth_compare == true is paired with a bound image whose info.IsDepth() is false, it clears the compare-enable bit (fields[0] &= ~(0x7u << 12u), the same mask the non-compare path already clears) and logs the shader hash and stage.

No defined information is lost — the descriptor was already illegal and the sampled value undefined. What changes is that the failure becomes a named log line instead of a GPU hang.

Caveats

  • This is a diagnostic guard, not a correctness fix. The open question is why the guest binds a compare sampler against a colour view at all (image's depth_compare comes from ImageSampleFlagCompare in ResourceTracking::AddImage(), while the paired sampler's DepthCompareFunc() != 0); I have not root-caused that.
  • Compile-verified locally with the same compiler family CI uses: clang-cl 23.1.3 (MSVC 19.44 headers) run against the exact command line CMake generates for this translation unit (-std:c++20 /W3, -O2, same includes/macros): zero errors, zero warnings, both before and after the change. The full link was not exercised here. CI for this PR is currently action_required (first-time contributor, needs a maintainer to approve the run), so the build matrix is still the authority.
  • A hard EXIT on the mismatch may be the better behaviour for a debug build; I opted not to abort on a case that today "only" hangs the GPU. Happy to switch if you prefer.
  • For this title the FindImage/exact_format aliasing floated in #1476 does not apply: Bit32 & D32 != D32 and SameBacking() also checks tile_mode, and FindGuestDepthFormatPolicy(k32Float) exists, so the depth-format table is not the gap.

Context

  • Validation capture and analysis: #1476
  • Original report of this crash class: #1602

Environment of the capture: Windows 11, RTX 5060 Ti 16 GB, NVIDIA 617.42, Vulkan SDK 1.4.363 validation layers, build bd8f0da.


**@⁠ricardocacco** on GitHub · 2026-10-17 22:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625) `ricardocacco:guard-compare-sampler` → `main` · +37 −3 · 1 files · 2 commits · open ## What happens On Astro Bot (PPSA21567) the recompiler emits a compute shader whose descriptor set pairs a depth-comparison sampler with a **colour** image view (`VK_FORMAT_R32_SFLOAT`). The validation layer reports, at `vkCmdDispatch`: ``` VUID-vkCmdDispatch-None-06479 ``` which is precisely that rule: a comparison sampler may only be combined with a depth/stencil image view. The sample itself is undefined either way, but on this machine the illegal combination ends in an NVIDIA device lost (`nvlddmkm` Event ID 153, "Error occurred on GPUID: 100", same second) and the renderer surfaces it as ``` Not implemented (result != vk::Result::eSuccess) in src/graphics/host_gpu/renderer/masterSemaphore.cpp:53 ``` i.e. `EXIT_NOT_IMPLEMENTED(result != vk::Result::eSuccess)` after `device.waitSemaphores(&wait_info, UINT64_MAX)` stops returning `eSuccess`. Nothing in that message names the binding, which is what makes the failure expensive to diagnose. ## What this patch does `ShaderInfo::sampled_pairs` already carries the exact image/sampler pairing for each compiled program. `RenderExecutor::PrepareBindings` now walks that list: if a sampler with `depth_compare == true` is paired with a bound image whose `info.IsDepth()` is false, it clears the compare-enable bit (`fields[0] &= ~(0x7u << 12u)`, the same mask the non-compare path already clears) and logs the shader hash and stage. No defined information is lost — the descriptor was already illegal and the sampled value undefined. What changes is that the failure becomes a named log line instead of a GPU hang. ## Caveats * This is a **diagnostic guard, not a correctness fix**. The open question is why the guest binds a compare sampler against a colour view at all (image's `depth_compare` comes from `ImageSampleFlagCompare` in `ResourceTracking::AddImage()`, while the paired sampler's `DepthCompareFunc() != 0`); I have not root-caused that. * **Compile-verified locally** with the same compiler family CI uses: `clang-cl 23.1.3` (MSVC 19.44 headers) run against the exact command line CMake generates for this translation unit (`-std:c++20 /W3`, `-O2`, same includes/macros): zero errors, zero warnings, both before and after the change. The full link was not exercised here. CI for this PR is currently `action_required` (first-time contributor, needs a maintainer to approve the run), so the build matrix is still the authority. * A hard `EXIT` on the mismatch may be the better behaviour for a debug build; I opted not to abort on a case that today "only" hangs the GPU. Happy to switch if you prefer. * For this title the `FindImage`/`exact_format` aliasing floated in #1476 does not apply: `Bit32 & D32 != D32` and `SameBacking()` also checks `tile_mode`, and `FindGuestDepthFormatPolicy(k32Float)` exists, so the depth-format table is not the gap. ## Context * Validation capture and analysis: https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1476 * Original report of this crash class: #1602 Environment of the capture: Windows 11, RTX 5060 Ti 16 GB, NVIDIA 617.42, Vulkan SDK 1.4.363 validation layers, build `bd8f0da`. --- [![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
Guests can bind a depth-compare sampler to a colour image view. Vulkan only
allows a comparison sampler on a depth/stencil view (validation reports
VUID-vkCmdDispatch-None-06479) and the sampled value is undefined either way,
but on some drivers the illegal combination ends in VK_ERROR_DEVICE_LOST, which
the renderer surfaces as a generic "Not implemented (result != vk::Result::eSuccess)"
without naming the offending binding.

Walk ShaderInfo::sampled_pairs, and when a compare sampler is paired with a
view that is not a depth image, clear the compare-enable bit and log the shader
hash so the guest bug shows up in the log instead of hanging the GPU. The bit
is the same one the non-compare path already clears, so behaviour is otherwise
unchanged.
The depth check indexed the texture cache with the prepared binding id, which is
INVALID for a null descriptor and stale once the image is retired; TextureCache::GetImage
asserts on such ids and aborts the emulator. Use try_get and leave the sampler alone.

Found by running ASTRO BOT (PPSA21567) locally with this patch applied.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:01:54 +00:00
Author
Owner

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

Review in Change Stack →

📝 Walkthrough

PrepareBindings checks sampled image and sampler pairs that use depth comparison. If a paired image is not a depth image, it disables comparison for that sampler and logs the shader hash and stage when a mismatch occurs. NativeSampler now accepts this per-sampler permission and clears compare state when comparison is not allowed.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to 70ae8

The guard avoids the invalid compare-sampler and colour-view pairing in the common case. In rare cases a rebound image could still change type after the check, so the validation error could recur. Consider recomputing eligibility after rebinding.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main renderer change: removing compare state when a comparison sampler is paired with a colour view.
Description check Passed The description directly explains the Vulkan validation failure, the implemented guard, its diagnostic purpose, limitations, testing, and handling of null or retired bindings.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 22:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-6242624782) · edited 2026-10-17 23:25 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/1625?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> `PrepareBindings` checks sampled image and sampler pairs that use depth comparison. If a paired image is not a depth image, it disables comparison for that sampler and logs the shader hash and stage when a mismatch occurs. `NativeSampler` now accepts this per-sampler permission and clears compare state when comparison is not allowed. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"70ae891d260541e0ceedf32705bd0437fba9a058" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>70ae8</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `70ae8` --> <!-- final_review_risk_coverage:{"sourceCommitId":"70ae891d260541e0ceedf32705bd0437fba9a058","coveredCommitId":"70ae891d260541e0ceedf32705bd0437fba9a058","kind":"reviewed"} --> The guard avoids the invalid compare-sampler and colour-view pairing in the common case. In rare cases a rebound image could still change type after the check, so the validation error could recur. Consider recomputing eligibility after rebinding. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main renderer change: removing compare state when a comparison sampler is paired with a colour view. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the Vulkan validation failure, the implemented guard, its diagnostic purpose, limitations, testing, and handling of null or retired bindings. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1625)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 22:53 UTC · original · edited 2026-10-17 23:21 UTC
On src/graphics/host_gpu/renderer/pipeline/descriptors.cpp line 727 (outdated):

@@ -709,10 +710,37 @@ void RenderExecutor::PrepareBindings(const ShaderStageRuntime& runtime,
 		binding.mip_views.clear();
 		prepared.images[i] = std::move(binding);
 	}
+	// A comparison sampler may only be combined with a depth/stencil image view
+	// (VUID-vkCmdDispatch-None-06479). Guests can pair a compare sampler with a colour view;
+	// that is undefined behaviour for the host GPU and has been observed to end in a device
+	// lost. The sampled value is undefined either way, so drop the compare state on the
+	// offending samplers to keep the binding legal and make the guest bug visible instead of
+	// hanging the GPU.
+	std::vector<bool> sampler_compare_ok(program.info.samplers.size(), true);
+	bool              guest_compare_mismatch = false;
+	for (const auto& pair: program.info.sampled_pairs) {
+		if (pair.image >= prepared.images.size() || pair.sampler >= program.info.samplers.size() ||
+		    !program.info.samplers[pair.sampler].depth_compare) {
+			continue;
+		}
+		const auto& bound = prepared.images[pair.image];
+		const auto& image = m_context.GetTextureCache().GetImage(bound.image_id);

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C4 '\bImage&\s+TextureCache::GetImage\s*\(|\bGetImage\s*\(ImageId' src/graphics/host_gpu/renderer

Repository: KytyPS5/KytyPS5

Length of output: 1090


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- diff ---'
git diff --unified=30 763d3be3a9bc4e5a068d7cf52015030d6c03308f ba536173c0eb14cd1b8cedec1a1dcfabd534084f -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
printf '%s\n' '--- relevant symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'ResolveTexture' -e 'MakeImageInfo' -e 'RebindImages' -e 'struct ImageId' -e 'class ImageId' -e 'using ImageId' -e 'm_slot_images' src/graphics/host_gpu/renderer
printf '%s\n' '--- ImageId and resolver context ---'
rg -n -C12 -F --glob '*.{cpp,h,hpp}' -e 'struct ImageId' -e 'class ImageId' -e 'using ImageId' -e 'ResolveTexture' -e 'm_slot_images' src/graphics/host_gpu/renderer

Repository: KytyPS5/KytyPS5

Length of output: 42191


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- resolver and related binding code ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '70,105p;475,625p;830,865p'
printf '%s\n' '--- ImageId and SlotId definitions ---'
rg -n -F --glob '*.{h,hpp,cpp}' -e 'class SlotId' -e 'struct SlotId' -e 'using SlotId' -e 'class SlotVector' -e 'struct SlotVector' -e 'operator[](.*SlotId' src common
printf '%s\n' '--- slot container implementation ---'
rg -n -C8 -F --glob '*.{h,hpp,cpp}' -e 'class SlotVector' -e 'struct SlotVector' -e 'operator[](SlotId' src common

Repository: KytyPS5/KytyPS5

Length of output: 13055


🏁 Script executed:

#!/bin/bash
set -e
nl -ba src/common/slotVector.h | sed -n '1,130p'
printf '%s\n' '--- texture cache declaration ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.h | sed -n '48,70p;160,180p'

Repository: KytyPS5/KytyPS5

Length of output: 7489


Guard against a null bound.image_id before GetImage.

ResolveTexture returns a binding without an image_id for a null descriptor. The new loop passes that ID to TextureCache::GetImage. SlotVector::operator[] rejects the invalid ID with EXIT_IF(!is_allocated(id)). A compare sampler paired with a null image can therefore terminate binding preparation.

Proposed fix
--- "a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp"
+++ "b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp"
@@ -723,8 +723,11 @@
 		    !program.info.samplers[pair.sampler].depth_compare) {
 			continue;
 		}
 		const auto& bound = prepared.images[pair.image];
+		if (!bound.image_id) {
+			continue;
+		}
 		const auto& image = m_context.GetTextureCache().GetImage(bound.image_id);
 		if (!image.info.IsDepth()) {
 			sampler_compare_ok[pair.sampler] = false;
 			guest_compare_mismatch           = true;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		const auto& bound = prepared.images[pair.image];
		if (!bound.image_id) {
			continue;
		}
		const auto& image = m_context.GetTextureCache().GetImage(bound.image_id);

✅ Addressed in commit 70ae891

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 22:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#discussion_r4304858296) · edited 2026-10-17 23:21 UTC On `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` line 727 (outdated): ```diff @@ -709,10 +710,37 @@ void RenderExecutor::PrepareBindings(const ShaderStageRuntime& runtime, binding.mip_views.clear(); prepared.images[i] = std::move(binding); } + // A comparison sampler may only be combined with a depth/stencil image view + // (VUID-vkCmdDispatch-None-06479). Guests can pair a compare sampler with a colour view; + // that is undefined behaviour for the host GPU and has been observed to end in a device + // lost. The sampled value is undefined either way, so drop the compare state on the + // offending samplers to keep the binding legal and make the guest bug visible instead of + // hanging the GPU. + std::vector<bool> sampler_compare_ok(program.info.samplers.size(), true); + bool guest_compare_mismatch = false; + for (const auto& pair: program.info.sampled_pairs) { + if (pair.image >= prepared.images.size() || pair.sampler >= program.info.samplers.size() || + !program.info.samplers[pair.sampler].depth_compare) { + continue; + } + const auto& bound = prepared.images[pair.image]; + const auto& image = m_context.GetTextureCache().GetImage(bound.image_id); ``` **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash rg -nP -C4 '\bImage&\s+TextureCache::GetImage\s*\(|\bGetImage\s*\(ImageId' src/graphics/host_gpu/renderer ``` Repository: KytyPS5/KytyPS5 Length of output: 1090 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- diff ---' git diff --unified=30 763d3be3a9bc4e5a068d7cf52015030d6c03308f ba536173c0eb14cd1b8cedec1a1dcfabd534084f -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp printf '%s\n' '--- relevant symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'ResolveTexture' -e 'MakeImageInfo' -e 'RebindImages' -e 'struct ImageId' -e 'class ImageId' -e 'using ImageId' -e 'm_slot_images' src/graphics/host_gpu/renderer printf '%s\n' '--- ImageId and resolver context ---' rg -n -C12 -F --glob '*.{cpp,h,hpp}' -e 'struct ImageId' -e 'class ImageId' -e 'using ImageId' -e 'ResolveTexture' -e 'm_slot_images' src/graphics/host_gpu/renderer ``` Repository: KytyPS5/KytyPS5 Length of output: 42191 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- resolver and related binding code ---' nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '70,105p;475,625p;830,865p' printf '%s\n' '--- ImageId and SlotId definitions ---' rg -n -F --glob '*.{h,hpp,cpp}' -e 'class SlotId' -e 'struct SlotId' -e 'using SlotId' -e 'class SlotVector' -e 'struct SlotVector' -e 'operator[](.*SlotId' src common printf '%s\n' '--- slot container implementation ---' rg -n -C8 -F --glob '*.{h,hpp,cpp}' -e 'class SlotVector' -e 'struct SlotVector' -e 'operator[](SlotId' src common ``` Repository: KytyPS5/KytyPS5 Length of output: 13055 --- 🏁 Script executed: ```bash #!/bin/bash set -e nl -ba src/common/slotVector.h | sed -n '1,130p' printf '%s\n' '--- texture cache declaration ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.h | sed -n '48,70p;160,180p' ``` Repository: KytyPS5/KytyPS5 Length of output: 7489 --- </details> **Guard against a null `bound.image_id` before `GetImage`.** `ResolveTexture` returns a binding without an `image_id` for a null descriptor. The new loop passes that ID to `TextureCache::GetImage`. `SlotVector::operator[]` rejects the invalid ID with `EXIT_IF(!is_allocated(id))`. A compare sampler paired with a null image can therefore terminate binding preparation. <details> <summary>Proposed fix</summary> ```diff --- "a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp" +++ "b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp" @@ -723,8 +723,11 @@ !program.info.samplers[pair.sampler].depth_compare) { continue; } const auto& bound = prepared.images[pair.image]; + if (!bound.image_id) { + continue; + } const auto& image = m_context.GetTextureCache().GetImage(bound.image_id); if (!image.info.IsDepth()) { sampler_compare_ok[pair.sampler] = false; guest_compare_mismatch = true; ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion const auto& bound = prepared.images[pair.image]; if (!bound.image_id) { continue; } const auto& image = m_context.GetTextureCache().GetImage(bound.image_id); ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:poseidon:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:6ec12dedbd7745782d91e896 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 70ae891
Author
Owner

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d0fe02a-605f-479d-8c37-613f078abd14
📥 Commits

Reviewing files that changed from the base of the PR and between 763d3be3a9 and ba536173c0.

📒 Files selected for processing: 1
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 22:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#pullrequestreview-5560496239) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `4d0fe02a-605f-479d-8c37-613f078abd14` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 763d3be3a9bc4e5a068d7cf52015030d6c03308f and ba536173c0eb14cd1b8cedec1a1dcfabd534084f. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=46cbdd81-971d-4d63-a264-21d63277967d attempt=be114b90-c959-4b11-ac6e-7b922785039b batch=1/1 -->
Author
Owner

@⁠ricardocacco on GitHub · 2026-10-17 23:21 UTC · original

Pushed 70ae891: the depth check indexed the texture cache with the prepared binding id, which is INVALID for a null descriptor and stale once the image is retired. TextureCache::GetImage asserts on both and aborts with slotVector.h:41; the guard now uses m_slot_images.try_get and leaves the sampler alone for those bindings.

Found by running ASTRO BOT (PPSA21567) locally with this patch on top of the #1528 SRT fix: without it the emulator dies with was !is_allocated(id), with it the game gets past asset loading and pipeline creation and the next fatal is a GPU device loss, which this patch does not cover.

**@⁠ricardocacco** on GitHub · 2026-10-17 23:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-6243009219) Pushed 70ae891: the depth check indexed the texture cache with the prepared binding id, which is INVALID for a null descriptor and stale once the image is retired. TextureCache::GetImage asserts on both and aborts with slotVector.h:41; the guard now uses m_slot_images.try_get and leaves the sampler alone for those bindings. Found by running ASTRO BOT (PPSA21567) locally with this patch on top of the #1528 SRT fix: without it the emulator dies with was !is_allocated(id), with it the game gets past asset loading and pipeline creation and the next fatal is a GPU device loss, which this patch does not cover.
@ -712,0 +727,4 @@
// Null and already-retired bindings have no image to inspect; the descriptor path
// reports those on its own, so leave the sampler untouched here.
const auto* image =
m_context.GetTextureCache().m_slot_images.try_get(bound.image_id);
Author
Owner

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- diff ---'
git diff --no-ext-diff --unified=80 763d3be3a9bc4e5a068d7cf52015030d6c03308f 70ae891d260541e0ceedf32705bd0437fba9a058 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
printf '%s\n' '--- bindings symbols ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'PrepareBindings' -e 'RebindImages' -e 'ResolveTexture' -e 'sampled_pairs' src/graphics/host_gpu

Repository: KytyPS5/KytyPS5

Length of output: 15703


🏁 Script executed:

set -eu
printf '%s\n' '--- RebindImages and commit ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '820,930p'
printf '%s\n' '--- compute call sequences ---'
nl -ba src/graphics/host_gpu/renderer/renderCompute.cpp | sed -n '300,370p;440,495p'
printf '%s\n' '--- draw call sequences ---'
nl -ba src/graphics/host_gpu/renderer/renderDraw.cpp | sed -n '1125,1185p'
printf '%s\n' '--- PreparedBindings declarations ---'
nl -ba src/graphics/host_gpu/renderer/render.h | sed -n '125,190p'

Repository: KytyPS5/KytyPS5

Length of output: 19842


🏁 Script executed:

set -eu
printf '%s\n' '--- ResolveTexture ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '470,635p'
printf '%s\n' '--- FindImage declarations and definitions ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'FindImage' -e 'IsDepth' -e 'struct ImageInfo' -e 'class TextureCache' src/graphics
printf '%s\n' '--- texture cache files ---'
rg --files src/graphics | rg 'texture|image|cache' | head -80

Repository: KytyPS5/KytyPS5

Length of output: 18162


🏁 Script executed:

set -eu
printf '%s\n' '--- ImageInfo depth definition ---'
nl -ba src/graphics/host_gpu/renderer/image/imageInfo.h | sed -n '60,120p;235,260p'
printf '%s\n' '--- TextureCache FindImage ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '600,720p;1170,1295p'
printf '%s\n' '--- ImageDesc and cache declarations ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.h | sed -n '38,90p'

Repository: KytyPS5/KytyPS5

Length of output: 19332


🏁 Script executed:

set -eu
printf '%s\n' '--- SameBacking and overlap dispatch ---'
rg -n -F --glob 'src/graphics/host_gpu/renderer/cache/textureCache.cpp' -e 'bool TextureCache::SameBacking' -e 'SameBacking(' -e 'ResolveOverlap' -e 'ResolveDepthOverlap'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1,90p;390,590p'

Repository: KytyPS5/KytyPS5

Length of output: 14682


🏁 Script executed:

set -eu
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '135,180p;720,810p'

Repository: KytyPS5/KytyPS5

Length of output: 6252


🏁 Script executed:

set -eu
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '810,855p'

Repository: KytyPS5/KytyPS5

Length of output: 2807


🏁 Script executed:

set -eu
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '849,895p'

Repository: KytyPS5/KytyPS5

Length of output: 2505


🏁 Script executed:

set -eu
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '925,1075p'

Repository: KytyPS5/KytyPS5

Length of output: 8947


🏁 Script executed:

set -eu
nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '1070,1155p'

Repository: KytyPS5/KytyPS5

Length of output: 4254


Recompute compare eligibility after RebindImages.

When RebindImages replaces a paired image, recompute sampler_compare_ok before creating or committing the sampler. A non-depth request can initially resolve to a cached depth image, then resolve to a color image after the cached image is retired. CommitBindings uses the rebound image view with the sampler created earlier, which can recreate the Vulkan validation error.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 23:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#discussion_r4304958114) **🩺 Stability & Availability** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash set -eu printf '%s\n' '--- diff ---' git diff --no-ext-diff --unified=80 763d3be3a9bc4e5a068d7cf52015030d6c03308f 70ae891d260541e0ceedf32705bd0437fba9a058 -- src/graphics/host_gpu/renderer/pipeline/descriptors.cpp printf '%s\n' '--- bindings symbols ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'PrepareBindings' -e 'RebindImages' -e 'ResolveTexture' -e 'sampled_pairs' src/graphics/host_gpu ``` Repository: KytyPS5/KytyPS5 Length of output: 15703 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- RebindImages and commit ---' nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '820,930p' printf '%s\n' '--- compute call sequences ---' nl -ba src/graphics/host_gpu/renderer/renderCompute.cpp | sed -n '300,370p;440,495p' printf '%s\n' '--- draw call sequences ---' nl -ba src/graphics/host_gpu/renderer/renderDraw.cpp | sed -n '1125,1185p' printf '%s\n' '--- PreparedBindings declarations ---' nl -ba src/graphics/host_gpu/renderer/render.h | sed -n '125,190p' ``` Repository: KytyPS5/KytyPS5 Length of output: 19842 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- ResolveTexture ---' nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '470,635p' printf '%s\n' '--- FindImage declarations and definitions ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'FindImage' -e 'IsDepth' -e 'struct ImageInfo' -e 'class TextureCache' src/graphics printf '%s\n' '--- texture cache files ---' rg --files src/graphics | rg 'texture|image|cache' | head -80 ``` Repository: KytyPS5/KytyPS5 Length of output: 18162 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- ImageInfo depth definition ---' nl -ba src/graphics/host_gpu/renderer/image/imageInfo.h | sed -n '60,120p;235,260p' printf '%s\n' '--- TextureCache FindImage ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '600,720p;1170,1295p' printf '%s\n' '--- ImageDesc and cache declarations ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.h | sed -n '38,90p' ``` Repository: KytyPS5/KytyPS5 Length of output: 19332 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- SameBacking and overlap dispatch ---' rg -n -F --glob 'src/graphics/host_gpu/renderer/cache/textureCache.cpp' -e 'bool TextureCache::SameBacking' -e 'SameBacking(' -e 'ResolveOverlap' -e 'ResolveDepthOverlap' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1,90p;390,590p' ``` Repository: KytyPS5/KytyPS5 Length of output: 14682 --- 🏁 Script executed: ```bash set -eu nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '135,180p;720,810p' ``` Repository: KytyPS5/KytyPS5 Length of output: 6252 --- 🏁 Script executed: ```bash set -eu nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '810,855p' ``` Repository: KytyPS5/KytyPS5 Length of output: 2807 --- 🏁 Script executed: ```bash set -eu nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '849,895p' ``` Repository: KytyPS5/KytyPS5 Length of output: 2505 --- 🏁 Script executed: ```bash set -eu nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '925,1075p' ``` Repository: KytyPS5/KytyPS5 Length of output: 8947 --- 🏁 Script executed: ```bash set -eu nl -ba src/graphics/host_gpu/renderer/pipeline/descriptors.cpp | sed -n '1070,1155p' ``` Repository: KytyPS5/KytyPS5 Length of output: 4254 --- </details> **Recompute compare eligibility after `RebindImages`.** When `RebindImages` replaces a paired image, recompute `sampler_compare_ok` before creating or committing the sampler. A non-depth request can initially resolve to a cached depth image, then resolve to a color image after the cached image is retired. `CommitBindings` uses the rebound image view with the sampler created earlier, which can recreate the Vulkan validation error. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:7f265854f907636942ecfb51 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8568777f-635a-4373-970c-5fb3211ddf5d
📥 Commits

Reviewing files that changed from the base of the PR and between ba536173c0 and 70ae891d26.

📒 Files selected for processing: 1
  • src/graphics/host_gpu/renderer/pipeline/descriptors.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-10-17 23:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#pullrequestreview-5560610145) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8568777f-635a-4373-970c-5fb3211ddf5d` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between ba536173c0eb14cd1b8cedec1a1dcfabd534084f and 70ae891d260541e0ceedf32705bd0437fba9a058. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.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 --> <!-- coderabbit-review-publication v1 publication=cbfaaeb1-2f0a-40d3-8f80-11e026ef1d38 attempt=ea57d7f6-61f0-4294-bf2c-af9e602ddb4c batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-19 17:16 UTC · original

@⁠ricardocacco I traced the shared-sampler case behind the guard in this PR. Here is the root cause and a tested fix.

Root cause. AddSampler returns an existing entry when m_info.samplers[i].source == source (ResourceTracking.cpp:3827-3833), so compare state is not part of the key. Image entries do include depth_compare in their key (ResourceTracking.cpp:3793). A guest sampler can be used by both of these:

  • an IMAGE_SAMPLE_C, whose image gets a D32 view (descriptors.cpp:553-556);
  • a plain IMAGE_SAMPLE of a k32Float texture (R32_SFLOAT view).

ResourceMaterialization.cpp:1853 then merges the two uses:

samplers[pair.sampler].depth_compare |= images[pair.image].depth_compare;

The result is one sampler with compare enabled for both pairs. descriptors.cpp:640-641 clears S# bits 14:12 (the RDNA2 compare func) only when depth_compare is false. For the plain sample, Vulkan Texel Input Operations makes the texel poison: "The SPIR-V instruction is not one of the OpImage*Dref* instructions and the sampler compareEnable is VK_TRUE". #1476 has two NVIDIA logs showing an R32_SFLOAT view without SAMPLED_IMAGE_DEPTH_COMPARISON:

  • VUID-vkCmdDrawIndexed-None-06479 (binding 80);
  • VUID-vkCmdDispatch-None-06479 (binding 24, Astro Bot PPSA21567, RTX 5060 Ti).

The guard in #1625. It sets sampler_compare_ok[pair.sampler] = false for every sampler paired with a non-depth image. With the shared entry, that also turns compare off for the Dref shadow lookup. That hits the other poison case: "The SPIR-V instruction is one of the OpImage*Dref* instructions and the sampler compareEnable is VK_FALSE".

Fix. Branch shader/sampler-compare-variants (commit bc553dca on top of current upstream main 0cad4672, +39/-4: https://github.com/Nawid3333/KytyPS5/commits/shader/sampler-compare-variants):

  • SamplerClass gains Compare, and ClassifySampler returns it for depth-compare images.
  • The existing sampler plan then builds a compare variant that shares the guest descriptor. This is the same mechanism as the Float/Integer border variants.
  • The variant's depth_compare comes from its class.
  • integer_border now tests == Integer.
  • The SPIR-V typed-variant lookup for indirect images also matches depth_compare.

Tests. New test TestCompareSamplerUsesOwnVariant (ResourceMaterializationTests) has sampler 1 shared by a compare image and a plain k32Float image. It expects 3 sampler entries, 2 runtime descriptors, and each pair's sampler compare equal to its image's compare. It fails on main ("shared compare sampler did not get its own variant") and passes with the fix. resource_tracking_tests pass.

GPU results. I ran on GPU 0 and GPU 1, with native and 32-wide host subgroups. ComparisonDepthTexture, ImageSampleA16CompareBiasRdna2AddressOrder and ImageGatherCompareOpcodes pass with the fix, with 0 validation messages. They also pass on main, so they do not reproduce the bug and only show no regression. The full suite (811 entries per compute config, 30 graphics entries per GPU) shows no differences between fix and main.

Next step, your call:

  1. You take the fix into #1625 (co-author credit is fine).
  2. I open a PR from shader/sampler-compare-variants that references #1625.

Written with Claude Code (AI): it traced the code and wrote the fix and test; I reviewed and ran them.

**@⁠Nawid3333** on GitHub · 2026-10-19 17:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-6272949216) @⁠ricardocacco I traced the shared-sampler case behind the guard in this PR. Here is the root cause and a tested fix. **Root cause.** `AddSampler` returns an existing entry when `m_info.samplers[i].source == source` (ResourceTracking.cpp:3827-3833), so compare state is not part of the key. Image entries do include `depth_compare` in their key (ResourceTracking.cpp:3793). A guest sampler can be used by both of these: - an `IMAGE_SAMPLE_C`, whose image gets a D32 view (descriptors.cpp:553-556); - a plain `IMAGE_SAMPLE` of a k32Float texture (R32_SFLOAT view). ResourceMaterialization.cpp:1853 then merges the two uses: ```cpp samplers[pair.sampler].depth_compare |= images[pair.image].depth_compare; ``` The result is one sampler with compare enabled for both pairs. descriptors.cpp:640-641 clears S# bits 14:12 (the RDNA2 compare func) only when `depth_compare` is false. For the plain sample, Vulkan Texel Input Operations makes the texel poison: "The SPIR-V instruction is not one of the OpImage\*Dref\* instructions and the sampler compareEnable is VK_TRUE". #1476 has two NVIDIA logs showing an R32_SFLOAT view without SAMPLED_IMAGE_DEPTH_COMPARISON: - VUID-vkCmdDrawIndexed-None-06479 (binding 80); - VUID-vkCmdDispatch-None-06479 (binding 24, Astro Bot PPSA21567, RTX 5060 Ti). **The guard in #1625.** It sets `sampler_compare_ok[pair.sampler] = false` for every sampler paired with a non-depth image. With the shared entry, that also turns compare off for the Dref shadow lookup. That hits the other poison case: "The SPIR-V instruction is one of the OpImage\*Dref\* instructions and the sampler compareEnable is VK_FALSE". **Fix.** Branch `shader/sampler-compare-variants` (commit bc553dca on top of current upstream main 0cad4672, +39/-4: https://github.com/Nawid3333/KytyPS5/commits/shader/sampler-compare-variants): - `SamplerClass` gains `Compare`, and `ClassifySampler` returns it for depth-compare images. - The existing sampler plan then builds a compare variant that shares the guest descriptor. This is the same mechanism as the Float/Integer border variants. - The variant's `depth_compare` comes from its class. - `integer_border` now tests `== Integer`. - The SPIR-V typed-variant lookup for indirect images also matches `depth_compare`. **Tests.** New test `TestCompareSamplerUsesOwnVariant` (ResourceMaterializationTests) has sampler 1 shared by a compare image and a plain k32Float image. It expects 3 sampler entries, 2 runtime descriptors, and each pair's sampler compare equal to its image's compare. It fails on main ("shared compare sampler did not get its own variant") and passes with the fix. `resource_tracking_tests` pass. **GPU results.** I ran on GPU 0 and GPU 1, with native and 32-wide host subgroups. ComparisonDepthTexture, ImageSampleA16CompareBiasRdna2AddressOrder and ImageGatherCompareOpcodes pass with the fix, with 0 validation messages. They also pass on main, so they do not reproduce the bug and only show no regression. The full suite (811 entries per compute config, 30 graphics entries per GPU) shows no differences between fix and main. **Next step, your call:** 1. You take the fix into #1625 (co-author credit is fine). 2. I open a PR from `shader/sampler-compare-variants` that references #1625. Written with Claude Code (AI): it traced the code and wrote the fix and test; I reviewed and ran them.
Author
Owner

@⁠ricardocacco on GitHub · 2026-10-19 19:50 UTC · original

Thanks @⁠Nawid3333 — going with your offer, so please open the PR against KytyPS5/KytyPS5 from shader/sampler-compare-variants (bc553dca) and reference this one (#1625). Authorship stays entirely with you; no co-author credit needed.

A few notes:

  • Your structural analysis matches what I can verify against current main (0cad4672): AddSampler dedups only by source, while image entries carry depth_compare in their key. So one guest sampler really can be paired with both a depth-compare view and a non-depth one, and a per-sampler boolean cannot represent that. The variant approach is the right shape, and this guard here only fixes one direction of the mismatch — it can leave the Dref side with compareEnable=false, which is exactly the opposite VUID.
  • I also cannot get CI to run on this PR (action_required, first-time contributor), so your PR is the better vehicle for the fix regardless.
  • I will close this PR as superseded once yours is open, to avoid two PRs touching the same descriptor path. Leaving it open until then so the discussion stays findable.

On verification: locally I never reproduced the VUID on either side — with the guard applied the check never fired and Khronos validation stayed silent up to the unrelated device-lost that ends those runs, so your GPU results are the validation here, not mine. If you keep the new test (TestCompareSamplerUsesOwnVariant) in the PR that is the piece that makes the change reviewable on its own.

**@⁠ricardocacco** on GitHub · 2026-10-19 19:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-6275904787) Thanks @⁠Nawid3333 — going with your offer, so please open the PR against `KytyPS5/KytyPS5` from `shader/sampler-compare-variants` (`bc553dca`) and reference this one (`#1625`). Authorship stays entirely with you; no co-author credit needed. A few notes: * Your structural analysis matches what I can verify against current `main` (`0cad4672`): `AddSampler` dedups only by `source`, while image entries carry `depth_compare` in their key. So one guest sampler really can be paired with both a depth-compare view and a non-depth one, and a per-sampler boolean cannot represent that. The variant approach is the right shape, and this guard here only fixes one direction of the mismatch — it can leave the Dref side with `compareEnable=false`, which is exactly the opposite VUID. * I also cannot get CI to run on this PR (`action_required`, first-time contributor), so your PR is the better vehicle for the fix regardless. * I will close this PR as superseded once yours is open, to avoid two PRs touching the same descriptor path. Leaving it open until then so the discussion stays findable. On verification: locally I never reproduced the VUID on either side — with the guard applied the check never fired and Khronos validation stayed silent up to the unrelated device-lost that ends those runs, so your GPU results are the validation here, not mine. If you keep the new test (`TestCompareSamplerUsesOwnVariant`) in the PR that is the piece that makes the change reviewable on its own.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-19 20:04 UTC · original

@⁠ricardocacco opened as #1733 (branch shader/sampler-compare-variants, bc553dca), referencing this PR. Thanks again for the analysis that pointed at the sampler/image mismatch.

**@⁠Nawid3333** on GitHub · 2026-10-19 20:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-6276161102) @⁠ricardocacco opened as #1733 (branch shader/sampler-compare-variants, bc553dca), referencing this PR. Thanks again for the analysis that pointed at the sampler/image mismatch.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-11-21 20:07 UTC · original

@⁠ricardocacco #1733 is now one commit on current main (040e658f0): its test still fails on main 39936ffa3 (shared compare sampler did not get its own variant) and passes with the change. If you still see it as covering this one, could you close #1625 as superseded, as planned? While both are open, CodeRabbit lists this PR's guard as an open requirement of #1733.

**@⁠Nawid3333** on GitHub · 2026-11-21 20:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1625#issuecomment-7068524396) @⁠ricardocacco #1733 is now one commit on current main (040e658f0): its test still fails on main 39936ffa3 (`shared compare sampler did not get its own variant`) and passes with the change. If you still see it as covering this one, could you close #1625 as superseded, as planned? While both are open, CodeRabbit lists this PR's guard as an open requirement of #1733.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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