38 return render_pass_->GetContext();
42 return render_target_;
46 return render_target_;
50 size_t color_attachment_index) {
51 auto color = color_descriptors_.find(color_attachment_index);
52 if (color == color_descriptors_.end()) {
53 return color_descriptors_[color_attachment_index] = {};
65 return stencil_front_desc_;
70 return stencil_back_desc_;
74 return pipeline_descriptor_;
79 command_buffer.GetCommandBuffer()->CreateRenderPass(render_target_);
90 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)) {
166 std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>>>
168 auto pipeline_future = pipeline_promise.get_future();
170 dart_state->GetTaskRunners().GetRasterTaskRunner(),
173 promise.set_value(
context->GetPipelineLibrary()
174 ->GetPipeline(pipeline_desc,
true,
true)
179 pipeline =
context.GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
187 size_t instance_count,
189 if (element_count == 0u || instance_count == 0u) {
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()),
216 render_pass_->BindDynamicResource(
219 std::make_unique<impeller::ShaderMetadata>(*
buffer.view.GetMetadata()),
223 render_pass_->BindDynamicResource(
226 std::make_unique<impeller::ShaderMetadata>(
227 *
texture.texture.GetMetadata()),
238 render_pass_->SetElementCount(element_count);
239 render_pass_->SetInstanceCount(instance_count);
244 render_pass_->SetViewport(
viewport.value());
248 render_pass_->SetScissor(
scissor.value());
251 bool result = render_pass_->Draw().ok();
264 auto res = fml::MakeRefCounted<flutter::gpu::RenderPass>();
265 res->AssociateWithDartWrapper(wrapper);
271 int color_attachment_index,
279 Dart_Handle resolve_texture_wrapper,
286 clear_color_b, clear_color_a);
290 if (!Dart_IsNull(resolve_texture_wrapper)) {
293 resolve_texture_wrapper);
310 int depth_load_action,
311 int depth_store_action,
312 float depth_clear_value,
313 int stencil_load_action,
314 int stencil_store_action,
315 int stencil_clear_value,
362 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
366 if (slot < 0 ||
static_cast<size_t>(slot) >=
384 length_in_bytes, slot);
389 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
405 length_in_bytes, index_type);
411 Dart_Handle uniform_name_handle,
412 const std::shared_ptr<const impeller::DeviceBuffer>& buffer,
414 int length_in_bytes) {
420 if (!uniform_struct) {
437 if (!buffer ||
static_cast<size_t>(offset_in_bytes + length_in_bytes) >
438 buffer->GetDeviceBufferDescriptor().size) {
442 uniform_map->insert_or_assign(
457 Dart_Handle uniform_name_handle,
460 int length_in_bytes) {
461 return BindUniform(wrapper, shader, uniform_name_handle,
462 device_buffer->
GetBuffer(), offset_in_bytes,
469 Dart_Handle uniform_name_handle,
474 int width_address_mode,
475 int height_address_mode,
476 int max_anisotropy) {
482 if (!texture_binding) {
497 static_cast<uint8_t
>(std::clamp(max_anisotropy, 1, 255));
499 wrapper->
GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc);
513 uniform_map->insert_or_assign(
530 int color_attachment_index,
538 int color_attachment_index,
539 int color_blend_operation,
540 int source_color_blend_factor,
541 int destination_color_blend_factor,
542 int alpha_blend_operation,
543 int source_alpha_blend_factor,
544 int destination_alpha_blend_factor) {
548 color.src_color_blend_factor =
550 color.dst_color_blend_factor =
552 color.alpha_blend_op =
554 color.src_alpha_blend_factor =
556 color.dst_alpha_blend_factor =
569 int compare_operation) {
577 int stencil_reference) {
600 depth_range.z_near = z_near;
601 depth_range.z_far = z_far;
604 viewport.rect = rect;
605 viewport.depth_range = depth_range;
612 int stencil_compare_operation,
613 int stencil_fail_operation,
614 int depth_fail_operation,
615 int depth_stencil_pass_operation,
628 desc.
read_mask =
static_cast<uint32_t
>(read_mask);
629 desc.
write_mask =
static_cast<uint32_t
>(write_mask);
632 if (target_face != 2 ) {
635 if (target_face != 1 ) {
650 int primitive_type) {
677 int instance_count) {
679 return vertex_count >= 0 && instance_count >= 0 &&
680 wrapper->
Draw(vertex_count, instance_count,
false);
686 int instance_count) {
688 return index_count >= 0 && instance_count >= 0 &&
689 wrapper->
Draw(index_count, instance_count,
true);
static UIDartState * Current()
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)
bool Draw(size_t element_count, size_t instance_count, bool indexed)
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)
virtual fml::Status Draw()
Record the currently pending command.
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)
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)
void InternalFlutterGpu_RenderPass_ClearBindings(flutter::gpu::RenderPass *wrapper)
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, int mip_level, int slice)
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)
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, int mip_level, int slice)
void InternalFlutterGpu_RenderPass_SetStencilReference(flutter::gpu::RenderPass *wrapper, int stencil_reference)
void InternalFlutterGpu_RenderPass_BindVertexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int slot)
Dart_Handle InternalFlutterGpu_RenderPass_Begin(flutter::gpu::RenderPass *wrapper, flutter::gpu::CommandBuffer *command_buffer)
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, int max_anisotropy)
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)
bool InternalFlutterGpu_RenderPass_DrawIndexed(flutter::gpu::RenderPass *wrapper, int index_count, int instance_count)
bool InternalFlutterGpu_RenderPass_Draw(flutter::gpu::RenderPass *wrapper, int vertex_count, int instance_count)
void InternalFlutterGpu_RenderPass_SetDepthWriteEnable(flutter::gpu::RenderPass *wrapper, bool enable)
static void BindVertexBuffer(flutter::gpu::RenderPass *wrapper, const std::shared_ptr< const impeller::DeviceBuffer > &buffer, int offset_in_bytes, int length_in_bytes, int slot)
void InternalFlutterGpu_RenderPass_SetViewport(flutter::gpu::RenderPass *wrapper, int x, int y, int width, int height, float z_near, float z_far)
void InternalFlutterGpu_RenderPass_BindIndexBufferDevice(flutter::gpu::RenderPass *wrapper, flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int length_in_bytes, int index_type)
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)
std::shared_ptr< ContextGLES > context
std::shared_ptr< PipelineGLES > pipeline
std::shared_ptr< CommandBuffer > command_buffer
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.