[Impeller] switch Pipeline to use raw ptr instead of shared ptr for recorded references. (flutter/engine#57015)
Fixes https://github.com/flutter/flutter/issues/159566 We don't need recorded commands to keep pipelines alive as the context does that already.
This commit is contained in:
@@ -43017,6 +43017,8 @@ ORIGIN: ../../../flutter/impeller/core/platform.cc + ../../../flutter/LICENSE
|
|||||||
ORIGIN: ../../../flutter/impeller/core/platform.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/platform.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/impeller/core/range.cc + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/range.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/impeller/core/range.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/range.h + ../../../flutter/LICENSE
|
||||||
|
ORIGIN: ../../../flutter/impeller/core/raw_ptr.cc + ../../../flutter/LICENSE
|
||||||
|
ORIGIN: ../../../flutter/impeller/core/raw_ptr.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/impeller/core/resource_binder.cc + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/resource_binder.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/impeller/core/resource_binder.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/resource_binder.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/impeller/core/runtime_types.cc + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/impeller/core/runtime_types.cc + ../../../flutter/LICENSE
|
||||||
@@ -45946,6 +45948,8 @@ FILE: ../../../flutter/impeller/core/platform.cc
|
|||||||
FILE: ../../../flutter/impeller/core/platform.h
|
FILE: ../../../flutter/impeller/core/platform.h
|
||||||
FILE: ../../../flutter/impeller/core/range.cc
|
FILE: ../../../flutter/impeller/core/range.cc
|
||||||
FILE: ../../../flutter/impeller/core/range.h
|
FILE: ../../../flutter/impeller/core/range.h
|
||||||
|
FILE: ../../../flutter/impeller/core/raw_ptr.cc
|
||||||
|
FILE: ../../../flutter/impeller/core/raw_ptr.h
|
||||||
FILE: ../../../flutter/impeller/core/resource_binder.cc
|
FILE: ../../../flutter/impeller/core/resource_binder.cc
|
||||||
FILE: ../../../flutter/impeller/core/resource_binder.h
|
FILE: ../../../flutter/impeller/core/resource_binder.h
|
||||||
FILE: ../../../flutter/impeller/core/runtime_types.cc
|
FILE: ../../../flutter/impeller/core/runtime_types.cc
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ impeller_component("core") {
|
|||||||
"platform.h",
|
"platform.h",
|
||||||
"range.cc",
|
"range.cc",
|
||||||
"range.h",
|
"range.h",
|
||||||
|
"raw_ptr.cc",
|
||||||
|
"raw_ptr.h",
|
||||||
"resource_binder.cc",
|
"resource_binder.cc",
|
||||||
"resource_binder.h",
|
"resource_binder.h",
|
||||||
"runtime_types.cc",
|
"runtime_types.cc",
|
||||||
|
|||||||
11
engine/src/flutter/impeller/core/raw_ptr.cc
Normal file
11
engine/src/flutter/impeller/core/raw_ptr.cc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// 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/core/raw_ptr.h"
|
||||||
|
|
||||||
|
namespace impeller {
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
}
|
||||||
84
engine/src/flutter/impeller/core/raw_ptr.h
Normal file
84
engine/src/flutter/impeller/core/raw_ptr.h
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef FLUTTER_IMPELLER_CORE_RAW_PTR_H_
|
||||||
|
#define FLUTTER_IMPELLER_CORE_RAW_PTR_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace impeller {
|
||||||
|
|
||||||
|
/// @brief A wrapper around a raw ptr that adds additional unopt mode only
|
||||||
|
/// checks.
|
||||||
|
template <typename T>
|
||||||
|
class raw_ptr {
|
||||||
|
public:
|
||||||
|
explicit raw_ptr(const std::shared_ptr<T>& ptr)
|
||||||
|
: ptr_(ptr.get())
|
||||||
|
#if !NDEBUG
|
||||||
|
,
|
||||||
|
weak_ptr_(ptr)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ptr() : ptr_(nullptr) {}
|
||||||
|
|
||||||
|
T* operator->() {
|
||||||
|
#if !NDEBUG
|
||||||
|
FML_CHECK(weak_ptr_.lock());
|
||||||
|
#endif
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const T* operator->() const {
|
||||||
|
#if !NDEBUG
|
||||||
|
FML_CHECK(weak_ptr_.lock());
|
||||||
|
#endif
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() {
|
||||||
|
#if !NDEBUG
|
||||||
|
FML_CHECK(weak_ptr_.lock());
|
||||||
|
#endif
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator*() {
|
||||||
|
#if !NDEBUG
|
||||||
|
FML_CHECK(weak_ptr_.lock());
|
||||||
|
#endif
|
||||||
|
return *ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& operator*() const {
|
||||||
|
#if !NDEBUG
|
||||||
|
FML_CHECK(weak_ptr_.lock());
|
||||||
|
#endif
|
||||||
|
return *ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
inline bool operator==(raw_ptr<U> const& other) const {
|
||||||
|
return ptr_ == other.ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
inline bool operator!=(raw_ptr<U> const& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator bool() const { return !!ptr_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* ptr_;
|
||||||
|
#if !NDEBUG
|
||||||
|
std::weak_ptr<T> weak_ptr_;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace impeller
|
||||||
|
|
||||||
|
#endif // FLUTTER_IMPELLER_CORE_RAW_PTR_H_
|
||||||
@@ -104,8 +104,7 @@ class ColorSourceContents : public Contents {
|
|||||||
using PipelineBuilderMethod = std::shared_ptr<Pipeline<PipelineDescriptor>> (
|
using PipelineBuilderMethod = std::shared_ptr<Pipeline<PipelineDescriptor>> (
|
||||||
impeller::ContentContext::*)(ContentContextOptions) const;
|
impeller::ContentContext::*)(ContentContextOptions) const;
|
||||||
using PipelineBuilderCallback =
|
using PipelineBuilderCallback =
|
||||||
std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>(
|
std::function<PipelineRef(ContentContextOptions)>;
|
||||||
ContentContextOptions)>;
|
|
||||||
using CreateGeometryCallback =
|
using CreateGeometryCallback =
|
||||||
std::function<GeometryResult(const ContentContext& renderer,
|
std::function<GeometryResult(const ContentContext& renderer,
|
||||||
const Entity& entity,
|
const Entity& entity,
|
||||||
|
|||||||
@@ -569,8 +569,7 @@ void ContentContext::SetWireframe(bool wireframe) {
|
|||||||
wireframe_ = wireframe;
|
wireframe_ = wireframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef ContentContext::GetCachedRuntimeEffectPipeline(
|
||||||
ContentContext::GetCachedRuntimeEffectPipeline(
|
|
||||||
const std::string& unique_entrypoint_name,
|
const std::string& unique_entrypoint_name,
|
||||||
const ContentContextOptions& options,
|
const ContentContextOptions& options,
|
||||||
const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
|
const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
|
||||||
@@ -580,7 +579,7 @@ ContentContext::GetCachedRuntimeEffectPipeline(
|
|||||||
if (it == runtime_effect_pipelines_.end()) {
|
if (it == runtime_effect_pipelines_.end()) {
|
||||||
it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
|
it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
|
||||||
}
|
}
|
||||||
return it->second;
|
return raw_ptr(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentContext::ClearCachedRuntimeEffectPipeline(
|
void ContentContext::ClearCachedRuntimeEffectPipeline(
|
||||||
|
|||||||
@@ -377,102 +377,93 @@ class ContentContext {
|
|||||||
|
|
||||||
Tessellator& GetTessellator() const;
|
Tessellator& GetTessellator() const;
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline(
|
PipelineRef GetFastGradientPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(fast_gradient_pipelines_, opts);
|
return GetPipeline(fast_gradient_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearGradientFillPipeline(
|
PipelineRef GetLinearGradientFillPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(linear_gradient_fill_pipelines_, opts);
|
return GetPipeline(linear_gradient_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetLinearGradientUniformFillPipeline(
|
||||||
GetLinearGradientUniformFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(linear_gradient_uniform_fill_pipelines_, opts);
|
return GetPipeline(linear_gradient_uniform_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetRadialGradientUniformFillPipeline(
|
||||||
GetRadialGradientUniformFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(radial_gradient_uniform_fill_pipelines_, opts);
|
return GetPipeline(radial_gradient_uniform_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetConicalGradientUniformFillPipeline(
|
||||||
GetConicalGradientUniformFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(conical_gradient_uniform_fill_pipelines_, opts);
|
return GetPipeline(conical_gradient_uniform_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetSweepGradientUniformFillPipeline(
|
||||||
GetSweepGradientUniformFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(sweep_gradient_uniform_fill_pipelines_, opts);
|
return GetPipeline(sweep_gradient_uniform_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetLinearGradientSSBOFillPipeline(
|
||||||
GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||||
return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
|
return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetRadialGradientSSBOFillPipeline(
|
||||||
GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||||
return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
|
return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetConicalGradientSSBOFillPipeline(
|
||||||
GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||||
return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
|
return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetSweepGradientSSBOFillPipeline(
|
||||||
GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||||
return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
|
return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
|
PipelineRef GetRadialGradientFillPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(radial_gradient_fill_pipelines_, opts);
|
return GetPipeline(radial_gradient_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetConicalGradientFillPipeline(
|
PipelineRef GetConicalGradientFillPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(conical_gradient_fill_pipelines_, opts);
|
return GetPipeline(conical_gradient_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
|
PipelineRef GetRRectBlurPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(rrect_blur_pipelines_, opts);
|
return GetPipeline(rrect_blur_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSweepGradientFillPipeline(
|
PipelineRef GetSweepGradientFillPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(sweep_gradient_fill_pipelines_, opts);
|
return GetPipeline(sweep_gradient_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidFillPipeline(
|
PipelineRef GetSolidFillPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(solid_fill_pipelines_, opts);
|
return GetPipeline(solid_fill_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
|
PipelineRef GetTexturePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(texture_pipelines_, opts);
|
return GetPipeline(texture_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureStrictSrcPipeline(
|
PipelineRef GetTextureStrictSrcPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(texture_strict_src_pipelines_, opts);
|
return GetPipeline(texture_strict_src_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMPELLER_ENABLE_OPENGLES
|
#ifdef IMPELLER_ENABLE_OPENGLES
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetDownsampleTextureGlesPipeline(
|
||||||
GetDownsampleTextureGlesPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(texture_downsample_gles_pipelines_, opts);
|
return GetPipeline(texture_downsample_gles_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTextureExternalPipeline(
|
PipelineRef GetTiledTextureExternalPipeline(
|
||||||
ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetContext()->GetBackendType() ==
|
FML_DCHECK(GetContext()->GetBackendType() ==
|
||||||
Context::BackendType::kOpenGLES);
|
Context::BackendType::kOpenGLES);
|
||||||
@@ -480,236 +471,208 @@ class ContentContext {
|
|||||||
}
|
}
|
||||||
#endif // IMPELLER_ENABLE_OPENGLES
|
#endif // IMPELLER_ENABLE_OPENGLES
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTexturePipeline(
|
PipelineRef GetTiledTexturePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(tiled_texture_pipelines_, opts);
|
return GetPipeline(tiled_texture_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
|
PipelineRef GetGaussianBlurPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(gaussian_blur_pipelines_, opts);
|
return GetPipeline(gaussian_blur_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
|
PipelineRef GetBorderMaskBlurPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(border_mask_blur_pipelines_, opts);
|
return GetPipeline(border_mask_blur_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetMorphologyFilterPipeline(
|
PipelineRef GetMorphologyFilterPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(morphology_filter_pipelines_, opts);
|
return GetPipeline(morphology_filter_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetColorMatrixColorFilterPipeline(
|
||||||
GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
return GetPipeline(color_matrix_color_filter_pipelines_, opts);
|
return GetPipeline(color_matrix_color_filter_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearToSrgbFilterPipeline(
|
PipelineRef GetLinearToSrgbFilterPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
|
return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSrgbToLinearFilterPipeline(
|
PipelineRef GetSrgbToLinearFilterPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
|
return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
|
PipelineRef GetClipPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(clip_pipelines_, opts);
|
return GetPipeline(clip_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasPipeline(
|
PipelineRef GetGlyphAtlasPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(glyph_atlas_pipelines_, opts);
|
return GetPipeline(glyph_atlas_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetYUVToRGBFilterPipeline(
|
PipelineRef GetYUVToRGBFilterPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
|
return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetPorterDuffBlendPipeline(
|
PipelineRef GetPorterDuffBlendPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(porter_duff_blend_pipelines_, opts);
|
return GetPipeline(porter_duff_blend_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advanced blends.
|
// Advanced blends.
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
|
PipelineRef GetBlendColorPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_color_pipelines_, opts);
|
return GetPipeline(blend_color_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorBurnPipeline(
|
PipelineRef GetBlendColorBurnPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_colorburn_pipelines_, opts);
|
return GetPipeline(blend_colorburn_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorDodgePipeline(
|
PipelineRef GetBlendColorDodgePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_colordodge_pipelines_, opts);
|
return GetPipeline(blend_colordodge_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDarkenPipeline(
|
PipelineRef GetBlendDarkenPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_darken_pipelines_, opts);
|
return GetPipeline(blend_darken_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDifferencePipeline(
|
PipelineRef GetBlendDifferencePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_difference_pipelines_, opts);
|
return GetPipeline(blend_difference_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendExclusionPipeline(
|
PipelineRef GetBlendExclusionPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_exclusion_pipelines_, opts);
|
return GetPipeline(blend_exclusion_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHardLightPipeline(
|
PipelineRef GetBlendHardLightPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_hardlight_pipelines_, opts);
|
return GetPipeline(blend_hardlight_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHuePipeline(
|
PipelineRef GetBlendHuePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_hue_pipelines_, opts);
|
return GetPipeline(blend_hue_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLightenPipeline(
|
PipelineRef GetBlendLightenPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_lighten_pipelines_, opts);
|
return GetPipeline(blend_lighten_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
|
PipelineRef GetBlendLuminosityPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_luminosity_pipelines_, opts);
|
return GetPipeline(blend_luminosity_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendMultiplyPipeline(
|
PipelineRef GetBlendMultiplyPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_multiply_pipelines_, opts);
|
return GetPipeline(blend_multiply_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendOverlayPipeline(
|
PipelineRef GetBlendOverlayPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_overlay_pipelines_, opts);
|
return GetPipeline(blend_overlay_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSaturationPipeline(
|
PipelineRef GetBlendSaturationPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_saturation_pipelines_, opts);
|
return GetPipeline(blend_saturation_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendScreenPipeline(
|
PipelineRef GetBlendScreenPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_screen_pipelines_, opts);
|
return GetPipeline(blend_screen_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSoftLightPipeline(
|
PipelineRef GetBlendSoftLightPipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(blend_softlight_pipelines_, opts);
|
return GetPipeline(blend_softlight_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetDownsamplePipeline(
|
PipelineRef GetDownsamplePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(texture_downsample_pipelines_, opts);
|
return GetPipeline(texture_downsample_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Framebuffer Advanced Blends
|
// Framebuffer Advanced Blends
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendColorPipeline(
|
||||||
GetFramebufferBlendColorPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_color_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_color_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendColorBurnPipeline(
|
||||||
GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendColorDodgePipeline(
|
||||||
GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendDarkenPipeline(
|
||||||
GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendDifferencePipeline(
|
||||||
GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendExclusionPipeline(
|
||||||
GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendHardLightPipeline(
|
||||||
GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFramebufferBlendHuePipeline(
|
PipelineRef GetFramebufferBlendHuePipeline(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendLightenPipeline(
|
||||||
GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendLuminosityPipeline(
|
||||||
GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendMultiplyPipeline(
|
||||||
GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendOverlayPipeline(
|
||||||
GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendSaturationPipeline(
|
||||||
GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendScreenPipeline(
|
||||||
GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
PipelineRef GetFramebufferBlendSoftLightPipeline(
|
||||||
GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const {
|
ContentContextOptions opts) const {
|
||||||
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
|
||||||
return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
|
return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetDrawVerticesUberShader(
|
PipelineRef GetDrawVerticesUberShader(ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
return GetPipeline(vertices_uber_shader_, opts);
|
return GetPipeline(vertices_uber_shader_, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,7 +724,7 @@ class ContentContext {
|
|||||||
///
|
///
|
||||||
/// The create_callback is synchronously invoked exactly once if a cached
|
/// The create_callback is synchronously invoked exactly once if a cached
|
||||||
/// pipeline is not found.
|
/// pipeline is not found.
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetCachedRuntimeEffectPipeline(
|
PipelineRef GetCachedRuntimeEffectPipeline(
|
||||||
const std::string& unique_entrypoint_name,
|
const std::string& unique_entrypoint_name,
|
||||||
const ContentContextOptions& options,
|
const ContentContextOptions& options,
|
||||||
const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
|
const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
|
||||||
@@ -992,14 +955,13 @@ class ContentContext {
|
|||||||
mutable Variants<VerticesUberShader> vertices_uber_shader_;
|
mutable Variants<VerticesUberShader> vertices_uber_shader_;
|
||||||
|
|
||||||
template <class TypedPipeline>
|
template <class TypedPipeline>
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
|
PipelineRef GetPipeline(Variants<TypedPipeline>& container,
|
||||||
Variants<TypedPipeline>& container,
|
ContentContextOptions opts) const {
|
||||||
ContentContextOptions opts) const {
|
|
||||||
TypedPipeline* pipeline = CreateIfNeeded(container, opts);
|
TypedPipeline* pipeline = CreateIfNeeded(container, opts);
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
return nullptr;
|
return raw_ptr<Pipeline<PipelineDescriptor>>();
|
||||||
}
|
}
|
||||||
return pipeline->WaitAndGet();
|
return raw_ptr(pipeline->WaitAndGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class RenderPipelineHandleT>
|
template <class RenderPipelineHandleT>
|
||||||
@@ -1023,7 +985,7 @@ class ContentContext {
|
|||||||
// The default must always be initialized in the constructor.
|
// The default must always be initialized in the constructor.
|
||||||
FML_CHECK(default_handle != nullptr);
|
FML_CHECK(default_handle != nullptr);
|
||||||
|
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
|
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline =
|
||||||
default_handle->WaitAndGet();
|
default_handle->WaitAndGet();
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ BlendFilterContents::BlendFilterContents() {
|
|||||||
|
|
||||||
BlendFilterContents::~BlendFilterContents() = default;
|
BlendFilterContents::~BlendFilterContents() = default;
|
||||||
|
|
||||||
using PipelineProc = std::shared_ptr<Pipeline<PipelineDescriptor>> (
|
using PipelineProc =
|
||||||
ContentContext::*)(ContentContextOptions) const;
|
PipelineRef (ContentContext::*)(ContentContextOptions) const;
|
||||||
|
|
||||||
template <typename TPipeline>
|
template <typename TPipeline>
|
||||||
static std::optional<Entity> AdvancedBlend(
|
static std::optional<Entity> AdvancedBlend(
|
||||||
@@ -170,8 +170,7 @@ static std::optional<Entity> AdvancedBlend(
|
|||||||
auto options = OptionsFromPass(pass);
|
auto options = OptionsFromPass(pass);
|
||||||
options.primitive_type = PrimitiveType::kTriangleStrip;
|
options.primitive_type = PrimitiveType::kTriangleStrip;
|
||||||
options.blend_mode = BlendMode::kSource;
|
options.blend_mode = BlendMode::kSource;
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
|
PipelineRef pipeline = std::invoke(pipeline_proc, renderer, options);
|
||||||
std::invoke(pipeline_proc, renderer, options);
|
|
||||||
|
|
||||||
#ifdef IMPELLER_DEBUG
|
#ifdef IMPELLER_DEBUG
|
||||||
pass.SetCommandLabel(
|
pass.SetCommandLabel(
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ RecordingRenderPass::RecordingRenderPass(
|
|||||||
: RenderPass(context, render_target), delegate_(std::move(delegate)) {}
|
: RenderPass(context, render_target), delegate_(std::move(delegate)) {}
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void RecordingRenderPass::SetPipeline(
|
void RecordingRenderPass::SetPipeline(PipelineRef pipeline) {
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) {
|
|
||||||
pending_.pipeline = pipeline;
|
pending_.pipeline = pipeline;
|
||||||
if (delegate_) {
|
if (delegate_) {
|
||||||
delegate_->SetPipeline(pipeline);
|
delegate_->SetPipeline(pipeline);
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ class RecordingRenderPass : public RenderPass {
|
|||||||
const std::vector<Command>& GetCommands() const override { return commands_; }
|
const std::vector<Command>& GetCommands() const override { return commands_; }
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void SetPipeline(
|
void SetPipeline(PipelineRef pipeline) override;
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
|
|
||||||
|
|
||||||
void SetCommandLabel(std::string_view label) override;
|
void SetCommandLabel(std::string_view label) override;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "impeller/core/device_buffer.h"
|
#include "impeller/core/device_buffer.h"
|
||||||
#include "impeller/core/formats.h"
|
#include "impeller/core/formats.h"
|
||||||
#include "impeller/core/host_buffer.h"
|
#include "impeller/core/host_buffer.h"
|
||||||
|
#include "impeller/core/raw_ptr.h"
|
||||||
#include "impeller/core/texture_descriptor.h"
|
#include "impeller/core/texture_descriptor.h"
|
||||||
#include "impeller/entity/contents/clip_contents.h"
|
#include "impeller/entity/contents/clip_contents.h"
|
||||||
#include "impeller/entity/contents/conical_gradient_contents.h"
|
#include "impeller/entity/contents/conical_gradient_contents.h"
|
||||||
@@ -1696,7 +1697,7 @@ TEST_P(EntityTest, RuntimeEffect) {
|
|||||||
ASSERT_TRUE(runtime_stage->IsDirty());
|
ASSERT_TRUE(runtime_stage->IsDirty());
|
||||||
|
|
||||||
bool expect_dirty = true;
|
bool expect_dirty = true;
|
||||||
Pipeline<PipelineDescriptor>* first_pipeline;
|
PipelineRef first_pipeline;
|
||||||
std::unique_ptr<Geometry> geom = Geometry::MakeCover();
|
std::unique_ptr<Geometry> geom = Geometry::MakeCover();
|
||||||
|
|
||||||
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
|
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
|
||||||
@@ -1723,10 +1724,10 @@ TEST_P(EntityTest, RuntimeEffect) {
|
|||||||
bool result = contents->Render(context, entity, pass);
|
bool result = contents->Render(context, entity, pass);
|
||||||
|
|
||||||
if (expect_dirty) {
|
if (expect_dirty) {
|
||||||
EXPECT_NE(first_pipeline, pass.GetCommands().back().pipeline.get());
|
EXPECT_NE(first_pipeline, pass.GetCommands().back().pipeline);
|
||||||
first_pipeline = pass.GetCommands().back().pipeline.get();
|
first_pipeline = pass.GetCommands().back().pipeline;
|
||||||
} else {
|
} else {
|
||||||
EXPECT_EQ(pass.GetCommands().back().pipeline.get(), first_pipeline);
|
EXPECT_EQ(pass.GetCommands().back().pipeline, first_pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect_dirty = false;
|
expect_dirty = false;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include "impeller/geometry/point.h"
|
#include "impeller/geometry/point.h"
|
||||||
#include "impeller/geometry/rect.h"
|
#include "impeller/geometry/rect.h"
|
||||||
#include "impeller/geometry/size.h"
|
#include "impeller/geometry/size.h"
|
||||||
#include "impeller/renderer/command.h"
|
|
||||||
#include "impeller/renderer/context.h"
|
#include "impeller/renderer/context.h"
|
||||||
#include "impeller/renderer/pipeline_builder.h"
|
#include "impeller/renderer/pipeline_builder.h"
|
||||||
#include "impeller/renderer/pipeline_descriptor.h"
|
#include "impeller/renderer/pipeline_descriptor.h"
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ class RenderPassMTL final : public RenderPass {
|
|||||||
bool OnEncodeCommands(const Context& context) const override;
|
bool OnEncodeCommands(const Context& context) const override;
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void SetPipeline(
|
void SetPipeline(PipelineRef pipeline) override;
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
|
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void SetCommandLabel(std::string_view label) override;
|
void SetCommandLabel(std::string_view label) override;
|
||||||
|
|||||||
@@ -233,8 +233,7 @@ static bool Bind(PassBindingsCacheMTL& pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void RenderPassMTL::SetPipeline(
|
void RenderPassMTL::SetPipeline(PipelineRef pipeline) {
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) {
|
|
||||||
const PipelineDescriptor& pipeline_desc = pipeline->GetDescriptor();
|
const PipelineDescriptor& pipeline_desc = pipeline->GetDescriptor();
|
||||||
primitive_type_ = pipeline_desc.GetPrimitiveType();
|
primitive_type_ = pipeline_desc.GetPrimitiveType();
|
||||||
pass_bindings_.SetRenderPipelineState(
|
pass_bindings_.SetRenderPipelineState(
|
||||||
|
|||||||
@@ -293,9 +293,8 @@ SharedHandleVK<vk::Framebuffer> RenderPassVK::CreateVKFramebuffer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void RenderPassVK::SetPipeline(
|
void RenderPassVK::SetPipeline(PipelineRef pipeline) {
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) {
|
pipeline_ = pipeline;
|
||||||
pipeline_ = pipeline.get();
|
|
||||||
if (!pipeline_) {
|
if (!pipeline_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -305,7 +304,7 @@ void RenderPassVK::SetPipeline(
|
|||||||
|
|
||||||
if (pipeline_uses_input_attachments_) {
|
if (pipeline_uses_input_attachments_) {
|
||||||
if (bound_image_offset_ >= kMaxBindings) {
|
if (bound_image_offset_ >= kMaxBindings) {
|
||||||
pipeline_ = nullptr;
|
pipeline_ = PipelineRef(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vk::DescriptorImageInfo image_info;
|
vk::DescriptorImageInfo image_info;
|
||||||
@@ -464,7 +463,7 @@ fml::Status RenderPassVK::Draw() {
|
|||||||
/// Jank can be completely eliminated by pre-populating known YUV conversion
|
/// Jank can be completely eliminated by pre-populating known YUV conversion
|
||||||
/// pipelines.
|
/// pipelines.
|
||||||
if (immutable_sampler_) {
|
if (immutable_sampler_) {
|
||||||
std::shared_ptr<PipelineVK> pipeline_variant =
|
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline_variant =
|
||||||
PipelineVK::Cast(*pipeline_)
|
PipelineVK::Cast(*pipeline_)
|
||||||
.CreateVariantForImmutableSamplers(immutable_sampler_);
|
.CreateVariantForImmutableSamplers(immutable_sampler_);
|
||||||
if (!pipeline_variant) {
|
if (!pipeline_variant) {
|
||||||
@@ -472,7 +471,7 @@ fml::Status RenderPassVK::Draw() {
|
|||||||
fml::StatusCode::kAborted,
|
fml::StatusCode::kAborted,
|
||||||
"Could not create pipeline variant with immutable sampler.");
|
"Could not create pipeline variant with immutable sampler.");
|
||||||
}
|
}
|
||||||
pipeline_ = pipeline_variant.get();
|
pipeline_ = raw_ptr(pipeline_variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& context_vk = ContextVK::Cast(*context_);
|
const auto& context_vk = ContextVK::Cast(*context_);
|
||||||
@@ -539,7 +538,7 @@ fml::Status RenderPassVK::Draw() {
|
|||||||
instance_count_ = 1u;
|
instance_count_ = 1u;
|
||||||
base_vertex_ = 0u;
|
base_vertex_ = 0u;
|
||||||
element_count_ = 0u;
|
element_count_ = 0u;
|
||||||
pipeline_ = nullptr;
|
pipeline_ = PipelineRef(nullptr);
|
||||||
pipeline_uses_input_attachments_ = false;
|
pipeline_uses_input_attachments_ = false;
|
||||||
immutable_sampler_ = nullptr;
|
immutable_sampler_ = nullptr;
|
||||||
return fml::Status();
|
return fml::Status();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class RenderPassVK final : public RenderPass {
|
|||||||
size_t element_count_ = 0u;
|
size_t element_count_ = 0u;
|
||||||
bool has_index_buffer_ = false;
|
bool has_index_buffer_ = false;
|
||||||
bool has_label_ = false;
|
bool has_label_ = false;
|
||||||
const Pipeline<PipelineDescriptor>* pipeline_;
|
PipelineRef pipeline_ = PipelineRef(nullptr);
|
||||||
bool pipeline_uses_input_attachments_ = false;
|
bool pipeline_uses_input_attachments_ = false;
|
||||||
std::shared_ptr<SamplerVK> immutable_sampler_;
|
std::shared_ptr<SamplerVK> immutable_sampler_;
|
||||||
|
|
||||||
@@ -58,8 +58,7 @@ class RenderPassVK final : public RenderPass {
|
|||||||
std::shared_ptr<CommandBufferVK> command_buffer);
|
std::shared_ptr<CommandBufferVK> command_buffer);
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void SetPipeline(
|
void SetPipeline(PipelineRef pipeline) override;
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) override;
|
|
||||||
|
|
||||||
// |RenderPass|
|
// |RenderPass|
|
||||||
void SetCommandLabel(std::string_view label) override;
|
void SetCommandLabel(std::string_view label) override;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ struct Command {
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
/// The pipeline to use for this command.
|
/// The pipeline to use for this command.
|
||||||
///
|
///
|
||||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline;
|
PipelineRef pipeline;
|
||||||
|
|
||||||
/// An offset into render pass storage where bound buffers/texture metadata is
|
/// An offset into render pass storage where bound buffers/texture metadata is
|
||||||
/// stored.
|
/// stored.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
#include "compute_pipeline_descriptor.h"
|
#include "compute_pipeline_descriptor.h"
|
||||||
|
#include "impeller/core/raw_ptr.h"
|
||||||
#include "impeller/renderer/compute_pipeline_builder.h"
|
#include "impeller/renderer/compute_pipeline_builder.h"
|
||||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||||
#include "impeller/renderer/context.h"
|
#include "impeller/renderer/context.h"
|
||||||
@@ -78,6 +79,12 @@ class Pipeline {
|
|||||||
Pipeline& operator=(const Pipeline&) = delete;
|
Pipeline& operator=(const Pipeline&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief A raw ptr to a pipeline object.
|
||||||
|
///
|
||||||
|
/// These pipeline refs are safe to use as the context will keep the
|
||||||
|
/// pipelines alive throughout rendering.
|
||||||
|
using PipelineRef = raw_ptr<Pipeline<PipelineDescriptor>>;
|
||||||
|
|
||||||
extern template class Pipeline<PipelineDescriptor>;
|
extern template class Pipeline<PipelineDescriptor>;
|
||||||
extern template class Pipeline<ComputePipelineDescriptor>;
|
extern template class Pipeline<ComputePipelineDescriptor>;
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,13 @@ const std::shared_ptr<const Context>& RenderPass::GetContext() const {
|
|||||||
return context_;
|
return context_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderPass::SetPipeline(PipelineRef pipeline) {
|
||||||
|
pending_.pipeline = pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderPass::SetPipeline(
|
void RenderPass::SetPipeline(
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) {
|
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline) {
|
||||||
pending_.pipeline = pipeline;
|
SetPipeline(PipelineRef(pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPass::SetCommandLabel(std::string_view label) {
|
void RenderPass::SetCommandLabel(std::string_view label) {
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ class RenderPass : public ResourceBinder {
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
/// The pipeline to use for this command.
|
/// The pipeline to use for this command.
|
||||||
virtual void SetPipeline(
|
virtual void SetPipeline(PipelineRef pipeline);
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
/// The pipeline to use for this command.
|
||||||
|
void SetPipeline(
|
||||||
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline);
|
const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ RenderPass::GetOrCreatePipeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RenderPass::Draw() {
|
bool RenderPass::Draw() {
|
||||||
render_pass_->SetPipeline(GetOrCreatePipeline());
|
render_pass_->SetPipeline(impeller::PipelineRef(GetOrCreatePipeline()));
|
||||||
|
|
||||||
for (const auto& [_, buffer] : vertex_uniform_bindings) {
|
for (const auto& [_, buffer] : vertex_uniform_bindings) {
|
||||||
render_pass_->BindDynamicResource(
|
render_pass_->BindDynamicResource(
|
||||||
|
|||||||
Reference in New Issue
Block a user