37 return render_pass_->GetContext();
41 return render_target_;
45 return render_target_;
49 size_t color_attachment_index) {
50 auto color = color_descriptors_.find(color_attachment_index);
51 if (color == color_descriptors_.end()) {
52 return color_descriptors_[color_attachment_index] = {};
64 return stencil_front_desc_;
69 return stencil_back_desc_;
73 return pipeline_descriptor_;
89 render_pipeline_ = std::move(pipeline);
106std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>
107RenderPass::GetOrCreatePipeline() {
109 auto pipeline_desc = pipeline_descriptor_;
120 pipeline_desc.SetColorAttachmentDescriptors(color_descriptors_);
125 stencil->texture->GetTextureDescriptor().format)) {
126 pipeline_desc.SetStencilPixelFormat(
127 stencil->texture->GetTextureDescriptor().format);
128 pipeline_desc.SetStencilAttachmentDescriptors(stencil_front_desc_,
131 pipeline_desc.ClearStencilAttachments();
138 depth->texture->GetTextureDescriptor().format)) {
139 pipeline_desc.SetDepthPixelFormat(
140 depth->texture->GetTextureDescriptor().format);
141 pipeline_desc.SetDepthStencilAttachmentDescriptor(depth_desc_);
143 pipeline_desc.ClearDepthAttachment();
149 render_pipeline_->BindToPipelineDescriptor(*context.GetShaderLibrary(),
152 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>> pipeline;
155 !context.GetPipelineLibrary()->HasPipeline(pipeline_desc)) {
165 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>>
167 auto pipeline_future = pipeline_promise.get_future();
169 dart_state->GetTaskRunners().GetRasterTaskRunner(),
171 context =
GetContext(), pipeline_desc]()
mutable {
172 promise.set_value(context->GetPipelineLibrary()
173 ->GetPipeline(pipeline_desc,
true,
true)
176 pipeline = pipeline_future.get();
178 pipeline = context.GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
181 FML_DCHECK(pipeline) <<
"Couldn't resolve render pipeline";
189 render_pass_->BindDynamicResource(
192 std::make_unique<impeller::ShaderMetadata>(*
buffer.view.GetMetadata()),
196 render_pass_->BindDynamicResource(
199 std::make_unique<impeller::ShaderMetadata>(
200 *
texture.texture.GetMetadata()),
204 render_pass_->BindDynamicResource(
207 std::make_unique<impeller::ShaderMetadata>(*
buffer.view.GetMetadata()),
211 render_pass_->BindDynamicResource(
214 std::make_unique<impeller::ShaderMetadata>(
215 *
texture.texture.GetMetadata()),
226 render_pass_->SetViewport(
viewport.value());
230 render_pass_->SetScissor(
scissor.value());
233 bool result = render_pass_->Draw().ok();
246 auto res = fml::MakeRefCounted<flutter::gpu::RenderPass>();
247 res->AssociateWithDartWrapper(wrapper);
253 int color_attachment_index,
261 Dart_Handle resolve_texture_wrapper) {
266 clear_color_b, clear_color_a);
268 if (!Dart_IsNull(resolve_texture_wrapper)) {
271 resolve_texture_wrapper);
288 int depth_load_action,
289 int depth_store_action,
290 float depth_clear_value,
291 int stencil_load_action,
292 int stencil_store_action,
293 int stencil_clear_value,
319 if (!wrapper->
Begin(*command_buffer)) {
334 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
339 if (slot < 0 ||
static_cast<size_t>(slot) >=
373 length_in_bytes, vertex_count, slot);
378 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
389 if (setting_index_buffer) {
403 length_in_bytes, index_type, index_count);
409 Dart_Handle uniform_name_handle,
410 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
412 int length_in_bytes) {
418 if (!uniform_struct) {
435 if (!buffer ||
static_cast<size_t>(offset_in_bytes + length_in_bytes) >
436 buffer->GetDeviceBufferDescriptor().size) {
440 uniform_map->insert_or_assign(
455 Dart_Handle uniform_name_handle,
458 int length_in_bytes) {
459 return BindUniform(wrapper, shader, uniform_name_handle,
460 device_buffer->
GetBuffer(), offset_in_bytes,
467 Dart_Handle uniform_name_handle,
472 int width_address_mode,
473 int height_address_mode) {
479 if (!texture_binding) {
492 wrapper->
GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc);
506 uniform_map->insert_or_assign(
523 int color_attachment_index,
531 int color_attachment_index,
532 int color_blend_operation,
533 int source_color_blend_factor,
534 int destination_color_blend_factor,
535 int alpha_blend_operation,
536 int source_alpha_blend_factor,
537 int destination_alpha_blend_factor) {
541 color.src_color_blend_factor =
543 color.dst_color_blend_factor =
545 color.alpha_blend_op =
547 color.src_alpha_blend_factor =
549 color.dst_alpha_blend_factor =
562 int compare_operation) {
570 int stencil_reference) {
593 depth_range.z_near = z_near;
594 depth_range.z_far = z_far;
597 viewport.rect = rect;
598 viewport.depth_range = depth_range;
605 int stencil_compare_operation,
606 int stencil_fail_operation,
607 int depth_fail_operation,
608 int depth_stencil_pass_operation,
621 desc.
read_mask =
static_cast<uint32_t
>(read_mask);
622 desc.
write_mask =
static_cast<uint32_t
>(write_mask);
625 if (target_face != 2 ) {
628 if (target_face != 1 ) {
643 int primitive_type) {
669 return wrapper->
Draw();
static UIDartState * Current()
std::shared_ptr< impeller::CommandBuffer > GetCommandBuffer()
void AddRenderPass(std::shared_ptr< impeller::RenderPass > render_pass)
impeller::Context & GetContext()
std::shared_ptr< impeller::DeviceBuffer > GetBuffer()
uint32_t stencil_reference
std::optional< impeller::Viewport > viewport
impeller::StencilAttachmentDescriptor & GetStencilBackAttachmentDescriptor()
void SetPipeline(fml::RefPtr< RenderPipeline > pipeline)
impeller::RenderTarget & GetRenderTarget()
bool Begin(flutter::gpu::CommandBuffer &command_buffer)
std::unordered_map< const flutter::gpu::Shader::UniformBinding *, BufferAndUniformSlot > BufferUniformMap
static constexpr size_t kMaxVertexBufferSlots
impeller::DepthAttachmentDescriptor & GetDepthAttachmentDescriptor()
std::unordered_map< const flutter::gpu::Shader::TextureBinding *, impeller::TextureAndSampler > TextureUniformMap
size_t vertex_buffer_count
std::optional< impeller::IRect32 > scissor
TextureUniformMap fragment_texture_bindings
BufferUniformMap fragment_uniform_bindings
TextureUniformMap vertex_texture_bindings
BufferUniformMap vertex_uniform_bindings
impeller::IndexType index_buffer_type
std::array< impeller::BufferView, kMaxVertexBufferSlots > vertex_buffers
impeller::StencilAttachmentDescriptor & GetStencilFrontAttachmentDescriptor()
impeller::ColorAttachmentDescriptor & GetColorAttachmentDescriptor(size_t color_attachment_index)
impeller::PipelineDescriptor & GetPipelineDescriptor()
const std::shared_ptr< const impeller::Context > & GetContext() const
impeller::BufferView index_buffer
An immutable collection of shaders loaded from a shader bundle asset.
const Shader::UniformBinding * GetUniformStruct(const std::string &name) const
impeller::ShaderStage GetShaderStage() const
const Shader::TextureBinding * GetUniformTexture(const std::string &name) const
std::shared_ptr< impeller::Texture > GetTexture()
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
void SetCullMode(CullMode mode)
void SetPolygonMode(PolygonMode mode)
PipelineDescriptor & SetSampleCount(SampleCount samples)
void SetPrimitiveType(PrimitiveType type)
void SetWindingOrder(WindingOrder order)
SampleCount GetSampleCount() const
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
RenderTarget & SetDepthAttachment(std::optional< DepthAttachment > attachment)
PixelFormat GetRenderTargetPixelFormat() const
RenderTarget & SetStencilAttachment(std::optional< StencilAttachment > attachment)
bool IterateAllColorAttachments(const std::function< bool(size_t index, const ColorAttachment &attachment)> &iterator) const
const std::optional< DepthAttachment > & GetDepthAttachment() const
const std::optional< StencilAttachment > & GetStencilAttachment() const
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
#define FML_DCHECK(condition)
void InternalFlutterGpu_RenderPass_BindPipeline(flutter::gpu::RenderPass *wrapper, flutter::gpu::RenderPipeline *pipeline)
static bool BindUniform(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, const std::shared_ptr< const impeller::DeviceBuffer > &buffer, int offset_in_bytes, int length_in_bytes)
void InternalFlutterGpu_RenderPass_BindVertexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int vertex_count, int slot)
void InternalFlutterGpu_RenderPass_ClearBindings(flutter::gpu::RenderPass *wrapper)
static void BindIndexBuffer(flutter::gpu::RenderPass *wrapper, const std::shared_ptr< const impeller::DeviceBuffer > &buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
void InternalFlutterGpu_RenderPass_SetStencilConfig(flutter::gpu::RenderPass *wrapper, int stencil_compare_operation, int stencil_fail_operation, int depth_fail_operation, int depth_stencil_pass_operation, int read_mask, int write_mask, int target_face)
void InternalFlutterGpu_RenderPass_SetPrimitiveType(flutter::gpu::RenderPass *wrapper, int primitive_type)
void InternalFlutterGpu_RenderPass_SetColorBlendEquation(flutter::gpu::RenderPass *wrapper, int color_attachment_index, int color_blend_operation, int source_color_blend_factor, int destination_color_blend_factor, int alpha_blend_operation, int source_alpha_blend_factor, int destination_alpha_blend_factor)
void InternalFlutterGpu_RenderPass_BindIndexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int index_type, int index_count)
void InternalFlutterGpu_RenderPass_SetStencilReference(flutter::gpu::RenderPass *wrapper, int stencil_reference)
bool InternalFlutterGpu_RenderPass_BindTexture(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, flutter::gpu::Texture *texture, int min_filter, int mag_filter, int mip_filter, int width_address_mode, int height_address_mode)
Dart_Handle InternalFlutterGpu_RenderPass_Begin(flutter::gpu::RenderPass *wrapper, flutter::gpu::CommandBuffer *command_buffer)
static void BindVertexBuffer(flutter::gpu::RenderPass *wrapper, const std::shared_ptr< const impeller::DeviceBuffer > &buffer, int offset_in_bytes, int length_in_bytes, int vertex_count, int slot)
void InternalFlutterGpu_RenderPass_SetDepthCompareOperation(flutter::gpu::RenderPass *wrapper, int compare_operation)
void InternalFlutterGpu_RenderPass_SetCullMode(flutter::gpu::RenderPass *wrapper, int cull_mode)
void InternalFlutterGpu_RenderPass_SetPolygonMode(flutter::gpu::RenderPass *wrapper, int polygon_mode)
bool InternalFlutterGpu_RenderPass_BindUniformDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::Shader *shader, Dart_Handle uniform_name_handle, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes)
void InternalFlutterGpu_RenderPass_SetWindingOrder(flutter::gpu::RenderPass *wrapper, int winding_order)
void InternalFlutterGpu_RenderPass_SetScissor(flutter::gpu::RenderPass *wrapper, int x, int y, int width, int height)
void InternalFlutterGpu_RenderPass_SetColorBlendEnable(flutter::gpu::RenderPass *wrapper, int color_attachment_index, bool enable)
void InternalFlutterGpu_RenderPass_Initialize(Dart_Handle wrapper)
void InternalFlutterGpu_RenderPass_SetDepthWriteEnable(flutter::gpu::RenderPass *wrapper, bool enable)
Dart_Handle InternalFlutterGpu_RenderPass_SetDepthStencilAttachment(flutter::gpu::RenderPass *wrapper, int depth_load_action, int depth_store_action, float depth_clear_value, int stencil_load_action, int stencil_store_action, int stencil_clear_value, flutter::gpu::Texture *texture)
bool InternalFlutterGpu_RenderPass_Draw(flutter::gpu::RenderPass *wrapper)
Dart_Handle InternalFlutterGpu_RenderPass_SetColorAttachment(flutter::gpu::RenderPass *wrapper, flutter::gpu::Context *context, int color_attachment_index, int load_action, int store_action, float clear_color_r, float clear_color_g, float clear_color_b, float clear_color_a, flutter::gpu::Texture *texture, Dart_Handle resolve_texture_wrapper)
void InternalFlutterGpu_RenderPass_SetViewport(flutter::gpu::RenderPass *wrapper, int x, int y, int width, int height, float z_near, float z_far)
constexpr impeller::BlendFactor ToImpellerBlendFactor(FlutterGPUBlendFactor value)
bool SupportsNormalOffscreenMSAA(const impeller::Context &context)
constexpr impeller::BlendOperation ToImpellerBlendOperation(FlutterGPUBlendOperation value)
constexpr impeller::SamplerAddressMode ToImpellerSamplerAddressMode(FlutterGPUSamplerAddressMode value)
constexpr impeller::MipFilter ToImpellerMipFilter(FlutterGPUMipFilter value)
constexpr impeller::WindingOrder ToImpellerWindingOrder(FlutterGPUWindingOrder value)
constexpr impeller::CompareFunction ToImpellerCompareFunction(FlutterGPUCompareFunction value)
constexpr impeller::LoadAction ToImpellerLoadAction(FlutterGPULoadAction value)
constexpr impeller::StoreAction ToImpellerStoreAction(FlutterGPUStoreAction value)
constexpr impeller::PolygonMode ToImpellerPolygonMode(FlutterGPUPolygonMode value)
constexpr impeller::IndexType ToImpellerIndexType(FlutterGPUIndexType value)
constexpr impeller::StencilOperation ToImpellerStencilOperation(FlutterGPUStencilOperation value)
constexpr impeller::PrimitiveType ToImpellerPrimitiveType(FlutterGPUPrimitiveType value)
constexpr impeller::CullMode ToImpellerCullMode(FlutterGPUCullMode value)
constexpr impeller::MinMagFilter ToImpellerMinMagFilter(FlutterGPUMinMagFilter value)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
internal::CopyableLambda< T > MakeCopyable(T lambda)
@ kNone
Does not use the index buffer.
constexpr bool IsDepthWritable(PixelFormat format)
constexpr bool IsStencilWritable(PixelFormat format)
Dart_Handle ToDart(const T &object)
std::string StdStringFromDart(Dart_Handle handle)
impeller::ShaderType type
impeller::SampledImageSlot slot
impeller::ShaderMetadata metadata
std::shared_ptr< Texture > resolve_texture
std::shared_ptr< Texture > texture
Describe the color attachment that will be used with this pipeline.
BlendOperation color_blend_op
CompareFunction depth_compare
SamplerAddressMode width_address_mode
SamplerAddressMode height_address_mode
StencilOperation stencil_failure
CompareFunction stencil_compare
StencilOperation depth_failure
StencilOperation depth_stencil_pass
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
combines the texture, sampler and sampler slot information.