diff options
| author | givethesourceplox <272928635+givethesourceplox@users.noreply.github.com> | 2026-10-30 09:46:22 -0300 |
|---|---|---|
| committer | kraibse <33869366+kraibse@users.noreply.github.com> | 2026-10-30 20:45:12 +0100 |
| commit | ca524c9aa883abc4d1c5aeb8aa4d2f9eb0b4225c (patch) | |
| tree | fcaaeb4b1b39f09084867b71472534bdf548578b /src | |
| parent | d2ac2275247a9ecb3e1404606f7026c6402533b8 (diff) | |
vulkan: keep the image's view type when a shader's dimension disagrees
A 3D view of a 2D image (or the reverse) is invalid in Vulkan and
aborts in MoltenVK (MVKImageViewPlane::newMTLTexture). Seen with a
null image view sampled as 3D in title 1.
Assisted-by: Claude (Anthropic)
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 9204ade9eb..6eb22fa263 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -3158,6 +3158,16 @@ vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_ std::optional<Shader::TextureType> texture_type) { VkImageViewType view_type = ImageViewType(type); VkImageSubresourceRange subresource_range = MakeSubresourceRange(aspect_mask, range); + const auto is_3d = [](VkImageViewType t) { return t == VK_IMAGE_VIEW_TYPE_3D; }; + if (texture_type && is_3d(ImageViewType(*texture_type)) != is_3d(view_type)) { + // A 3D view of a 2D image (or the reverse) is invalid in Vulkan and aborts on Metal; keep + // the image's own type when the shader's declared dimension disagrees with it. + LOG_WARNING(Render_Vulkan, + "Shader image type {} does not match view type {} at 0x{:x} (format={} " + "size={}x{}x{}), using the view type", + *texture_type, type, gpu_addr, format, size.width, size.height, size.depth); + texture_type.reset(); + } if (texture_type) { view_type = ImageViewType(*texture_type); switch (view_type) { |
