diff --git a/impeller/entity/entity.cc b/impeller/entity/entity.cc index 5bd509263b55f..d1a14acde9d62 100644 --- a/impeller/entity/entity.cc +++ b/impeller/entity/entity.cc @@ -4,16 +4,12 @@ #include "impeller/entity/entity.h" -#include #include -#include "impeller/base/validation.h" #include "impeller/entity/contents/content_context.h" -#include "impeller/entity/contents/filters/filter_contents.h" #include "impeller/entity/contents/texture_contents.h" #include "impeller/entity/entity_pass.h" #include "impeller/geometry/color.h" -#include "impeller/geometry/vector.h" #include "impeller/renderer/render_pass.h" namespace impeller { diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index c6c39a6416f7a..c951c7ac99e48 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -286,8 +286,7 @@ static EntityPassTarget CreateRenderTarget(ContentContext& renderer, } return EntityPassTarget( - target, renderer.GetDeviceCapabilities().SupportsReadFromResolve(), - renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA()); + target, renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA()); } uint32_t EntityPass::GetTotalPassReads(ContentContext& renderer) const { @@ -333,16 +332,11 @@ bool EntityPass::Render(ContentContext& renderer, .coverage = Rect::MakeSize(root_render_target.GetRenderTargetSize()), .clip_depth = 0}}; - bool supports_onscreen_backdrop_reads = - renderer.GetDeviceCapabilities().SupportsReadFromOnscreenTexture() && - // If the backend doesn't have `SupportsReadFromResolve`, we need to flip - // between two textures when restoring a previous MSAA pass. - renderer.GetDeviceCapabilities().SupportsReadFromResolve(); bool reads_from_onscreen_backdrop = GetTotalPassReads(renderer) > 0; // In this branch path, we need to render everything to an offscreen texture // and then blit the results onto the onscreen texture. If using this branch, // there's no need to set up a stencil attachment on the root render target. - if (!supports_onscreen_backdrop_reads && reads_from_onscreen_backdrop) { + if (reads_from_onscreen_backdrop) { auto offscreen_target = CreateRenderTarget(renderer, root_render_target.GetRenderTargetSize(), GetClearColor(render_target.GetRenderTargetSize())); @@ -459,7 +453,6 @@ bool EntityPass::Render(ContentContext& renderer, EntityPassTarget pass_target( root_render_target, - renderer.GetDeviceCapabilities().SupportsReadFromResolve(), renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA()); return OnRender( // @@ -844,8 +837,9 @@ bool EntityPass::OnRender( TRACE_EVENT0("impeller", "EntityPass::OnRender"); auto context = renderer.GetContext(); - InlinePassContext pass_context( - context, pass_target, GetTotalPassReads(renderer), collapsed_parent_pass); + InlinePassContext pass_context(context, renderer.GetRenderTargetCache(), + pass_target, GetTotalPassReads(renderer), + collapsed_parent_pass); if (!pass_context.IsValid()) { VALIDATION_LOG << SPrintF("Pass context invalid (Depth=%d)", pass_depth); return false; diff --git a/impeller/entity/entity_pass_target.cc b/impeller/entity/entity_pass_target.cc index d2a63bc43542c..5c10c615afb4e 100644 --- a/impeller/entity/entity_pass_target.cc +++ b/impeller/entity/entity_pass_target.cc @@ -7,17 +7,16 @@ #include "impeller/base/validation.h" #include "impeller/core/formats.h" #include "impeller/core/texture.h" +#include "impeller/renderer/render_target.h" namespace impeller { EntityPassTarget::EntityPassTarget(const RenderTarget& render_target, - bool supports_read_from_resolve, bool supports_implicit_msaa) - : target_(render_target), - supports_read_from_resolve_(supports_read_from_resolve), - supports_implicit_msaa_(supports_implicit_msaa) {} + : target_(render_target), supports_implicit_msaa_(supports_implicit_msaa) {} -std::shared_ptr EntityPassTarget::Flip(Allocator& allocator) { +std::shared_ptr EntityPassTarget::Flip( + RenderTargetAllocator& allocator) { auto color0 = target_.GetColorAttachments().find(0)->second; if (!color0.resolve_texture) { VALIDATION_LOG << "EntityPassTarget Flip should never be called for a " @@ -28,14 +27,6 @@ std::shared_ptr EntityPassTarget::Flip(Allocator& allocator) { return color0.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_`. - // - // Note that this can only be done when MSAA is being used. - return color0.resolve_texture; - } - if (!secondary_color_texture_) { // The second texture is allocated lazily to avoid unused allocations. TextureDescriptor new_descriptor = diff --git a/impeller/entity/entity_pass_target.h b/impeller/entity/entity_pass_target.h index 76e90ece6f083..644ff4d2967e6 100644 --- a/impeller/entity/entity_pass_target.h +++ b/impeller/entity/entity_pass_target.h @@ -13,9 +13,8 @@ class InlinePassContext; class EntityPassTarget { public: - explicit EntityPassTarget(const RenderTarget& render_target, - bool supports_read_from_resolve, - bool supports_implicit_msaa); + EntityPassTarget(const RenderTarget& render_target, + bool supports_implicit_msaa); /// @brief Flips the backdrop and returns a readable texture that can be /// bound/sampled to restore the previous pass. @@ -24,7 +23,7 @@ class EntityPassTarget { /// result of `GetRenderTarget` is guaranteed to be able to read the /// previous pass's backdrop texture (which is returned by this /// method). - std::shared_ptr Flip(Allocator& allocator); + std::shared_ptr Flip(RenderTargetAllocator& allocator); const RenderTarget& GetRenderTarget() const; @@ -34,7 +33,6 @@ class EntityPassTarget { RenderTarget target_; std::shared_ptr secondary_color_texture_; - bool supports_read_from_resolve_; bool supports_implicit_msaa_; friend InlinePassContext; diff --git a/impeller/entity/entity_pass_target_unittests.cc b/impeller/entity/entity_pass_target_unittests.cc index 390f7929913f7..b9fb1c72464f2 100644 --- a/impeller/entity/entity_pass_target_unittests.cc +++ b/impeller/entity/entity_pass_target_unittests.cc @@ -28,7 +28,7 @@ TEST_P(EntityPassTargetTest, SwapWithMSAATexture) { *content_context->GetContext(), *GetContentContext()->GetRenderTargetCache(), {100, 100}); - auto entity_pass_target = EntityPassTarget(render_target, false, false); + auto entity_pass_target = EntityPassTarget(render_target, false); auto color0 = entity_pass_target.GetRenderTarget() .GetColorAttachments() @@ -37,8 +37,7 @@ TEST_P(EntityPassTargetTest, SwapWithMSAATexture) { auto msaa_tex = color0.texture; auto resolve_tex = color0.resolve_texture; - entity_pass_target.Flip( - *content_context->GetContext()->GetResourceAllocator()); + entity_pass_target.Flip(*content_context->GetRenderTargetCache()); color0 = entity_pass_target.GetRenderTarget() .GetColorAttachments() @@ -86,7 +85,7 @@ TEST_P(EntityPassTargetTest, SwapWithMSAAImplicitResolve) { render_target.SetStencilAttachment(std::nullopt); } - auto entity_pass_target = EntityPassTarget(render_target, false, true); + auto entity_pass_target = EntityPassTarget(render_target, true); auto color0 = entity_pass_target.GetRenderTarget() .GetColorAttachments() @@ -97,8 +96,7 @@ TEST_P(EntityPassTargetTest, SwapWithMSAAImplicitResolve) { ASSERT_EQ(msaa_tex, resolve_tex); - entity_pass_target.Flip( - *content_context->GetContext()->GetResourceAllocator()); + entity_pass_target.Flip(*content_context->GetRenderTargetCache()); color0 = entity_pass_target.GetRenderTarget() .GetColorAttachments() diff --git a/impeller/entity/inline_pass_context.cc b/impeller/entity/inline_pass_context.cc index c1f9f59649c78..8a8862cbcab66 100644 --- a/impeller/entity/inline_pass_context.cc +++ b/impeller/entity/inline_pass_context.cc @@ -8,7 +8,6 @@ #include "impeller/base/validation.h" #include "impeller/core/formats.h" -#include "impeller/core/texture_descriptor.h" #include "impeller/entity/entity_pass_target.h" #include "impeller/renderer/command_buffer.h" @@ -16,10 +15,12 @@ namespace impeller { InlinePassContext::InlinePassContext( std::shared_ptr context, + std::shared_ptr allocator, EntityPassTarget& pass_target, uint32_t pass_texture_reads, std::optional collapsed_parent_pass) : context_(std::move(context)), + allocator_(std::move(allocator)), pass_target_(pass_target), is_collapsed_(collapsed_parent_pass.has_value()) { if (collapsed_parent_pass.has_value()) { @@ -106,8 +107,7 @@ InlinePassContext::RenderPassResult InlinePassContext::GetRenderPass( .find(0) ->second.resolve_texture != nullptr; if (pass_count_ > 0 && is_msaa) { - result.backdrop_texture = - pass_target_.Flip(*context_->GetResourceAllocator()); + result.backdrop_texture = pass_target_.Flip(*allocator_); if (!result.backdrop_texture) { VALIDATION_LOG << "Could not flip the EntityPass render target."; } @@ -156,9 +156,8 @@ InlinePassContext::RenderPassResult InlinePassContext::GetRenderPass( result.pass = pass_; - if (!context_->GetCapabilities()->SupportsReadFromResolve() && - result.backdrop_texture == - result.pass->GetRenderTarget().GetRenderTargetTexture()) { + if (result.backdrop_texture == + result.pass->GetRenderTarget().GetRenderTargetTexture()) { VALIDATION_LOG << "EntityPass backdrop restore configuration is not valid " "for the current graphics backend."; } diff --git a/impeller/entity/inline_pass_context.h b/impeller/entity/inline_pass_context.h index cd18d4e744dc1..fc9dd36fbab31 100644 --- a/impeller/entity/inline_pass_context.h +++ b/impeller/entity/inline_pass_context.h @@ -22,6 +22,7 @@ class InlinePassContext { InlinePassContext( std::shared_ptr context, + std::shared_ptr allocator, EntityPassTarget& pass_target, uint32_t pass_texture_reads, std::optional collapsed_parent_pass = std::nullopt); @@ -38,6 +39,7 @@ class InlinePassContext { private: std::shared_ptr context_; + std::shared_ptr allocator_; EntityPassTarget& pass_target_; std::shared_ptr command_buffer_; std::shared_ptr pass_; diff --git a/impeller/renderer/backend/gles/capabilities_gles.cc b/impeller/renderer/backend/gles/capabilities_gles.cc index 9b2251c054f39..f0cf176087f08 100644 --- a/impeller/renderer/backend/gles/capabilities_gles.cc +++ b/impeller/renderer/backend/gles/capabilities_gles.cc @@ -173,10 +173,6 @@ bool CapabilitiesGLES::SupportsReadFromOnscreenTexture() const { return false; } -bool CapabilitiesGLES::SupportsReadFromResolve() const { - return false; -} - bool CapabilitiesGLES::SupportsDecalSamplerAddressMode() const { return supports_decal_sampler_address_mode_; } diff --git a/impeller/renderer/backend/gles/capabilities_gles.h b/impeller/renderer/backend/gles/capabilities_gles.h index 47dcaa33f3fb0..943821ce45ab9 100644 --- a/impeller/renderer/backend/gles/capabilities_gles.h +++ b/impeller/renderer/backend/gles/capabilities_gles.h @@ -100,9 +100,6 @@ class CapabilitiesGLES final // |Capabilities| bool SupportsReadFromOnscreenTexture() const override; - // |Capabilities| - bool SupportsReadFromResolve() const override; - // |Capabilities| bool SupportsDecalSamplerAddressMode() const override; diff --git a/impeller/renderer/backend/gles/test/capabilities_unittests.cc b/impeller/renderer/backend/gles/test/capabilities_unittests.cc index 5a82cf5b4c9b6..41a83f61cf7f4 100644 --- a/impeller/renderer/backend/gles/test/capabilities_unittests.cc +++ b/impeller/renderer/backend/gles/test/capabilities_unittests.cc @@ -23,7 +23,6 @@ TEST(CapabilitiesGLES, CanInitializeWithDefaults) { EXPECT_FALSE(capabilities->SupportsCompute()); EXPECT_FALSE(capabilities->SupportsComputeSubgroups()); EXPECT_FALSE(capabilities->SupportsReadFromOnscreenTexture()); - EXPECT_FALSE(capabilities->SupportsReadFromResolve()); EXPECT_FALSE(capabilities->SupportsDecalSamplerAddressMode()); EXPECT_FALSE(capabilities->SupportsDeviceTransientTextures()); diff --git a/impeller/renderer/backend/metal/context_mtl.mm b/impeller/renderer/backend/metal/context_mtl.mm index 06fd34724685a..d15dc47c38dd5 100644 --- a/impeller/renderer/backend/metal/context_mtl.mm +++ b/impeller/renderer/backend/metal/context_mtl.mm @@ -65,7 +65,6 @@ static bool DeviceSupportsComputeSubgroups(id device) { .SetDefaultDepthStencilFormat(PixelFormat::kD32FloatS8UInt) .SetSupportsCompute(true) .SetSupportsComputeSubgroups(DeviceSupportsComputeSubgroups(device)) - .SetSupportsReadFromResolve(true) .SetSupportsReadFromOnscreenTexture(true) .SetSupportsDeviceTransientTextures(true) .Build(); diff --git a/impeller/renderer/backend/vulkan/capabilities_vk.cc b/impeller/renderer/backend/vulkan/capabilities_vk.cc index ada7712ad66f7..5c79902c7aa59 100644 --- a/impeller/renderer/backend/vulkan/capabilities_vk.cc +++ b/impeller/renderer/backend/vulkan/capabilities_vk.cc @@ -4,8 +4,6 @@ #include "impeller/renderer/backend/vulkan/capabilities_vk.h" -#include - #include "impeller/base/validation.h" #include "impeller/core/formats.h" #include "impeller/renderer/backend/vulkan/vk.h" @@ -446,11 +444,6 @@ bool CapabilitiesVK::SupportsComputeSubgroups() const { return supports_compute_subgroups_; } -// |Capabilities| -bool CapabilitiesVK::SupportsReadFromResolve() const { - return false; -} - // |Capabilities| bool CapabilitiesVK::SupportsReadFromOnscreenTexture() const { return false; diff --git a/impeller/renderer/backend/vulkan/capabilities_vk.h b/impeller/renderer/backend/vulkan/capabilities_vk.h index a768610d9c4ba..1437d62a38fdf 100644 --- a/impeller/renderer/backend/vulkan/capabilities_vk.h +++ b/impeller/renderer/backend/vulkan/capabilities_vk.h @@ -10,7 +10,6 @@ #include #include -#include "flutter/fml/macros.h" #include "impeller/base/backend_cast.h" #include "impeller/renderer/backend/vulkan/vk.h" #include "impeller/renderer/capabilities.h" @@ -82,9 +81,6 @@ class CapabilitiesVK final : public Capabilities, // |Capabilities| bool SupportsComputeSubgroups() const override; - // |Capabilities| - bool SupportsReadFromResolve() const override; - // |Capabilities| bool SupportsReadFromOnscreenTexture() const override; diff --git a/impeller/renderer/capabilities.cc b/impeller/renderer/capabilities.cc index 80ea8e0f2b384..f1c038d9a5a1d 100644 --- a/impeller/renderer/capabilities.cc +++ b/impeller/renderer/capabilities.cc @@ -54,11 +54,6 @@ class StandardCapabilities final : public Capabilities { return supports_read_from_onscreen_texture_; } - // |Capabilities| - bool SupportsReadFromResolve() const override { - return supports_read_from_resolve_; - } - // |Capabilities| bool SupportsDecalSamplerAddressMode() const override { return supports_decal_sampler_address_mode_; @@ -92,7 +87,6 @@ class StandardCapabilities final : public Capabilities { bool supports_compute, bool supports_compute_subgroups, bool supports_read_from_onscreen_texture, - bool supports_read_from_resolve, bool supports_decal_sampler_address_mode, bool supports_device_transient_textures, PixelFormat default_color_format, @@ -107,7 +101,6 @@ class StandardCapabilities final : public Capabilities { supports_compute_subgroups_(supports_compute_subgroups), supports_read_from_onscreen_texture_( supports_read_from_onscreen_texture), - supports_read_from_resolve_(supports_read_from_resolve), supports_decal_sampler_address_mode_( supports_decal_sampler_address_mode), supports_device_transient_textures_(supports_device_transient_textures), @@ -125,7 +118,6 @@ class StandardCapabilities final : public Capabilities { bool supports_compute_ = false; bool supports_compute_subgroups_ = false; bool supports_read_from_onscreen_texture_ = false; - bool supports_read_from_resolve_ = false; bool supports_decal_sampler_address_mode_ = false; bool supports_device_transient_textures_ = false; PixelFormat default_color_format_ = PixelFormat::kUnknown; @@ -186,12 +178,6 @@ CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromOnscreenTexture( return *this; } -CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve( - bool read_from_resolve) { - supports_read_from_resolve_ = read_from_resolve; - return *this; -} - CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat( PixelFormat value) { default_color_format_ = value; @@ -232,7 +218,6 @@ std::unique_ptr CapabilitiesBuilder::Build() { supports_compute_, // supports_compute_subgroups_, // supports_read_from_onscreen_texture_, // - supports_read_from_resolve_, // supports_decal_sampler_address_mode_, // supports_device_transient_textures_, // default_color_format_.value_or(PixelFormat::kUnknown), // diff --git a/impeller/renderer/capabilities.h b/impeller/renderer/capabilities.h index 99d5986b1fe02..d5772e326aa28 100644 --- a/impeller/renderer/capabilities.h +++ b/impeller/renderer/capabilities.h @@ -68,19 +68,6 @@ class Capabilities { /// texture for shader reading. virtual bool SupportsReadFromOnscreenTexture() const = 0; - /// @brief Whether the context backend supports binding the current - /// `RenderPass` attachments. This is supported if the backend can - /// guarantee that attachment textures will not be mutated until the - /// render pass has fully completed. - /// - /// This is possible because many mobile graphics cards track - /// `RenderPass` attachment state in intermediary tile memory prior to - /// Storing the pass in the heap allocated attachments on DRAM. - /// Metal's hazard tracking and Vulkan's barriers are granular enough - /// to allow for safely accessing attachment textures prior to storage - /// in the same `RenderPass`. - virtual bool SupportsReadFromResolve() const = 0; - /// @brief Whether the context backend supports `SamplerAddressMode::Decal`. virtual bool SupportsDecalSamplerAddressMode() const = 0; @@ -138,8 +125,6 @@ class CapabilitiesBuilder { CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(bool value); - CapabilitiesBuilder& SetSupportsReadFromResolve(bool value); - CapabilitiesBuilder& SetDefaultColorFormat(PixelFormat value); CapabilitiesBuilder& SetDefaultStencilFormat(PixelFormat value); @@ -161,7 +146,6 @@ class CapabilitiesBuilder { bool supports_compute_ = false; bool supports_compute_subgroups_ = false; bool supports_read_from_onscreen_texture_ = false; - bool supports_read_from_resolve_ = false; bool supports_decal_sampler_address_mode_ = false; bool supports_device_transient_textures_ = false; std::optional default_color_format_ = std::nullopt; diff --git a/impeller/renderer/capabilities_unittests.cc b/impeller/renderer/capabilities_unittests.cc index beab9a9a53615..71d1824a82fc0 100644 --- a/impeller/renderer/capabilities_unittests.cc +++ b/impeller/renderer/capabilities_unittests.cc @@ -26,7 +26,6 @@ CAPABILITY_TEST(SupportsFramebufferFetch, false); CAPABILITY_TEST(SupportsCompute, false); CAPABILITY_TEST(SupportsComputeSubgroups, false); CAPABILITY_TEST(SupportsReadFromOnscreenTexture, false); -CAPABILITY_TEST(SupportsReadFromResolve, false); CAPABILITY_TEST(SupportsDecalSamplerAddressMode, false); CAPABILITY_TEST(SupportsDeviceTransientTextures, false);