graphics: fall back to a 1x1 stand-in image when nullDescriptor is unsupported #1635
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!1635
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1635/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?
@wuboo on GitHub · 2026-10-18 09:26 UTC · original
wuboo:pr/apple-nulldescriptor-fallback→main· +163 −22 · 8 files · 1 commits · closed without mergingProblem
MoltenVK does not report
VK_EXT_robustness2nullDescriptor.VulkanFindPhysicalDevicerequires it(
check_feature(robustness2.nullDescriptor, ...)) andVulkanCreateDeviceforces it toVK_TRUE, so onmacOS the only GPU (Apple M3 Max, MoltenVK 1.4.x) is rejected and the emulator exits before it loads a title
("Could not find suitable device", nullDescriptor is the first hard failure in the log; colorWriteEnable /
depthClipEnable / depthBounds are already warnings on Apple).
Change
GraphicContext::null_descriptor_enabledis set fromUseNativeNullDescriptor(supported nullDescriptor)(
vulkanCommon.h) when the device is created, and logged (Vulkan nullDescriptor: native|stand-in image).__APPLE__a missingnullDescriptoris a warning in device selection (same pattern ascolorWriteEnable/depthClipEnable); other platforms keep requiring it.VK_NULL_HANDLEas today. Without it,ResolveTexturereturns a 1x1 stand-in image per pixel format (TextureCache::GetNullImage,NullTextureDesc): an unregistered image with no guest backing (info.data.Empty()skips registration,tracking, refresh, download and write-back), transitioned to
eGeneralbefore use.Tests
null_descriptor_policy(tests/NullDescriptorPolicyTests.cpp): native only when the feature issupported. Mutant (
UseNativeNullDescriptorreturnstrue): the test no longer builds(
static_assertfails), so it is caught.cteston this branch vs. origin/main built the same way: 58 tests vs 57, the same 19 failures (allGPU tests aborting with "could not load the Vulkan loader" in the CPU-only environment), 0 new failures.
Limits
covered by a headless GPU test, and the other shaders that need features MoltenVK lacks (image view min LOD,
64-bit buffer atomics, cull distance) are handled separately (see #1547, #1314).
zero like a native null descriptor does. Whether a title depends on that was not measured.
considered null, not how a null descriptor is bound.
@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
📝 Walkthrough
The Vulkan device setup now records whether
nullDescriptoris supported and enabled. On macOS, devices without the feature are no longer rejected for that reason. When native null descriptors are unavailable, texture descriptor resolution uses a cached 1×1 stand-in image. Empty-backed images skip guest-memory tracking and related refresh and storage-write operations. A test executable checks the null-descriptor policy helper.Suggested reviewers:
nmzikPriority: ⬆️ High
Change: Feature
Merge Risk: 🟡 Moderate · up to
da324Apple devices without native null descriptors can now run, but the fallback can still abort on dynamic-mip null textures. It can also return values that differ from real null descriptors: garbage contents, leftover writes, wrong comparison results, or alpha of one. Address the crash and the read semantics before merge; other platforms are unaffected.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 7 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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.@ -409,0 +413,4 @@ImageId TextureCache::GetNullImage(const ImageDesc& desc) {const auto format = desc.info.pixel_format;if (const auto found = m_null_images.find(format); found != m_null_images.end()) {return found->second;@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Prevent null storage writes from changing later null reads.
If a shader writes through a null storage binding, that write targets the image retained in
m_null_images. A later null binding with the same pixel format receives the same image ID and can observe the write. Native null-descriptor stores and atomics are discarded. A one-time clear does not fix this persistent state change. Keep null writes from becoming observable through later bindings. (docs.vulkan.org)@ -409,0 +427,4 @@info.tile_mode = Prospero::TileMode::kLinear;info.mip_layout[0] = {0, info.bytes_per_block, 1, 1};const auto id = InsertImage(info);m_null_images.emplace(format, id);@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Initialize the stand-in before shader reads.
If an Apple device lacks
nullDescriptor, the first null texture lookup creates this image without defined texel contents. The empty-backed path also skips the guest upload. A shader read can therefore return an undefined value instead of the zero value of a native null descriptor. Initialize the stand-in before its first use. (docs.vulkan.org)@ -359,0 +373,4 @@break;default: EXIT("null image has unsupported numeric class\n");}desc.info.pixel_format = VulkanFormat(desc.info.guest_format);@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve zero alpha in null texture reads.
If a shader reads the alpha component of a null float, signed, or unsigned texture, the single-component stand-in returns the format’s substituted alpha value of one. A native null descriptor returns zero. Clearing the stand-in cannot correct the missing component. Use a format or view mapping that preserves zero in all components read by the shader. (docs.vulkan.org)
@ -359,0 +376,4 @@desc.info.pixel_format = VulkanFormat(desc.info.guest_format);desc.info.type = Prospero::ImageType::kColor2D;desc.info.extent = {1, 1, 1};desc.info.resources = {1, 1};@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Support dynamic mip bindings for null textures.
If
resource.mip_modeisDynamicandresource.mip_countexceeds one, this stand-in has only one mip.RebindImagescompares that count withbinding.desc.view_info.level_countand exits when they differ. The native-null path skips that image acquisition. Make the fallback supply the required descriptor views without declaring more mips than its image contains.@ -359,0 +382,4 @@desc.info.mip_layout[0] = {0, 0, 1, 1};desc.view_info.format = resource.atomic64 ? vk::Format::eR64Uint : desc.info.pixel_format;desc.view_info.type = vk::ImageViewType::e2D;desc.view_info.aspect = vk::ImageAspectFlagBits::eColor;@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Use a depth view for null comparison textures.
If
resource.depth_compareis true,NullTextureDescstill supplies a color format and color aspect. The normal texture path selects a depth format for comparison resources. Vulkan performs the depth comparison for a depth/stencil view with its depth aspect; this stand-in does not provide that view. Select a compatible depth stand-in for null comparison bindings. (docs.vulkan.org)@coderabbitai[bot] on GitHub · 2026-10-18 09:34 UTC · original · reviewed
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
d8925c84-1f41-43bb-81f6-228271257b6c📥 Commits
Reviewing files that changed from the base of the PR and between
37df7f3278andda32430a5d.📒 Files selected for processing: 8
CMakeLists.txtsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/vulkanCommon.hsrc/graphics/presentation/window/vulkanWindow.cpptests/NullDescriptorPolicyTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Nmzik on GitHub · 2026-10-18 13:57 UTC · original
We wont return back to old code. Use KosmicKrisp
@wuboo on GitHub · 2026-10-18 14:15 UTC · original
Fair enough, understood. I'm moving the macOS work over to KosmicKrisp now and will report how it runs on an M3 Max (startup, rendering, frame times). Any fixes from that will target KosmicKrisp rather than MoltenVK workarounds.
Pull request closed