34 const std::string& label,
36 std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
37 const std::shared_ptr<Texture>& existing_color_texture,
38 const std::shared_ptr<Texture>& existing_depth_stencil_texture) {
43 FML_DCHECK(existing_color_texture ==
nullptr &&
44 existing_depth_stencil_texture ==
nullptr);
47 .mip_count =
static_cast<size_t>(mip_count),
49 .has_depth_stencil = stencil_attachment_config.has_value(),
51 for (
auto& render_target_data : render_target_data_) {
52 const auto other_config = render_target_data.config;
53 if (!render_target_data.used_this_frame && other_config == config) {
54 render_target_data.used_this_frame =
true;
55 auto color0 = render_target_data.render_target.GetColorAttachments()
58 auto depth = render_target_data.render_target.GetDepthAttachment();
59 std::shared_ptr<Texture> depth_tex = depth ? depth->texture :
nullptr;
61 context, size, mip_count, label, color_attachment_config,
62 stencil_attachment_config, color0.texture, depth_tex);
66 context, size, mip_count, label, color_attachment_config,
67 stencil_attachment_config);
68 if (!created_target.
IsValid()) {
69 return created_target;
71 render_target_data_.push_back(
72 RenderTargetData{.used_this_frame =
true,
74 .render_target = created_target});
75 return created_target;
82 const std::string& label,
84 std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config,
85 const std::shared_ptr<Texture>& existing_color_msaa_texture,
86 const std::shared_ptr<Texture>& existing_color_resolve_texture,
87 const std::shared_ptr<Texture>& existing_depth_stencil_texture) {
92 FML_DCHECK(existing_color_msaa_texture ==
nullptr &&
93 existing_color_resolve_texture ==
nullptr &&
94 existing_depth_stencil_texture ==
nullptr);
97 .mip_count =
static_cast<size_t>(mip_count),
99 .has_depth_stencil = stencil_attachment_config.has_value(),
101 for (
auto& render_target_data : render_target_data_) {
102 const auto other_config = render_target_data.config;
103 if (!render_target_data.used_this_frame && other_config == config) {
104 render_target_data.used_this_frame =
true;
105 auto color0 = render_target_data.render_target.GetColorAttachments()
108 auto depth = render_target_data.render_target.GetDepthAttachment();
109 std::shared_ptr<Texture> depth_tex = depth ? depth->texture :
nullptr;
111 context, size, mip_count, label, color_attachment_config,
112 stencil_attachment_config, color0.texture, color0.resolve_texture,
117 context, size, mip_count, label, color_attachment_config,
118 stencil_attachment_config);
119 if (!created_target.
IsValid()) {
120 return created_target;
122 render_target_data_.push_back(
123 RenderTargetData{.used_this_frame =
true,
125 .render_target = created_target});
126 return created_target;
To do anything rendering related with Impeller, you need a context.
virtual RenderTarget CreateOffscreen(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen", RenderTarget::AttachmentConfig color_attachment_config=RenderTarget::kDefaultColorAttachmentConfig, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr)
virtual RenderTarget CreateOffscreenMSAA(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen MSAA", RenderTarget::AttachmentConfigMSAA color_attachment_config=RenderTarget::kDefaultColorAttachmentConfigMSAA, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_msaa_texture=nullptr, const std::shared_ptr< Texture > &existing_color_resolve_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr)
RenderTarget CreateOffscreen(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen", RenderTarget::AttachmentConfig color_attachment_config=RenderTarget::kDefaultColorAttachmentConfig, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr) override
RenderTarget CreateOffscreenMSAA(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen MSAA", RenderTarget::AttachmentConfigMSAA color_attachment_config=RenderTarget::kDefaultColorAttachmentConfigMSAA, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_msaa_texture=nullptr, const std::shared_ptr< Texture > &existing_color_resolve_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr) override