5#ifndef FLUTTER_IMPELLER_RENDERER_PIPELINE_H_
6#define FLUTTER_IMPELLER_RENDERER_PIPELINE_H_
25template <
typename PipelineDescriptor_>
31 std::shared_future<std::shared_ptr<Pipeline<T>>>
future;
33 const std::shared_ptr<Pipeline<T>>
Get()
const {
return future.get(); }
70 const std::function<
void(T& desc)>& descriptor_callback)
const;
77 Pipeline(std::weak_ptr<PipelineLibrary> library,
const T& desc);
104 std::optional<PipelineDescriptor> desc,
109 std::optional<ComputePipelineDescriptor> desc);
118 std::optional<PipelineDescriptor> desc,
125 : pipeline_future_(
std::move(future)) {}
135 if (pipeline_future_.IsValid()) {
136 if (
queue !=
nullptr && pipeline_future_.descriptor.has_value()) {
137 queue->PerformJobEagerly(pipeline_future_.descriptor.value());
139 pipeline_ = pipeline_future_.Get();
145 return pipeline_future_.descriptor;
150 std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline_;
151 bool did_wait_ =
false;
165template <
class VertexShader_,
class FragmentShader_>
179 std::optional<PipelineDescriptor> desc,
192template <
class ComputeShader_>
205 std::optional<ComputePipelineDescriptor> compute_desc)
210 : pipeline_future_(
std::move(future)) {}
212 std::shared_ptr<Pipeline<ComputePipelineDescriptor>>
WaitAndGet() {
217 if (pipeline_future_.IsValid()) {
218 pipeline_ = pipeline_future_.Get();
225 std::shared_ptr<Pipeline<ComputePipelineDescriptor>> pipeline_;
226 bool did_wait_ =
false;
ComputePipelineHandle(PipelineFuture< ComputePipelineDescriptor > future)
ComputePipelineBuilder< ComputeShader > Builder
ComputePipelineHandle(const Context &context, std::optional< ComputePipelineDescriptor > compute_desc)
ComputePipelineHandle(const Context &context)
ComputeShader_ ComputeShader
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > WaitAndGet()
To do anything rendering related with Impeller, you need a context.
virtual ~GenericRenderPipelineHandle()=default
GenericRenderPipelineHandle(PipelineFuture< PipelineDescriptor > future)
GenericRenderPipelineHandle(const Context &context, std::optional< PipelineDescriptor > desc, bool async=true)
std::optional< PipelineDescriptor > GetDescriptor() const
std::shared_ptr< Pipeline< PipelineDescriptor > > WaitAndGet(PipelineCompileQueue *queue)
A task queue designed for managing compilation of pipeline state objects.
Describes the fixed function and programmable aspects of rendering and compute operations performed b...
PipelineFuture< T > CreateVariant(bool async, const std::function< void(T &desc)> &descriptor_callback) const
const std::weak_ptr< PipelineLibrary > library_
virtual bool IsValid() const =0
const T & GetDescriptor() const
Get the descriptor that was responsible for creating this pipeline. It may be copied and modified to ...
RenderPipelineHandle(const Context &context, std::optional< PipelineDescriptor > desc, bool async=true)
VertexShader_ VertexShader
RenderPipelineHandle(const Context &context, bool async=true)
RenderPipelineHandle(PipelineFuture< PipelineDescriptor > future)
PipelineBuilder< VertexShader, FragmentShader > Builder
FragmentShader_ FragmentShader
PipelineFuture< PipelineDescriptor > CreatePipelineFuture(const Context &context, std::optional< PipelineDescriptor > desc, bool async)
Create a pipeline for the given descriptor.
std::shared_ptr< ContextGLES > context
An optional (but highly recommended) utility for creating pipelines from reflected shader information...
An optional (but highly recommended) utility for creating pipelines from reflected shader information...
const std::shared_ptr< Pipeline< T > > Get() const
std::shared_future< std::shared_ptr< Pipeline< T > > > future
std::optional< T > descriptor