Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix missing color attachments in vk render_pass.
  • Loading branch information
jonahwilliams committed Nov 27, 2024
commit 5b4d07e4aeecd98b6a5e143abbcec0ea22bf4fd0
36 changes: 32 additions & 4 deletions impeller/renderer/backend/vulkan/render_pass_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ static std::vector<vk::ClearValue> GetVKClearValues(
const RenderTarget& target) {
std::vector<vk::ClearValue> clears;

const ColorAttachment& color0 = target.GetColor0();
clears.emplace_back(VKClearValueFromColor(color0.clear_color));
if (color0.resolve_texture) {
clears.emplace_back(VKClearValueFromColor(color0.clear_color));
}

for (const auto& [_, color] : target.GetColorAttachments()) {
clears.emplace_back(VKClearValueFromColor(color.clear_color));
if (color.resolve_texture) {
Expand Down Expand Up @@ -83,6 +89,22 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
const std::shared_ptr<CommandBufferVK>& command_buffer) const {
RenderPassBuilderVK builder;

const ColorAttachment& color0 = render_target_.GetColor0();
builder.SetColorAttachment(
0u, //
color0.texture->GetTextureDescriptor().format, //
color0.texture->GetTextureDescriptor().sample_count, //
color0.load_action, //
color0.store_action, //
TextureVK::Cast(*color0.texture).GetLayout() //
);
TextureVK::Cast(*color0.texture)
.SetLayoutWithoutEncoding(vk::ImageLayout::eGeneral);
if (color0.resolve_texture) {
TextureVK::Cast(*color0.resolve_texture)
.SetLayoutWithoutEncoding(vk::ImageLayout::eGeneral);
}

for (const auto& [bind_point, color] : render_target_.GetColorAttachments()) {
builder.SetColorAttachment(
bind_point, //
Expand Down Expand Up @@ -137,10 +159,8 @@ RenderPassVK::RenderPassVK(const std::shared_ptr<const Context>& context,
const RenderTarget& target,
std::shared_ptr<CommandBufferVK> command_buffer)
: RenderPass(context, target), command_buffer_(std::move(command_buffer)) {
color_image_vk_ =
render_target_.GetColorAttachments().find(0u)->second.texture;
resolve_image_vk_ =
render_target_.GetColorAttachments().find(0u)->second.resolve_texture;
color_image_vk_ = render_target_.GetColor0().texture;
resolve_image_vk_ = render_target_.GetColor0().resolve_texture;

const auto& vk_context = ContextVK::Cast(*context);
command_buffer_vk_ = command_buffer_->GetCommandBuffer();
Expand Down Expand Up @@ -254,6 +274,14 @@ SharedHandleVK<vk::Framebuffer> RenderPassVK::CreateVKFramebuffer(
// This bit must be consistent to ensure compatibility with the pass created
// earlier. Follow this order: Color attachments, then depth-stencil, then
// stencil.
const ColorAttachment color0 = render_target_.GetColor0();
attachments.emplace_back(
TextureVK::Cast(*color0.texture).GetRenderTargetView());
if (color0.resolve_texture) {
attachments.emplace_back(
TextureVK::Cast(*color0.resolve_texture).GetRenderTargetView());
}

for (const auto& [_, color] : render_target_.GetColorAttachments()) {
// The bind point doesn't matter here since that information is present in
// the render pass.
Expand Down