18#include "impeller/scene/importer/scene_flatbuffers.h"
19#include "impeller/scene/shaders/skinned.vert.h"
20#include "impeller/scene/shaders/unskinned.vert.h"
32 auto result = std::make_shared<CuboidGeometry>();
40 auto result = std::make_shared<SkinnedVertexBufferGeometry>();
41 result->SetVertexBuffer(std::move(vertex_buffer));
44 auto result = std::make_shared<UnskinnedVertexBufferGeometry>();
45 result->SetVertexBuffer(std::move(vertex_buffer));
51 const fb::MeshPrimitive&
mesh,
54 switch (
mesh.indices()->type()) {
55 case fb::IndexType::k16Bit:
58 case fb::IndexType::k32Bit:
63 const uint8_t* vertices_start;
64 size_t vertices_bytes;
67 switch (
mesh.vertices_type()) {
68 case fb::VertexBuffer::UnskinnedVertexBuffer: {
69 const auto* vertices =
70 mesh.vertices_as_UnskinnedVertexBuffer()->vertices();
71 vertices_start =
reinterpret_cast<const uint8_t*
>(vertices->Get(0));
72 vertices_bytes = vertices->size() *
sizeof(
fb::Vertex);
76 case fb::VertexBuffer::SkinnedVertexBuffer: {
77 const auto* vertices =
mesh.vertices_as_SkinnedVertexBuffer()->vertices();
78 vertices_start =
reinterpret_cast<const uint8_t*
>(vertices->Get(0));
79 vertices_bytes = vertices->size() *
sizeof(fb::SkinnedVertex);
83 case fb::VertexBuffer::NONE:
88 const uint8_t* indices_start =
89 reinterpret_cast<const uint8_t*
>(
mesh.indices()->data()->Data());
91 const size_t indices_bytes =
mesh.indices()->data()->size();
92 if (vertices_bytes == 0 || indices_bytes == 0) {
97 buffer_desc.
size = vertices_bytes + indices_bytes;
101 buffer->SetLabel(
"Mesh vertices+indices");
103 if (!
buffer->CopyHostBuffer(vertices_start,
Range(0, vertices_bytes))) {
106 if (!
buffer->CopyHostBuffer(indices_start,
Range(0, indices_bytes),
113 .index_buffer = {.buffer =
buffer,
114 .range =
Range(vertices_bytes, indices_bytes)},
115 .vertex_count =
mesh.indices()->count(),
116 .index_type = index_type,
146 {
Vector3(0, 0, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(0, 0),
148 {
Vector3(1, 0, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(1, 0),
150 {
Vector3(1, 1, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(1, 1),
152 {
Vector3(1, 1, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(1, 1),
154 {
Vector3(0, 1, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(0, 1),
156 {
Vector3(0, 0, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Point(0, 0),
159 return builder.CreateVertexBuffer(allocator);
170 UnskinnedVertexShader::FrameInfo
info;
172 UnskinnedVertexShader::BindFrameInfo(pass,
buffer.EmplaceUniform(
info));
185 vertex_buffer_ = std::move(vertex_buffer);
196 return vertex_buffer_;
208 UnskinnedVertexShader::FrameInfo
info;
210 UnskinnedVertexShader::BindFrameInfo(pass,
buffer.EmplaceUniform(
info));
222 vertex_buffer_ = std::move(vertex_buffer);
233 return vertex_buffer_;
250 sampler_desc.
label =
"NN Repeat";
252 SkinnedVertexShader::BindJointsTexture(
255 scene_context.
GetContext()->GetSamplerLibrary()->GetSampler(
258 SkinnedVertexShader::FrameInfo
info;
260 info.enable_skinning = joints_texture_ ? 1 : 0;
261 info.joint_texture_size =
262 joints_texture_ ? joints_texture_->GetSize().width : 1;
263 SkinnedVertexShader::BindFrameInfo(pass,
buffer.EmplaceUniform(
info));
268 const std::shared_ptr<Texture>&
texture) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
GrTriangulator::Vertex Vertex
An object that allocates device memory.
std::shared_ptr< DeviceBuffer > CreateBuffer(const DeviceBufferDescriptor &desc)
Render passes encode render commands directed as one specific render target into an underlying comman...
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
GeometryType GetGeometryType() const override
void SetSize(Vector3 size)
~CuboidGeometry() override
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
static std::shared_ptr< Geometry > MakeFromFlatbuffer(const fb::MeshPrimitive &mesh, Allocator &allocator)
static std::shared_ptr< Geometry > MakeVertexBuffer(VertexBuffer vertex_buffer, bool is_skinned)
virtual void SetJointsTexture(const std::shared_ptr< Texture > &texture)
static std::shared_ptr< CuboidGeometry > MakeCuboid(Vector3 size)
std::shared_ptr< Context > GetContext() const
std::shared_ptr< Texture > GetPlaceholderTexture() const
~SkinnedVertexBufferGeometry() override
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
SkinnedVertexBufferGeometry()
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
void SetJointsTexture(const std::shared_ptr< Texture > &texture) override
GeometryType GetGeometryType() const override
void SetVertexBuffer(VertexBuffer vertex_buffer)
void SetVertexBuffer(VertexBuffer vertex_buffer)
GeometryType GetGeometryType() const override
UnskinnedVertexBufferGeometry()
~UnskinnedVertexBufferGeometry() override
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
@ kNearest
The nearst mipmap level is selected.
@ kNearest
Select nearest to the sample point. Most widely supported.
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
std::shared_ptr< const DeviceBuffer > buffer
static constexpr Color White()
A 4x4 matrix using column-major storage.
SamplerAddressMode width_address_mode