Disable msaa tiler resolve + removal dead code from branch

This commit is contained in:
CamilleLaVey
2026-08-22 15:27:03 -04:00
parent 385b844e2a
commit 7102ff8ecb
4 changed files with 9 additions and 119 deletions
@@ -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;
}
}
@@ -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<vk::Image> resolve_images;
std::vector<vk::ImageView> resolve_image_views;
std::array<VkImage, 9> resolve_shadow_images{};
u32 num_resolve_shadows = 0;
TextureCacheRuntime* runtime_ptr{nullptr};
@@ -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) {
@@ -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;