renderer_vulkan: Require exact image format for resolve pass. (#1742)

This commit is contained in:
squidbus 2024-12-11 12:51:39 -08:00 committed by GitHub
parent cb4760b724
commit f9406b325e
3 changed files with 15 additions and 5 deletions

View file

@ -790,8 +790,10 @@ void Rasterizer::Resolve() {
mrt0_hint};
VideoCore::TextureCache::RenderTargetDesc mrt1_desc{liverpool->regs.color_buffers[1],
mrt1_hint};
auto& mrt0_image = texture_cache.GetImage(texture_cache.FindImage(mrt0_desc));
auto& mrt1_image = texture_cache.GetImage(texture_cache.FindImage(mrt1_desc));
auto& mrt0_image =
texture_cache.GetImage(texture_cache.FindImage(mrt0_desc, VideoCore::FindFlags::ExactFmt));
auto& mrt1_image =
texture_cache.GetImage(texture_cache.FindImage(mrt1_desc, VideoCore::FindFlags::ExactFmt));
VideoCore::SubresourceRange mrt0_range;
mrt0_range.base.layer = liverpool->regs.color_buffers[0].view.slice_start;

View file

@ -324,6 +324,10 @@ ImageId TextureCache::FindImage(BaseDesc& desc, FindFlags flags) {
!IsVulkanFormatCompatible(info.pixel_format, cache_image.info.pixel_format)) {
continue;
}
if (True(flags & FindFlags::ExactFmt) &&
info.pixel_format != cache_image.info.pixel_format) {
continue;
}
ASSERT((cache_image.info.type == info.type || info.size == Extent3D{1, 1, 1} ||
True(flags & FindFlags::RelaxFmt)));
image_id = cache_id;
@ -348,9 +352,12 @@ ImageId TextureCache::FindImage(BaseDesc& desc, FindFlags flags) {
}
if (image_id) {
Image& image_resoved = slot_images[image_id];
if (image_resoved.info.resources < info.resources) {
Image& image_resolved = slot_images[image_id];
if (True(flags & FindFlags::ExactFmt) &&
info.pixel_format != image_resolved.info.pixel_format) {
// Cannot reuse this image as we need the exact requested format.
image_id = {};
} else if (image_resolved.info.resources < info.resources) {
// The image was clearly picked up wrong.
FreeImage(image_id);
image_id = {};

View file

@ -28,6 +28,7 @@ enum class FindFlags {
RelaxDim = 1 << 1, ///< Do not check the dimentions of image, only address.
RelaxSize = 1 << 2, ///< Do not check that the size matches exactly.
RelaxFmt = 1 << 3, ///< Do not check that format is compatible.
ExactFmt = 1 << 4, ///< Require the format to be exactly the same.
};
DECLARE_ENUM_FLAG_OPERATORS(FindFlags)