From 7102ff8ecb51c4ed0e4db2313409b514872c6836 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Sat, 22 Aug 2026 15:27:03 -0400 Subject: [PATCH] Disable msaa tiler resolve + removal dead code from branch --- .../renderer_vulkan/vk_texture_cache.cpp | 57 +++---------------- .../renderer_vulkan/vk_texture_cache.h | 10 ---- .../vulkan_common/vulkan_device.cpp | 41 ------------- src/video_core/vulkan_common/vulkan_device.h | 20 ------- 4 files changed, 9 insertions(+), 119 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 0c7f8cca77..2789dbee3e 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -53,6 +53,9 @@ using VideoCore::Surface::IsPixelFormatInteger; using VideoCore::Surface::SurfaceType; namespace { +// Master switch for the tiler MSAA resolve path: resolve attachments, resolve shadows and the +// MSAA store discard that pays for them. Turning it off restores plain MSAA store behaviour. +constexpr bool ENABLE_MSAA_TILER_RESOLVE = false; constexpr bool ENABLE_MSAA_RESOLVE_CONSUME = true; constexpr bool ENABLE_MSAA_COLOR_DISCARD = true; constexpr bool ENABLE_MSAA_DEPTH_STENCIL_DISCARD = true; @@ -3043,11 +3046,11 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, renderpass_key.depth_format = PixelFormat::Invalid; } renderpass_key.samples = samples; - const bool do_resolve_color = + const bool do_resolve_color = ENABLE_MSAA_TILER_RESOLVE && samples != VK_SAMPLE_COUNT_1_BIT && num_colors > 0 && runtime.device.IsTiler(); renderpass_key.resolve_color = do_resolve_color; - const bool do_resolve_depth_stencil = + const bool do_resolve_depth_stencil = ENABLE_MSAA_TILER_RESOLVE && samples != VK_SAMPLE_COUNT_1_BIT && depth_image != VK_NULL_HANDLE && runtime.device.IsTiler() && SupportsDepthStencilResolve(runtime.device, renderpass_key.depth_format); @@ -3074,52 +3077,10 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, } const VkFormat vk_format = MaxwellToVK::SurfaceFormat(runtime.device, FormatType::Optimal, true, format).format; - if (ENABLE_MSAA_RESOLVE_CONSUME) { - const VkImage msaa_image = images[rt_map[index]]; - attachments.push_back(runtime.GetOrCreateResolveShadow( - msaa_image, vk_format, render_area, layers, VK_IMAGE_ASPECT_COLOR_BIT)); - resolve_shadow_images[num_resolve_shadows++] = msaa_image; - continue; - } - VkImageCreateInfo resolve_ci{ - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .imageType = VK_IMAGE_TYPE_2D, - .format = vk_format, - .extent = {render_area.width, render_area.height, 1}, - .mipLevels = 1, - .arrayLayers = layers, - .samples = VK_SAMPLE_COUNT_1_BIT, - .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | - VK_IMAGE_USAGE_TRANSFER_SRC_BIT, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, - .queueFamilyIndexCount = 0, - .pQueueFamilyIndices = nullptr, - .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, - }; - vk::Image resolve_image = runtime.memory_allocator.CreateImage(resolve_ci); - vk::ImageView resolve_view = - runtime.device.GetLogical().CreateImageView(VkImageViewCreateInfo{ - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .image = *resolve_image, - .viewType = layers > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D, - .format = vk_format, - .components{}, - .subresourceRange{ - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = 0, - .levelCount = 1, - .baseArrayLayer = 0, - .layerCount = layers, - }, - }); - attachments.push_back(*resolve_view); - resolve_images.push_back(std::move(resolve_image)); - resolve_image_views.push_back(std::move(resolve_view)); + const VkImage msaa_image = images[rt_map[index]]; + attachments.push_back(runtime.GetOrCreateResolveShadow( + msaa_image, vk_format, render_area, layers, VK_IMAGE_ASPECT_COLOR_BIT)); + resolve_shadow_images[num_resolve_shadows++] = msaa_image; } } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index f611c0f31b..e17a0653f6 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -243,14 +243,6 @@ public: return is_rescaled; } - [[nodiscard]] bool HasResolveColor() const noexcept { - return !resolve_images.empty(); - } - - [[nodiscard]] VkImage ResolveColorImage(size_t index) const noexcept { - return index < resolve_images.size() ? *resolve_images[index] : VK_NULL_HANDLE; - } - [[nodiscard]] bool DiscardsMsaaColor() const noexcept { return discard_msaa_color; } @@ -278,8 +270,6 @@ private: bool has_depth{}; bool has_stencil{}; bool is_rescaled{}; - std::vector resolve_images; - std::vector resolve_image_views; std::array resolve_shadow_images{}; u32 num_resolve_shadows = 0; TextureCacheRuntime* runtime_ptr{nullptr}; diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index f398fbccbc..a7c93c161c 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -1572,47 +1572,6 @@ void Device::SetupFamilies(VkSurfaceKHR surface) { } } -VkSampleCountFlags Device::GetSupportedSampleCounts(VkImageUsageFlags usage, - VkImageAspectFlags aspect, - bool is_integer) const { - const VkPhysicalDeviceLimits& limits = properties.properties.limits; - const bool has_color = (aspect & VK_IMAGE_ASPECT_COLOR_BIT) != 0; - const bool has_depth = (aspect & VK_IMAGE_ASPECT_DEPTH_BIT) != 0; - const bool has_stencil = (aspect & VK_IMAGE_ASPECT_STENCIL_BIT) != 0; - - VkSampleCountFlags counts = ~VkSampleCountFlags{0}; - if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0) { - if (has_color) { - if (is_integer) { - counts &= limits.sampledImageIntegerSampleCounts; - } else { - counts &= limits.sampledImageColorSampleCounts; - } - } - if (has_depth) { - counts &= limits.sampledImageDepthSampleCounts; - } - if (has_stencil) { - counts &= limits.sampledImageStencilSampleCounts; - } - } - if ((usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0) { - counts &= limits.framebufferColorSampleCounts; - } - if ((usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) { - if (has_depth) { - counts &= limits.framebufferDepthSampleCounts; - } - if (has_stencil) { - counts &= limits.framebufferStencilSampleCounts; - } - } - if ((usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) { - counts &= limits.storageImageSampleCounts; - } - return counts; -} - bool Device::TryReserveCustomBorderColorSamplers(size_t count) const { const size_t limit = properties.custom_border_color.maxCustomBorderColorSamplers; if (limit == 0) { diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 8083e376fe..51bae46409 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -459,10 +459,6 @@ FN_MAX_LIMIT_LIST return features.features.shaderStorageImageMultisample; } - /// Returns the sample counts an image with the given usage and aspect can be created with. - VkSampleCountFlags GetSupportedSampleCounts(VkImageUsageFlags usage, VkImageAspectFlags aspect, - bool is_integer) const; - /// Returns true if the device warp size can potentially be bigger than guest's warp size. bool IsWarpSizePotentiallyBiggerThanGuest() const { return is_warp_potentially_bigger; @@ -645,11 +641,6 @@ FN_MAX_LIMIT_LIST return properties.depth_stencil_resolve.supportedStencilResolveModes; } - /// Returns true if the depth and stencil aspects may resolve with different modes. - bool SupportsIndependentResolve() const { - return properties.depth_stencil_resolve.independentResolve == VK_TRUE; - } - /// Returns true if only one of the depth and stencil aspects may be resolved. bool SupportsIndependentResolveNone() const { return properties.depth_stencil_resolve.independentResolveNone == VK_TRUE; @@ -719,11 +710,6 @@ FN_MAX_LIMIT_LIST features.custom_border_color.customBorderColorWithoutFormat; } - /// Returns how many live samplers may carry a custom border color, 0 when unknown. - u32 GetMaxCustomBorderColorSamplers() const { - return properties.custom_border_color.maxCustomBorderColorSamplers; - } - /// Takes budget for samplers carrying a custom border color, false when exhausted. bool TryReserveCustomBorderColorSamplers(size_t count) const; @@ -1039,12 +1025,6 @@ FN_MAX_LIMIT_LIST return stages; } - VkPipelineStageFlags AttachmentConsumerStages() const { - return ShaderConsumerStages() | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | - VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - } - /// Returns true if the device supports VK_KHR_maintenance1. bool IsKhrMaintenance1Supported() const { return extensions.maintenance1;