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);
103std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>
104RenderPass::GetOrCreatePipeline() {
106 auto pipeline_desc = pipeline_descriptor_;
117 pipeline_desc.SetColorAttachmentDescriptors(color_descriptors_);
122 stencil->texture->GetTextureDescriptor().format)) {
123 pipeline_desc.SetStencilPixelFormat(
124 stencil->texture->GetTextureDescriptor().format);
125 pipeline_desc.SetStencilAttachmentDescriptors(stencil_front_desc_,
128 pipeline_desc.ClearStencilAttachments();
135 depth->texture->GetTextureDescriptor().format)) {
136 pipeline_desc.SetDepthPixelFormat(
137 depth->texture->GetTextureDescriptor().format);
138 pipeline_desc.SetDepthStencilAttachmentDescriptor(depth_desc_);
140 pipeline_desc.ClearDepthAttachment();
146 render_pipeline_->BindToPipelineDescriptor(*context.GetShaderLibrary(),
149 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>> pipeline;
152 !context.GetPipelineLibrary()->HasPipeline(pipeline_desc)) {
162 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>>
164 auto pipeline_future = pipeline_promise.get_future();
166 dart_state->GetTaskRunners().GetRasterTaskRunner(),
168 context =
GetContext(), pipeline_desc]()
mutable {
169 promise.set_value(context->GetPipelineLibrary()
170 ->GetPipeline(pipeline_desc,
true,
true)
173 pipeline = pipeline_future.get();
175 pipeline = context.GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
178 FML_DCHECK(pipeline) <<
"Couldn't resolve render pipeline";
186 render_pass_->BindDynamicResource(
189 std::make_unique<impeller::ShaderMetadata>(*
buffer.view.GetMetadata()),
193 render_pass_->BindDynamicResource(
196 std::make_unique<impeller::ShaderMetadata>(
197 *
texture.texture.GetMetadata()),
201 render_pass_->BindDynamicResource(
204 std::make_unique<impeller::ShaderMetadata>(*
buffer.view.GetMetadata()),
208 render_pass_->BindDynamicResource(
211 std::make_unique<impeller::ShaderMetadata>(
212 *
texture.texture.GetMetadata()),
223 render_pass_->SetViewport(
viewport.value());
227 render_pass_->SetScissor(
scissor.value());
230 bool result = render_pass_->Draw().ok();
243 auto res = fml::MakeRefCounted<flutter::gpu::RenderPass>();
244 res->AssociateWithDartWrapper(wrapper);
250 int color_attachment_index,
258 Dart_Handle resolve_texture_wrapper) {
263 clear_color_b, clear_color_a);
265 if (!Dart_IsNull(resolve_texture_wrapper)) {
268 resolve_texture_wrapper);
285 int depth_load_action,
286 int depth_store_action,
287 float depth_clear_value,
288 int stencil_load_action,
289 int stencil_store_action,
290 int stencil_clear_value,
316 if (!wrapper->
Begin(*command_buffer)) {
331 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
358 length_in_bytes, vertex_count);
363 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
374 if (setting_index_buffer) {
388 length_in_bytes, index_type, index_count);
394 Dart_Handle uniform_name_handle,
395 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
397 int length_in_bytes) {
403 if (!uniform_struct) {
420 if (!buffer ||
static_cast<size_t>(offset_in_bytes + length_in_bytes) >
421 buffer->GetDeviceBufferDescriptor().size) {
425 uniform_map->insert_or_assign(
440 Dart_Handle uniform_name_handle,
443 int length_in_bytes) {
444 return BindUniform(wrapper, shader, uniform_name_handle,
445 device_buffer->
GetBuffer(), offset_in_bytes,
452 Dart_Handle uniform_name_handle,
457 int width_address_mode,
458 int height_address_mode) {
464 if (!texture_binding) {
477 wrapper->
GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc);
491 uniform_map->insert_or_assign(
508 int color_attachment_index,
516 int color_attachment_index,
517 int color_blend_operation,
518 int source_color_blend_factor,
519 int destination_color_blend_factor,
520 int alpha_blend_operation,
521 int source_alpha_blend_factor,
522 int destination_alpha_blend_factor) {
526 color.src_color_blend_factor =
528 color.dst_color_blend_factor =
530 color.alpha_blend_op =
532 color.src_alpha_blend_factor =
534 color.dst_alpha_blend_factor =
547 int compare_operation) {
555 int stencil_reference) {
578 depth_range.z_near = z_near;
579 depth_range.z_far = z_far;
582 viewport.rect = rect;
583 viewport.depth_range = depth_range;
590 int stencil_compare_operation,
591 int stencil_fail_operation,
592 int depth_fail_operation,
593 int depth_stencil_pass_operation,
606 desc.
read_mask =
static_cast<uint32_t
>(read_mask);
607 desc.
write_mask =
static_cast<uint32_t
>(write_mask);
610 if (target_face != 2 ) {
613 if (target_face != 1 ) {
628 int primitive_type) {
654 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
impeller::BufferView vertex_buffer
impeller::DepthAttachmentDescriptor & GetDepthAttachmentDescriptor()
std::unordered_map< const flutter::gpu::Shader::TextureBinding *, impeller::TextureAndSampler > TextureUniformMap
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
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_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_BindVertexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int vertex_count)
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)
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)
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)
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::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.