Add support for typed pipeline futures.
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
#include <string>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/compositor/pipeline_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ShaderLibrary;
|
||||
class SamplerLibrary;
|
||||
class CommandBuffer;
|
||||
class PipelineLibrary;
|
||||
class Allocator;
|
||||
|
||||
class Context {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "flutter/fml/paths.h"
|
||||
#include "impeller/compositor/allocator.h"
|
||||
#include "impeller/compositor/command_buffer.h"
|
||||
#include "impeller/compositor/pipeline_library.h"
|
||||
#include "impeller/compositor/sampler_descriptor.h"
|
||||
#include "impeller/compositor/shader_library.h"
|
||||
|
||||
|
||||
@@ -4,13 +4,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include <future>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/compositor/context.h"
|
||||
#include "impeller/compositor/pipeline_builder.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PipelineLibrary;
|
||||
class Pipeline;
|
||||
|
||||
using PipelineFuture = std::future<std::shared_ptr<Pipeline>>;
|
||||
|
||||
class Pipeline {
|
||||
public:
|
||||
@@ -41,4 +48,27 @@ class Pipeline {
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Pipeline);
|
||||
};
|
||||
|
||||
PipelineFuture CreatePipelineFuture(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc);
|
||||
|
||||
template <class VertexShader_, class FragmentShader_>
|
||||
class PipelineT {
|
||||
public:
|
||||
using VertexShader = VertexShader_;
|
||||
using FragmentShader = FragmentShader_;
|
||||
using Builder = PipelineBuilder<VertexShader, FragmentShader>;
|
||||
|
||||
explicit PipelineT(const Context& context)
|
||||
: pipeline_future_(CreatePipelineFuture(
|
||||
context,
|
||||
Builder::MakeDefaultPipelineDescriptor(context))) {}
|
||||
|
||||
const Pipeline* WaitAndGet() { return pipeline_future_.get().get(); }
|
||||
|
||||
private:
|
||||
PipelineFuture pipeline_future_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineT);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "impeller/compositor/pipeline.h"
|
||||
|
||||
#include "impeller/compositor/context.h"
|
||||
#include "impeller/compositor/pipeline_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Pipeline::Pipeline(id<MTLRenderPipelineState> state,
|
||||
@@ -30,4 +33,16 @@ id<MTLDepthStencilState> Pipeline::GetMTLDepthStencilState() const {
|
||||
return depth_stencil_state_;
|
||||
}
|
||||
|
||||
PipelineFuture CreatePipelineFuture(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc) {
|
||||
if (!context.IsValid()) {
|
||||
std::promise<std::shared_ptr<Pipeline>> promise;
|
||||
auto future = promise.get_future();
|
||||
promise.set_value(nullptr);
|
||||
return future;
|
||||
}
|
||||
|
||||
return context.GetPipelineLibrary()->GetRenderPipeline(std::move(desc));
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -22,11 +21,10 @@ class PipelineLibrary : public std::enable_shared_from_this<PipelineLibrary> {
|
||||
public:
|
||||
~PipelineLibrary();
|
||||
|
||||
std::future<std::shared_ptr<Pipeline>> GetRenderPipeline(
|
||||
PipelineFuture GetRenderPipeline(
|
||||
std::optional<PipelineDescriptor> descriptor);
|
||||
|
||||
std::future<std::shared_ptr<Pipeline>> GetRenderPipeline(
|
||||
PipelineDescriptor descriptor);
|
||||
PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor);
|
||||
|
||||
private:
|
||||
friend Context;
|
||||
|
||||
@@ -69,6 +69,10 @@ bool Entity::HasRenderableContents() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsClip()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HasStroke()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,16 @@
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/compositor/context.h"
|
||||
#include "impeller/compositor/pipeline.h"
|
||||
#include "impeller/compositor/pipeline_builder.h"
|
||||
#include "impeller/compositor/render_pass.h"
|
||||
#include "impeller/compositor/surface.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/path.vert.h"
|
||||
#include "impeller/entity/solid_fill.frag.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class Entity;
|
||||
|
||||
// TODO(csg): Only present to hide Objective-C++ interface in the headers. Once
|
||||
// the backend is separated into its own TU, this can be merged with
|
||||
// EntityRenderer.
|
||||
@@ -31,7 +34,12 @@ class EntityRendererImpl {
|
||||
const Entity& entities);
|
||||
|
||||
private:
|
||||
using SolidFillPipeline =
|
||||
PipelineT<PathVertexShader, SolidFillFragmentShader>;
|
||||
|
||||
std::shared_ptr<Context> context_;
|
||||
std::unique_ptr<SolidFillPipeline> solid_fill_pipeline_;
|
||||
|
||||
bool is_valid_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EntityRendererImpl);
|
||||
|
||||
@@ -11,6 +11,9 @@ EntityRendererImpl::EntityRendererImpl(std::shared_ptr<Context> context)
|
||||
if (!context_ || !context_->IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
solid_fill_pipeline_ = std::make_unique<SolidFillPipeline>(*context);
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user