[impeller] Refactored backend specific feature checks to capabilities (flutter/engine#39598)
part of https://github.com/flutter/flutter/issues/120498
This commit is contained in:
@@ -1431,7 +1431,6 @@ ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/texture_vk.h + ../../.
|
||||
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vk.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/backend_features.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/blit_command.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/blit_command.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/blit_pass.cc + ../../../flutter/LICENSE
|
||||
@@ -1459,6 +1458,8 @@ ORIGIN: ../../../flutter/impeller/renderer/device_buffer.cc + ../../../flutter/L
|
||||
ORIGIN: ../../../flutter/impeller/renderer/device_buffer.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/device_buffer_descriptor.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/device_buffer_descriptor.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/device_capabilities.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/device_capabilities.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/formats.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/formats.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/renderer/gpu_tracer.cc + ../../../flutter/LICENSE
|
||||
@@ -3908,7 +3909,6 @@ FILE: ../../../flutter/impeller/renderer/backend/vulkan/texture_vk.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc
|
||||
FILE: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/vulkan/vk.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend_features.h
|
||||
FILE: ../../../flutter/impeller/renderer/blit_command.cc
|
||||
FILE: ../../../flutter/impeller/renderer/blit_command.h
|
||||
FILE: ../../../flutter/impeller/renderer/blit_pass.cc
|
||||
@@ -3936,6 +3936,8 @@ FILE: ../../../flutter/impeller/renderer/device_buffer.cc
|
||||
FILE: ../../../flutter/impeller/renderer/device_buffer.h
|
||||
FILE: ../../../flutter/impeller/renderer/device_buffer_descriptor.cc
|
||||
FILE: ../../../flutter/impeller/renderer/device_buffer_descriptor.h
|
||||
FILE: ../../../flutter/impeller/renderer/device_capabilities.cc
|
||||
FILE: ../../../flutter/impeller/renderer/device_capabilities.h
|
||||
FILE: ../../../flutter/impeller/renderer/formats.cc
|
||||
FILE: ../../../flutter/impeller/renderer/formats.h
|
||||
FILE: ../../../flutter/impeller/renderer/gpu_tracer.cc
|
||||
|
||||
@@ -54,7 +54,7 @@ std::shared_ptr<Texture> Picture::RenderToTexture(
|
||||
// features to Image someday.
|
||||
auto impeller_context = context.GetContext();
|
||||
RenderTarget target;
|
||||
if (impeller_context->SupportsOffscreenMSAA()) {
|
||||
if (impeller_context->GetDeviceCapabilities().SupportsOffscreenMSAA()) {
|
||||
target = RenderTarget::CreateOffscreenMSAA(*impeller_context, size);
|
||||
} else {
|
||||
target = RenderTarget::CreateOffscreen(*impeller_context, size);
|
||||
|
||||
@@ -164,7 +164,7 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
CreateDefaultPipeline<LinearGradientFillPipeline>(*context_);
|
||||
radial_gradient_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<RadialGradientFillPipeline>(*context_);
|
||||
if (context_->GetBackendFeatures().ssbo_support) {
|
||||
if (context_->GetDeviceCapabilities().SupportsSSBO()) {
|
||||
linear_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<LinearGradientSSBOFillPipeline>(*context_);
|
||||
radial_gradient_ssbo_fill_pipelines_[{}] =
|
||||
@@ -270,7 +270,8 @@ std::shared_ptr<Texture> ContentContext::MakeSubpass(
|
||||
auto context = GetContext();
|
||||
|
||||
RenderTarget subpass_target;
|
||||
if (context->SupportsOffscreenMSAA() && msaa_enabled) {
|
||||
if (context->GetDeviceCapabilities().SupportsOffscreenMSAA() &&
|
||||
msaa_enabled) {
|
||||
subpass_target = RenderTarget::CreateOffscreenMSAA(*context, texture_size);
|
||||
} else {
|
||||
subpass_target = RenderTarget::CreateOffscreen(*context, texture_size);
|
||||
@@ -324,8 +325,8 @@ std::shared_ptr<Context> ContentContext::GetContext() const {
|
||||
return context_;
|
||||
}
|
||||
|
||||
const BackendFeatures& ContentContext::GetBackendFeatures() const {
|
||||
return context_->GetBackendFeatures();
|
||||
const IDeviceCapabilities& ContentContext::GetDeviceCapabilities() const {
|
||||
return context_->GetDeviceCapabilities();
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "impeller/entity/vertices.frag.h"
|
||||
#include "impeller/entity/yuv_to_rgb_filter.frag.h"
|
||||
#include "impeller/entity/yuv_to_rgb_filter.vert.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
#include "impeller/scene/scene_context.h"
|
||||
@@ -245,19 +246,19 @@ class ContentContext {
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetBackendFeatures().ssbo_support);
|
||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||
return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetBackendFeatures().ssbo_support);
|
||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||
return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetBackendFeatures().ssbo_support);
|
||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||
return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
@@ -442,7 +443,7 @@ class ContentContext {
|
||||
|
||||
std::shared_ptr<GlyphAtlasContext> GetGlyphAtlasContext() const;
|
||||
|
||||
const BackendFeatures& GetBackendFeatures() const;
|
||||
const IDeviceCapabilities& GetDeviceCapabilities() const;
|
||||
|
||||
using SubpassCallback =
|
||||
std::function<bool(const ContentContext&, RenderPass&)>;
|
||||
|
||||
@@ -47,7 +47,7 @@ void LinearGradientContents::SetTileMode(Entity::TileMode tile_mode) {
|
||||
bool LinearGradientContents::Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetBackendFeatures().ssbo_support) {
|
||||
if (renderer.GetDeviceCapabilities().SupportsSSBO()) {
|
||||
return RenderSSBO(renderer, entity, pass);
|
||||
}
|
||||
return RenderTexture(renderer, entity, pass);
|
||||
|
||||
@@ -48,7 +48,7 @@ const std::vector<Scalar>& RadialGradientContents::GetStops() const {
|
||||
bool RadialGradientContents::Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetBackendFeatures().ssbo_support) {
|
||||
if (renderer.GetDeviceCapabilities().SupportsSSBO()) {
|
||||
return RenderSSBO(renderer, entity, pass);
|
||||
}
|
||||
return RenderTexture(renderer, entity, pass);
|
||||
|
||||
@@ -53,7 +53,7 @@ const std::vector<Scalar>& SweepGradientContents::GetStops() const {
|
||||
bool SweepGradientContents::Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetBackendFeatures().ssbo_support) {
|
||||
if (renderer.GetDeviceCapabilities().SupportsSSBO()) {
|
||||
return RenderSSBO(renderer, entity, pass);
|
||||
}
|
||||
return RenderTexture(renderer, entity, pass);
|
||||
|
||||
@@ -154,7 +154,7 @@ static RenderTarget CreateRenderTarget(ContentContext& renderer,
|
||||
/// What's important is the `StorageMode` of the textures, which cannot be
|
||||
/// changed for the lifetime of the textures.
|
||||
|
||||
if (context->SupportsOffscreenMSAA()) {
|
||||
if (context->GetDeviceCapabilities().SupportsOffscreenMSAA()) {
|
||||
return RenderTarget::CreateOffscreenMSAA(
|
||||
*context, // context
|
||||
size, // size
|
||||
|
||||
@@ -35,6 +35,8 @@ impeller_component("renderer") {
|
||||
"device_buffer.h",
|
||||
"device_buffer_descriptor.cc",
|
||||
"device_buffer_descriptor.h",
|
||||
"device_capabilities.cc",
|
||||
"device_capabilities.h",
|
||||
"formats.cc",
|
||||
"formats.h",
|
||||
"gpu_tracer.cc",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "impeller/base/config.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/base/work_queue_common.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
@@ -68,6 +69,15 @@ ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
|
||||
}
|
||||
}
|
||||
|
||||
// Create the device capabilities.
|
||||
{
|
||||
device_capabilities_ = DeviceCapabilitiesBuilder()
|
||||
.SetHasThreadingRestrictions(true)
|
||||
.SetSupportsOffscreenMSAA(false)
|
||||
.SetSupportsSSBO(false)
|
||||
.Build();
|
||||
}
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
@@ -128,18 +138,8 @@ std::shared_ptr<WorkQueue> ContextGLES::GetWorkQueue() const {
|
||||
}
|
||||
|
||||
// |Context|
|
||||
bool ContextGLES::HasThreadingRestrictions() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// |Context|
|
||||
bool ContextGLES::SupportsOffscreenMSAA() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// |Context|
|
||||
const BackendFeatures& ContextGLES::GetBackendFeatures() const {
|
||||
return kLegacyBackendFeatures;
|
||||
const IDeviceCapabilities& ContextGLES::GetDeviceCapabilities() const {
|
||||
return *device_capabilities_;
|
||||
}
|
||||
|
||||
// |Context|
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "impeller/renderer/backend/gles/sampler_library_gles.h"
|
||||
#include "impeller/renderer/backend/gles/shader_library_gles.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
@@ -40,6 +41,7 @@ class ContextGLES final : public Context,
|
||||
std::shared_ptr<SamplerLibraryGLES> sampler_library_;
|
||||
std::shared_ptr<WorkQueue> work_queue_;
|
||||
std::shared_ptr<AllocatorGLES> resource_allocator_;
|
||||
std::unique_ptr<IDeviceCapabilities> device_capabilities_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
ContextGLES(
|
||||
@@ -68,13 +70,7 @@ class ContextGLES final : public Context,
|
||||
std::shared_ptr<WorkQueue> GetWorkQueue() const override;
|
||||
|
||||
// |Context|
|
||||
bool HasThreadingRestrictions() const override;
|
||||
|
||||
// |Context|
|
||||
bool SupportsOffscreenMSAA() const override;
|
||||
|
||||
// |Context|
|
||||
const BackendFeatures& GetBackendFeatures() const override;
|
||||
const IDeviceCapabilities& GetDeviceCapabilities() const override;
|
||||
|
||||
// |Context|
|
||||
PixelFormat GetColorAttachmentPixelFormat() const override;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "impeller/renderer/backend/metal/pipeline_library_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/shader_library_mtl.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
#include "impeller/renderer/sampler.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -45,6 +46,7 @@ class ContextMTL final : public Context,
|
||||
std::shared_ptr<AllocatorMTL> resource_allocator_;
|
||||
std::shared_ptr<WorkQueue> work_queue_;
|
||||
std::shared_ptr<GPUTracerMTL> gpu_tracer_;
|
||||
std::unique_ptr<IDeviceCapabilities> device_capabilities_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
ContextMTL(id<MTLDevice> device, NSArray<id<MTLLibrary>>* shader_libraries);
|
||||
@@ -74,10 +76,7 @@ class ContextMTL final : public Context,
|
||||
std::shared_ptr<GPUTracer> GetGPUTracer() const override;
|
||||
|
||||
// |Context|
|
||||
bool SupportsOffscreenMSAA() const override;
|
||||
|
||||
// |Context|
|
||||
const BackendFeatures& GetBackendFeatures() const override;
|
||||
const IDeviceCapabilities& GetDeviceCapabilities() const override;
|
||||
|
||||
std::shared_ptr<CommandBuffer> CreateCommandBufferInQueue(
|
||||
id<MTLCommandQueue> queue) const;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "flutter/fml/paths.h"
|
||||
#include "impeller/base/platform/darwin/work_queue_darwin.h"
|
||||
#include "impeller/renderer/backend/metal/sampler_library_mtl.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
#include "impeller/renderer/sampler_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -88,6 +89,14 @@ ContextMTL::ContextMTL(id<MTLDevice> device,
|
||||
{ gpu_tracer_ = std::shared_ptr<GPUTracerMTL>(new GPUTracerMTL(device_)); }
|
||||
#endif
|
||||
|
||||
{
|
||||
device_capabilities_ = DeviceCapabilitiesBuilder()
|
||||
.SetHasThreadingRestrictions(false)
|
||||
.SetSupportsOffscreenMSAA(true)
|
||||
.SetSupportsSSBO(true)
|
||||
.Build();
|
||||
}
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
@@ -245,14 +254,8 @@ id<MTLDevice> ContextMTL::GetMTLDevice() const {
|
||||
return device_;
|
||||
}
|
||||
|
||||
// |Context|
|
||||
bool ContextMTL::SupportsOffscreenMSAA() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// |Context|
|
||||
const BackendFeatures& ContextMTL::GetBackendFeatures() const {
|
||||
return kModernBackendFeatures;
|
||||
const IDeviceCapabilities& ContextMTL::GetDeviceCapabilities() const {
|
||||
return *device_capabilities_;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "impeller/renderer/backend/vulkan/surface_producer_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/swapchain_details_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/vk.h"
|
||||
#include "impeller/renderer/backend_features.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
|
||||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
||||
|
||||
@@ -499,6 +499,12 @@ ContextVK::ContextVK(
|
||||
transfer_queue_ =
|
||||
device_->getQueue(transfer_queue->family, transfer_queue->index);
|
||||
|
||||
device_capabilities_ = DeviceCapabilitiesBuilder()
|
||||
.SetHasThreadingRestrictions(false)
|
||||
.SetSupportsOffscreenMSAA(true)
|
||||
.SetSupportsSSBO(false)
|
||||
.Build();
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
@@ -589,10 +595,6 @@ void ContextVK::SetupSwapchain(vk::UniqueSurfaceKHR surface) {
|
||||
});
|
||||
}
|
||||
|
||||
bool ContextVK::SupportsOffscreenMSAA() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<DescriptorPoolVK> ContextVK::CreateDescriptorPool() const {
|
||||
return std::make_unique<DescriptorPoolVK>(*device_);
|
||||
}
|
||||
@@ -601,8 +603,8 @@ PixelFormat ContextVK::GetColorAttachmentPixelFormat() const {
|
||||
return ToPixelFormat(surface_format_);
|
||||
}
|
||||
|
||||
const BackendFeatures& ContextVK::GetBackendFeatures() const {
|
||||
return kLegacyBackendFeatures;
|
||||
const IDeviceCapabilities& ContextVK::GetDeviceCapabilities() const {
|
||||
return *device_capabilities_;
|
||||
}
|
||||
|
||||
vk::Queue ContextVK::GetGraphicsQueue() const {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "impeller/renderer/backend/vulkan/swapchain_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/vk.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -116,6 +117,7 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
|
||||
std::unique_ptr<SwapchainVK> swapchain_;
|
||||
std::unique_ptr<SurfaceProducerVK> surface_producer_;
|
||||
std::shared_ptr<WorkQueue> work_queue_;
|
||||
std::unique_ptr<IDeviceCapabilities> device_capabilities_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
ContextVK(
|
||||
@@ -147,10 +149,7 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
|
||||
std::shared_ptr<WorkQueue> GetWorkQueue() const override;
|
||||
|
||||
// |Context|
|
||||
bool SupportsOffscreenMSAA() const override;
|
||||
|
||||
// |Context|
|
||||
const BackendFeatures& GetBackendFeatures() const override;
|
||||
const IDeviceCapabilities& GetDeviceCapabilities() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ContextVK);
|
||||
};
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace impeller {
|
||||
|
||||
/// @brief A struct for describing available backend features for runtime
|
||||
/// selection.
|
||||
struct BackendFeatures {
|
||||
bool ssbo_support;
|
||||
};
|
||||
|
||||
/// @brief feature sets available on most but not all modern hardware.
|
||||
constexpr BackendFeatures kModernBackendFeatures = {.ssbo_support = true};
|
||||
|
||||
/// @brief Lowest common denominator feature sets.
|
||||
constexpr BackendFeatures kLegacyBackendFeatures = {.ssbo_support = false};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -10,10 +10,6 @@ Context::~Context() = default;
|
||||
|
||||
Context::Context() = default;
|
||||
|
||||
bool Context::HasThreadingRestrictions() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<GPUTracer> Context::GetGPUTracer() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/backend_features.h"
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -49,11 +49,7 @@ class Context : public std::enable_shared_from_this<Context> {
|
||||
|
||||
virtual PixelFormat GetColorAttachmentPixelFormat() const;
|
||||
|
||||
virtual bool HasThreadingRestrictions() const;
|
||||
|
||||
virtual bool SupportsOffscreenMSAA() const = 0;
|
||||
|
||||
virtual const BackendFeatures& GetBackendFeatures() const = 0;
|
||||
virtual const IDeviceCapabilities& GetDeviceCapabilities() const = 0;
|
||||
|
||||
protected:
|
||||
Context();
|
||||
|
||||
58
engine/src/flutter/impeller/renderer/device_capabilities.cc
Normal file
58
engine/src/flutter/impeller/renderer/device_capabilities.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/device_capabilities.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
IDeviceCapabilities::IDeviceCapabilities(bool threading_restrictions,
|
||||
bool offscreen_msaa,
|
||||
bool supports_ssbo)
|
||||
: threading_restrictions_(threading_restrictions),
|
||||
offscreen_msaa_(offscreen_msaa),
|
||||
supports_ssbo_(supports_ssbo) {}
|
||||
|
||||
IDeviceCapabilities::~IDeviceCapabilities() = default;
|
||||
|
||||
bool IDeviceCapabilities::HasThreadingRestrictions() const {
|
||||
return threading_restrictions_;
|
||||
}
|
||||
|
||||
bool IDeviceCapabilities::SupportsOffscreenMSAA() const {
|
||||
return offscreen_msaa_;
|
||||
}
|
||||
|
||||
bool IDeviceCapabilities::SupportsSSBO() const {
|
||||
return supports_ssbo_;
|
||||
}
|
||||
|
||||
DeviceCapabilitiesBuilder::DeviceCapabilitiesBuilder() = default;
|
||||
|
||||
DeviceCapabilitiesBuilder::~DeviceCapabilitiesBuilder() = default;
|
||||
|
||||
DeviceCapabilitiesBuilder&
|
||||
DeviceCapabilitiesBuilder::SetHasThreadingRestrictions(bool value) {
|
||||
threading_restrictions_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetSupportsOffscreenMSAA(
|
||||
bool value) {
|
||||
offscreen_msaa_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceCapabilitiesBuilder& DeviceCapabilitiesBuilder::SetSupportsSSBO(
|
||||
bool value) {
|
||||
supports_ssbo_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::unique_ptr<IDeviceCapabilities> DeviceCapabilitiesBuilder::Build() {
|
||||
IDeviceCapabilities* capabilities = new IDeviceCapabilities(
|
||||
threading_restrictions_, offscreen_msaa_, supports_ssbo_);
|
||||
return std::unique_ptr<IDeviceCapabilities>(capabilities);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
59
engine/src/flutter/impeller/renderer/device_capabilities.h
Normal file
59
engine/src/flutter/impeller/renderer/device_capabilities.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class IDeviceCapabilities {
|
||||
public:
|
||||
~IDeviceCapabilities();
|
||||
|
||||
bool HasThreadingRestrictions() const;
|
||||
|
||||
bool SupportsOffscreenMSAA() const;
|
||||
|
||||
bool SupportsSSBO() const;
|
||||
|
||||
private:
|
||||
IDeviceCapabilities(bool threading_restrictions,
|
||||
bool offscreen_msaa,
|
||||
bool supports_ssbo);
|
||||
|
||||
friend class DeviceCapabilitiesBuilder;
|
||||
|
||||
bool threading_restrictions_ = false;
|
||||
bool offscreen_msaa_ = false;
|
||||
bool supports_ssbo_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(IDeviceCapabilities);
|
||||
};
|
||||
|
||||
class DeviceCapabilitiesBuilder {
|
||||
public:
|
||||
DeviceCapabilitiesBuilder();
|
||||
|
||||
~DeviceCapabilitiesBuilder();
|
||||
|
||||
DeviceCapabilitiesBuilder& SetHasThreadingRestrictions(bool value);
|
||||
|
||||
DeviceCapabilitiesBuilder& SetSupportsOffscreenMSAA(bool value);
|
||||
|
||||
DeviceCapabilitiesBuilder& SetSupportsSSBO(bool value);
|
||||
|
||||
std::unique_ptr<IDeviceCapabilities> Build();
|
||||
|
||||
private:
|
||||
bool threading_restrictions_ = false;
|
||||
bool offscreen_msaa_ = false;
|
||||
bool supports_ssbo_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(DeviceCapabilitiesBuilder);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -320,7 +320,7 @@ void ImageDecoderImpeller::Decode(fml::RefPtr<ImageDescriptor> descriptor,
|
||||
// Depending on whether the context has threading restrictions, stay on
|
||||
// the concurrent runner to perform texture upload or move to an IO
|
||||
// runner.
|
||||
if (context->HasThreadingRestrictions()) {
|
||||
if (context->GetDeviceCapabilities().HasThreadingRestrictions()) {
|
||||
io_runner->PostTask(upload_texture_and_invoke_result);
|
||||
} else {
|
||||
upload_texture_and_invoke_result();
|
||||
|
||||
@@ -52,12 +52,8 @@ class CustomColorAttachmentPixelFormatContext final : public Context {
|
||||
return color_attachment_pixel_format_;
|
||||
}
|
||||
|
||||
bool HasThreadingRestrictions() const override { return context_->HasThreadingRestrictions(); }
|
||||
|
||||
bool SupportsOffscreenMSAA() const override { return context_->SupportsOffscreenMSAA(); }
|
||||
|
||||
const BackendFeatures& GetBackendFeatures() const override {
|
||||
return context_->GetBackendFeatures();
|
||||
const IDeviceCapabilities& GetDeviceCapabilities() const override {
|
||||
return context_->GetDeviceCapabilities();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user