vulkan: use descriptor sets for MoltenVK shader pipelines #685
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!685
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/685/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@carbonimax on GitHub · 2026-09-17 19:32 UTC · original
carbonimax:codex/push-descriptor-moltenvk→main· +177 −119 · 5 files · 2 commits · closed without mergingProblem
On macOS, MoltenVK (1.4.3, binding through Metal3 argument buffers) does not deliver the storage
buffer length behind
OpArrayLengthwhen the buffer is bound withvkCmdPushDescriptorSetKHR.With the same SPIR-V module and the same descriptor,
OpArrayLengthreads 0 through pushdescriptors and 4 through regular descriptor sets.
The game's video conversion pixel shader (hash
e197e307a5f2cb39) compares an index againstOpArrayLengthand falls back to 0 when the bound check fails, so the converted video frame comesout black with green bands.
Measurements
The real SPIR-V was instrumented offline (32-bit
OpArrayLengthresult bit-packed into R,G,B, Aforced to 1.0 so an alpha blend cannot hide the value, module validated) and executed on the GPU:
OpArrayLengthvalueSame module, same descriptor and same driver in both runs. Rendering the video render target with
plain descriptor sets produces the correct frame.
Change
SelectMaxPushDescriptors(vk::DriverId, uint32_t)returns 0 forvk::DriverId::eMoltenvkandpasses the reported limit through for every other driver.
UsePushDescriptors(count, max)keeps the previouscount <= maxdecision and additionallyrequires
max > 0.vk::PhysicalDeviceDriverProperties, chained behind the existingvk::PhysicalDevicePushDescriptorPropertiesquery; the emulator requests API version 1.3, so thestructure is core and no extra query is needed.
(
Select device: ..., max push descriptors=0).tests/PushDescriptorPolicyTests.cpppins the policy: MoltenVK loses the limit, other driverskeep it, plus
(0,0),(4,0),(33,32),(32,32),(4,32),(0,32).Other drivers are unchanged by this patch: the previous
descriptor_count <= max_push_descriptorsdecision still holds whenever
max_push_descriptors > 0, and the emulator's own push layouts(tiler, blit helper, fault manager) are untouched.
Validation
104530ewith this patch in a clean worktree,ninja kyty_emulator push_descriptor_policy_testssucceeds (635 compile steps, both targets linked) andpush_descriptor_policy_testsprintsPushDescriptorPolicyTests: ok;shader_cfg_testsalsobuilds and passes in that same tree.
experiment, not on a build of this branch alone: there, the image read back from the GPU right
before presentation decodes to a correct frame instead of black with green bands
(
A2R10G10B10_UNORM_PACK32dump, 3840x2160), and the video plays correctly.Known limits
(
Fragment input(s) `user(locn1)` mismatching vertex shader output type(s)), and it is notaddressed here.
@coderabbitai[bot] on GitHub · 2026-09-17 21:02 UTC · original · edited 2026-10-13 22:44 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
0bb7bf7e-4813-43b2-a1f2-06977bab0946📥 Commits
Reviewing files that changed from the base of the PR and between e0629fb56bc100977c5a0d2e62d4e9c28c2526c4 and b529ceee4e787e0290d30258a421c11574a8f6e6.
📒 Files selected for processing (4)
CMakeLists.txtsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/host_gpu/vulkanCommon.hsrc/graphics/presentation/window/vulkanWindow.cpp🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
📝 Walkthrough
Walkthrough
The change adds helpers to select a push-descriptor limit and determine whether a descriptor layout can use push descriptors. Vulkan initialization queries driver properties and selects the limit using the driver ID and reported device limit. Descriptor-layout creation uses the shared eligibility helper. A standalone test executable covers policy behavior and is registered with CTest and the aggregate test target.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
b529cMoltenVK avoids the reported push-descriptor issue by using regular descriptor sets, while other drivers retain their reported limit. No concrete merge-blocking risk is established.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
bd289This is a narrowly scoped driver compatibility change with no demonstrated increase in privileges or external access. Residual uncertainty concerns concurrent execution and behavior on actual devices.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: 1 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.Pull request closed