From c279583f1f360ffb0641afeb6f3b468573643a1d Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 5 Apr 2026 23:23:02 +0300 Subject: [PATCH] vk: Allow cubemap unwrap to generate more than 1 mipmap level --- rpcs3/Emu/RSX/VK/VKDraw.cpp | 4 ++++ rpcs3/Emu/RSX/VK/VKTextureCache.cpp | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index 5c3737fdf2..f7dffc3029 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -471,6 +471,10 @@ void VKGSRender::load_texture_env() // Clamp min and max lod actual_mipmaps = static_cast(sampler_state->external_subresource_desc.sections_to_copy.size()); } + else if (sampler_state->external_subresource_desc.op == rsx::deferred_request_command::cubemap_unwrap) + { + actual_mipmaps = static_cast(sampler_state->external_subresource_desc.mipmaps); + } else { actual_mipmaps = 1.f; diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp index c9d9599b9e..206903bf64 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp @@ -761,8 +761,9 @@ namespace vk const rsx::simple_array& sections_to_copy, const rsx::texture_channel_remap_t& remap_vector) { auto _template = get_template_from_collection_impl(sections_to_copy); + const u8 mip_count = 1 + sections_to_copy.reduce(0, FN(std::max(x, y.level))); auto result = create_temporary_subresource_view_impl(cmd, _template, VK_IMAGE_TYPE_2D, - VK_IMAGE_VIEW_TYPE_CUBE, gcm_format, 0, 0, size, size, 1, 1, remap_vector, false); + VK_IMAGE_VIEW_TYPE_CUBE, gcm_format, 0, 0, size, size, 1, mip_count, remap_vector, false); if (!result) { @@ -772,7 +773,7 @@ namespace vk const auto image = result->image(); VkImageAspectFlags dst_aspect = vk::get_aspect_flags(result->info.format); - VkImageSubresourceRange dst_range = { dst_aspect, 0, 1, 0, 6 }; + VkImageSubresourceRange dst_range = { dst_aspect, 0, mip_count, 0, 6 }; vk::change_image_layout(cmd, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, dst_range); if (!(dst_aspect & VK_IMAGE_ASPECT_DEPTH_BIT))