Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Fix EntityPass target flip for Vulkan #40701

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1823,10 +1823,6 @@ TEST_P(AiksTest, SiblingSaveLayerBoundsAreRespected) {
}

TEST_P(AiksTest, CanRenderClippedLayers) {
if (GetBackend() == PlaygroundBackend::kVulkan) {
GTEST_SKIP_("Temporarily disabled.");
}

Canvas canvas;

canvas.DrawPaint({.color = Color::White()});
Expand Down
4 changes: 0 additions & 4 deletions impeller/display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,6 @@ TEST_P(DisplayListTest, SaveLayerWithBlendFiltersAndAlphaDrawCorrectly) {
}

TEST_P(DisplayListTest, CanDrawBackdropFilter) {
if (GetBackend() == PlaygroundBackend::kVulkan) {
GTEST_SKIP_("Temporarily disabled.");
}

auto texture = CreateTextureForFixture("embarcadero.jpg");

auto callback = [&]() {
Expand Down
18 changes: 14 additions & 4 deletions impeller/entity/entity_pass_target.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "impeller/entity/entity_pass_target.h"

#include "impeller/base/validation.h"
#include "impeller/renderer/formats.h"
#include "impeller/renderer/texture.h"

namespace impeller {
Expand All @@ -15,8 +17,16 @@ EntityPassTarget::EntityPassTarget(const RenderTarget& render_target,

std::shared_ptr<Texture> EntityPassTarget::Flip(Allocator& allocator) {
auto color0 = target_.GetColorAttachments().find(0)->second;
if (!color0.resolve_texture) {
VALIDATION_LOG << "EntityPassTarget Flip should never be called for a "
"non-MSAA target.";
// ...because there is never a circumstance where doing so would be
// necessary. Unlike MSAA passes, non-MSAA passes can be trivially loaded
// with `LoadAction::kLoad`.
return color0.texture;
}

if (supports_read_from_resolve_ && color0.resolve_texture) {
if (supports_read_from_resolve_) {
// Just return the current resolve texture, which is safe to read in the
// next render pass that'll resolve to `target_`.
//
Expand All @@ -26,16 +36,16 @@ std::shared_ptr<Texture> EntityPassTarget::Flip(Allocator& allocator) {

if (!secondary_color_texture_) {
// The second texture is allocated lazily to avoid unused allocations.
TextureDescriptor new_descriptor = color0.texture->GetTextureDescriptor();
TextureDescriptor new_descriptor =
color0.resolve_texture->GetTextureDescriptor();
secondary_color_texture_ = allocator.CreateTexture(new_descriptor);

if (!secondary_color_texture_) {
return nullptr;
}
}

std::swap(color0.resolve_texture ? color0.resolve_texture : color0.texture,
secondary_color_texture_);
std::swap(color0.resolve_texture, secondary_color_texture_);

target_.SetColorAttachment(color0, 0);

Expand Down