From 3780b80ce2333c893ee712c8fcc0f77b237682fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quang=20Ng=C3=B4?= Date: Wed, 8 Jan 2025 18:30:35 +0700 Subject: [PATCH] renderer_vulkan: Clear blank frame Fix display of garbage images on startup on some drivers. --- .../renderer_vulkan/vk_presenter.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/video_core/renderer_vulkan/vk_presenter.cpp b/src/video_core/renderer_vulkan/vk_presenter.cpp index 1679aa69142..191c6469678 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.cpp +++ b/src/video_core/renderer_vulkan/vk_presenter.cpp @@ -602,6 +602,28 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) cmdbuf.beginRendering(rendering_info); cmdbuf.draw(3, 1, 0, 0); cmdbuf.endRendering(); + } else { + // Fix display of garbage images on startup on some drivers + const std::array attachments = {vk::RenderingAttachmentInfo{ + .imageView = frame->image_view, + .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, + .loadOp = vk::AttachmentLoadOp::eClear, + .storeOp = vk::AttachmentStoreOp::eStore, + }}; + + vk::RenderingInfo rendering_info{ + .renderArea = + vk::Rect2D{ + .offset = {0, 0}, + .extent = {frame->width, frame->height}, + }, + .layerCount = 1, + .colorAttachmentCount = attachments.size(), + .pColorAttachments = attachments.data(), + }; + + cmdbuf.beginRendering(rendering_info); + cmdbuf.endRendering(); } const auto post_barrier =