Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
7 changes: 6 additions & 1 deletion impeller/aiks/color_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
#include "impeller/entity/contents/linear_gradient_contents.h"
#include "impeller/entity/contents/radial_gradient_contents.h"
#include "impeller/entity/contents/runtime_effect_contents.h"
#include "impeller/entity/contents/scene_contents.h"
#include "impeller/entity/contents/solid_color_contents.h"
#include "impeller/entity/contents/sweep_gradient_contents.h"
#include "impeller/entity/contents/tiled_texture_contents.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/scalar.h"
#include "impeller/runtime_stage/runtime_stage.h"

#if IMPELLER_ENABLE_3D
#include "impeller/entity/contents/scene_contents.h"
#include "impeller/scene/node.h"
#endif // IMPELLER_ENABLE_3D

namespace impeller {

Expand Down Expand Up @@ -210,6 +213,7 @@ ColorSource ColorSource::MakeRuntimeEffect(
return result;
}

#if IMPELLER_ENABLE_3D
ColorSource ColorSource::MakeScene(std::shared_ptr<scene::Node> scene_node,
Matrix camera_transform) {
ColorSource result;
Expand All @@ -224,6 +228,7 @@ ColorSource ColorSource::MakeScene(std::shared_ptr<scene::Node> scene_node,
};
return result;
}
#endif // IMPELLER_ENABLE_3D

ColorSource::Type ColorSource::GetType() const {
return type_;
Expand Down
5 changes: 5 additions & 0 deletions impeller/aiks/color_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/point.h"
#include "impeller/runtime_stage/runtime_stage.h"

#if IMPELLER_ENABLE_3D
#include "impeller/scene/node.h"
#endif // IMPELLER_ENABLE_3D

namespace impeller {

Expand Down Expand Up @@ -85,8 +88,10 @@ class ColorSource {
std::shared_ptr<std::vector<uint8_t>> uniform_data,
std::vector<RuntimeEffectContents::TextureInput> texture_inputs);

#if IMPELLER_ENABLE_3D
static ColorSource MakeScene(std::shared_ptr<scene::Node> scene_node,
Matrix camera_transform);
#endif // IMPELLER_ENABLE_3D

Type GetType() const;

Expand Down
5 changes: 4 additions & 1 deletion impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "impeller/entity/contents/linear_gradient_contents.h"
#include "impeller/entity/contents/radial_gradient_contents.h"
#include "impeller/entity/contents/runtime_effect_contents.h"
#include "impeller/entity/contents/scene_contents.h"
#include "impeller/entity/contents/sweep_gradient_contents.h"
#include "impeller/entity/contents/tiled_texture_contents.h"
#include "impeller/entity/entity.h"
Expand All @@ -37,6 +36,10 @@
#include "impeller/geometry/sigma.h"
#include "impeller/typographer/backends/skia/text_frame_skia.h"

#if IMPELLER_ENABLE_3D
#include "impeller/entity/contents/scene_contents.h"
#endif // IMPELLER_ENABLE_3D

namespace impeller {

#define UNIMPLEMENTED \
Expand Down
11 changes: 8 additions & 3 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ impeller_component("entity") {
"contents/radial_gradient_contents.h",
"contents/runtime_effect_contents.cc",
"contents/runtime_effect_contents.h",
"contents/scene_contents.cc",
"contents/scene_contents.h",
"contents/solid_color_contents.cc",
"contents/solid_color_contents.h",
"contents/solid_rrect_blur_contents.cc",
Expand Down Expand Up @@ -261,10 +259,17 @@ impeller_component("entity") {
"../archivist",
"../image:image_skia_backend",
"../renderer",
"../scene",
"../typographer",
]

if (impeller_enable_3d) {
sources += [
"contents/scene_contents.cc",
"contents/scene_contents.h",
]
public_deps += [ "../scene" ]
}

deps = [ "//flutter/fml" ]
}

Expand Down
4 changes: 4 additions & 0 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ ContentContext::ContentContext(
lazy_glyph_atlas_(
std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
tessellator_(std::make_shared<Tessellator>()),
#if IMPELLER_ENABLE_3D
scene_context_(std::make_shared<scene::SceneContext>(context_)),
#endif // IMPELLER_ENABLE_3D
render_target_cache_(std::make_shared<RenderTargetCache>(
context_->GetResourceAllocator())) {
if (!context_ || !context_->IsValid()) {
Expand Down Expand Up @@ -413,9 +415,11 @@ std::shared_ptr<Texture> ContentContext::MakeSubpass(
return subpass_texture;
}

#if IMPELLER_ENABLE_3D
std::shared_ptr<scene::SceneContext> ContentContext::GetSceneContext() const {
return scene_context_;
}
#endif // IMPELLER_ENABLE_3D

std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
return tessellator_;
Expand Down
4 changes: 4 additions & 0 deletions impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ class ContentContext {

bool IsValid() const;

#if IMPELLER_ENABLE_3D
std::shared_ptr<scene::SceneContext> GetSceneContext() const;
#endif // IMPELLER_ENABLE_3D

std::shared_ptr<Tessellator> GetTessellator() const;

Expand Down Expand Up @@ -873,7 +875,9 @@ class ContentContext {

bool is_valid_ = false;
std::shared_ptr<Tessellator> tessellator_;
#if IMPELLER_ENABLE_3D
std::shared_ptr<scene::SceneContext> scene_context_;
#endif // IMPELLER_ENABLE_3D
std::shared_ptr<RenderTargetAllocator> render_target_cache_;
bool wireframe_ = false;

Expand Down
7 changes: 6 additions & 1 deletion impeller/renderer/backend/vulkan/render_pass_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ SharedHandleVK<vk::Framebuffer> RenderPassVK::CreateVKFramebuffer(
auto [result, framebuffer] =
context.GetDevice().createFramebufferUnique(fb_info);

FML_LOG(ERROR) << "create framebuffer result is " << vk::to_string(result)
<< " "; // << framebuffer.get();
if (result != vk::Result::eSuccess) {
VALIDATION_LOG << "Could not create framebuffer: " << vk::to_string(result);
return {};
Expand Down Expand Up @@ -636,12 +638,15 @@ bool RenderPassVK::OnEncodeCommands(const Context& context) const {

vk::RenderPassBeginInfo pass_info;
pass_info.renderPass = *render_pass;
pass_info.framebuffer = *framebuffer;
FML_LOG(ERROR) << target_size;
pass_info.renderArea.extent.width = static_cast<uint32_t>(target_size.width);
pass_info.renderArea.extent.height =
static_cast<uint32_t>(target_size.height);
pass_info.setClearValues(clear_values);

VkRenderPassBeginInfo my_info = pass_info;
FML_LOG(ERROR) << "my_info is " << my_info.sType << " " << my_info.renderPass
<< " " << my_info.framebuffer;
{
TRACE_EVENT0("impeller", "EncodeRenderPassCommands");
cmd_buffer.beginRenderPass(pass_info, vk::SubpassContents::eInline);
Expand Down
15 changes: 9 additions & 6 deletions shell/platform/android/android_context_gl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include "flutter/impeller/toolkit/egl/context.h"
#include "flutter/impeller/toolkit/egl/surface.h"
#include "impeller/entity/gles/entity_shaders_gles.h"
#include "impeller/scene/shaders/gles/scene_shaders_gles.h"

#if IMPELLER_ENABLE_3D
#include "impeller/scene/shaders/gles/scene_shaders_gles.h"
#endif // IMPELLER_ENABLE_3D
namespace flutter {

class AndroidContextGLImpeller::ReactorWorker final
Expand Down Expand Up @@ -56,11 +58,12 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
}

std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(
impeller_entity_shaders_gles_data,
impeller_entity_shaders_gles_length),
std::make_shared<fml::NonOwnedMapping>(
impeller_scene_shaders_gles_data, impeller_scene_shaders_gles_length),
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_gles_data,
impeller_entity_shaders_gles_length),
#if IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_gles_data,
impeller_scene_shaders_gles_length),
#endif // IMPELLER_ENABLE_3D
};

auto context =
Expand Down
17 changes: 11 additions & 6 deletions shell/platform/android/android_context_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@
#include "flutter/impeller/entity/vk/entity_shaders_vk.h"
#include "flutter/impeller/entity/vk/modern_shaders_vk.h"
#include "flutter/impeller/renderer/backend/vulkan/context_vk.h"

#if IMPELLER_ENABLE_3D
#include "flutter/impeller/scene/shaders/vk/scene_shaders_vk.h"
#endif // IMPELLER_ENABLE_3D

namespace flutter {

static std::shared_ptr<impeller::Context> CreateImpellerContext(
const fml::RefPtr<vulkan::VulkanProcTable>& proc_table,
bool enable_vulkan_validation) {
std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_vk_data,
impeller_entity_shaders_vk_length),
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_vk_data,
impeller_scene_shaders_vk_length),
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_vk_data,
impeller_modern_shaders_vk_length),
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_vk_data,
impeller_entity_shaders_vk_length),
#if IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_vk_data,
impeller_scene_shaders_vk_length),
#endif
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_vk_data,
impeller_modern_shaders_vk_length),
};

PFN_vkGetInstanceProcAddr instance_proc_addr =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@
#include "impeller/entity/mtl/entity_shaders.h"
#include "impeller/entity/mtl/framebuffer_blend_shaders.h"
#include "impeller/entity/mtl/modern_shaders.h"

#if IMPELLER_ENABLE_3D
#include "impeller/scene/shaders/mtl/scene_shaders.h"
#endif // IMPELLER_ENABLE_3D

FLUTTER_ASSERT_ARC

static std::shared_ptr<impeller::ContextMTL> CreateImpellerContext(
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch) {
std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
impeller_entity_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
impeller_scene_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
impeller_modern_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
impeller_framebuffer_blend_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
impeller_entity_shaders_length),
#if IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
impeller_scene_shaders_length),
#endif // IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
impeller_modern_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
impeller_framebuffer_blend_shaders_length),
};
auto context = impeller::ContextMTL::Create(
shader_mappings, std::move(is_gpu_disabled_sync_switch), "Impeller Library");
Expand Down
14 changes: 9 additions & 5 deletions shell/platform/embedder/embedder_surface_gl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#include "impeller/entity/gles/entity_shaders_gles.h"
#include "impeller/renderer/backend/gles/context_gles.h"
#include "impeller/renderer/backend/gles/proc_table_gles.h"

#if IMPELLER_ENABLE_3D
#include "impeller/scene/shaders/gles/scene_shaders_gles.h"
#endif // IMPELLER_ENABLE_3D

namespace flutter {

Expand Down Expand Up @@ -62,11 +65,12 @@ EmbedderSurfaceGLImpeller::EmbedderSurfaceGLImpeller(
gl_dispatch_table_.gl_make_current_callback();

std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(
impeller_entity_shaders_gles_data,
impeller_entity_shaders_gles_length),
std::make_shared<fml::NonOwnedMapping>(
impeller_scene_shaders_gles_data, impeller_scene_shaders_gles_length),
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_gles_data,
impeller_entity_shaders_gles_length),
#if IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_gles_data,
impeller_scene_shaders_gles_length),
#endif // IMPELLER_ENABLE_3D
};
auto gl = std::make_unique<impeller::ProcTableGLES>(
gl_dispatch_table_.gl_proc_resolver);
Expand Down
21 changes: 13 additions & 8 deletions shell/platform/embedder/embedder_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#include "impeller/entity/mtl/framebuffer_blend_shaders.h"
#include "impeller/entity/mtl/modern_shaders.h"
#include "impeller/renderer/backend/metal/context_mtl.h"

#if IMPELLER_ENABLE_3D
#include "impeller/scene/shaders/mtl/scene_shaders.h"
#endif // IMPELLER_ENABLE_3D

FLUTTER_ASSERT_NOT_ARC

Expand All @@ -31,14 +34,16 @@
metal_dispatch_table_(std::move(metal_dispatch_table)),
external_view_embedder_(std::move(external_view_embedder)) {
std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
impeller_entity_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
impeller_scene_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
impeller_modern_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
impeller_framebuffer_blend_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
impeller_entity_shaders_length),
#if IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
impeller_scene_shaders_length),
#endif // IMPELLER_ENABLE_3D
std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
impeller_modern_shaders_length),
std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
impeller_framebuffer_blend_shaders_length),
};
context_ = impeller::ContextMTL::Create(
(id<MTLDevice>)device, // device
Expand Down