Skip to content

Commit

Permalink
renderer_vulkan: Clear blank frame (#2095)
Browse files Browse the repository at this point in the history
* renderer_vulkan: Clear blank frame

Fix display of garbage images on startup on some drivers.

* Remove duplicated attachment declarations

* Remove duplicated rendering_info declarations
  • Loading branch information
ngoquang2708 authored Jan 18, 2025
1 parent 40385e1 commit 9a956f5
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/video_core/renderer_vulkan/vk_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,23 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
.pImageMemoryBarriers = &pre_barrier,
});

const std::array attachments = {vk::RenderingAttachmentInfo{
.imageView = frame->image_view,
.imageLayout = vk::ImageLayout::eColorAttachmentOptimal,
.loadOp = vk::AttachmentLoadOp::eClear,
.storeOp = vk::AttachmentStoreOp::eStore,
}};
const vk::RenderingInfo rendering_info{
.renderArea =
vk::Rect2D{
.offset = {0, 0},
.extent = {frame->width, frame->height},
},
.layerCount = 1,
.colorAttachmentCount = attachments.size(),
.pColorAttachments = attachments.data(),
};

if (image_id != VideoCore::NULL_IMAGE_ID) {
auto& image = texture_cache.GetImage(image_id);
image.Transit(vk::ImageLayout::eShaderReadOnlyOptimal, vk::AccessFlagBits2::eShaderRead, {},
Expand Down Expand Up @@ -662,26 +679,13 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
cmdbuf.pushConstants(*pp_pipeline_layout, vk::ShaderStageFlagBits::eFragment, 0,
sizeof(PostProcessSettings), &pp_settings);

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.draw(3, 1, 0, 0);
cmdbuf.endRendering();
} else {
// Fix display of garbage images on startup on some drivers
cmdbuf.beginRendering(rendering_info);
cmdbuf.endRendering();
}

const auto post_barrier =
Expand Down

0 comments on commit 9a956f5

Please sign in to comment.