Update impeller-cmake to ToT
diff --git a/src/examples/mesh/mesh_example.cc b/src/examples/mesh/mesh_example.cc
index 90e3228..26d2055 100644
--- a/src/examples/mesh/mesh_example.cc
+++ b/src/examples/mesh/mesh_example.cc
@@ -15,6 +15,7 @@
#include "impeller/core/buffer_view.h"
#include "impeller/core/device_buffer_descriptor.h"
#include "impeller/core/formats.h"
+#include "impeller/core/host_buffer.h"
#include "impeller/core/vertex_buffer.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/scalar.h"
@@ -43,6 +44,9 @@
}
bool MeshExample::Setup(impeller::Context& context) {
+ transients_buffer_ =
+ impeller::HostBuffer::Create(context.GetResourceAllocator());
+
//----------------------------------------------------------------------------
/// Load/unpack the model.
///
@@ -67,14 +71,9 @@
fb::GetMesh(data.data())->UnPackTo(&mesh);
//----------------------------------------------------------------------------
- /// Create sampler and load textures.
+ /// Load textures.
///
- impeller::SamplerDescriptor sampler_desc;
- sampler_desc.min_filter = impeller::MinMagFilter::kLinear;
- sampler_desc.mag_filter = impeller::MinMagFilter::kLinear;
- sampler_ = context.GetSamplerLibrary()->GetSampler(sampler_desc);
-
const auto asset_path = std::filesystem::current_path() / "assets/";
base_color_texture_ =
@@ -168,6 +167,7 @@
const impeller::RenderTarget& render_target,
impeller::CommandBuffer& command_buffer) {
clock_.Tick();
+ transients_buffer_->Reset();
static float exposure = 5;
ImGui::SliderFloat("Exposure", &exposure, 0, 15);
@@ -177,11 +177,10 @@
return false;
}
- impeller::Command cmd;
- DEBUG_COMMAND_INFO(cmd, "Mesh Example");
- cmd.pipeline = pipeline_;
+ pass->SetCommandLabel("Mesh Example");
+ pass->SetPipeline(pipeline_);
- cmd.BindVertices(vertex_buffer_);
+ pass->SetVertexBuffer(vertex_buffer_);
auto time = clock_.GetTime();
@@ -197,19 +196,23 @@
impeller::Matrix::MakeRotationX(
impeller::Radians{std::cos(time * 0.27f) / 4});
- VS::BindVertInfo(cmd, pass->GetTransientsBuffer().EmplaceUniform(vs_uniform));
+ VS::BindVertInfo(*pass, transients_buffer_->EmplaceUniform(vs_uniform));
FS::FragInfo fs_uniform;
fs_uniform.exposure = exposure;
fs_uniform.camera_position = {0, 0, -50};
- FS::BindFragInfo(cmd, pass->GetTransientsBuffer().EmplaceUniform(fs_uniform));
+ FS::BindFragInfo(*pass, transients_buffer_->EmplaceUniform(fs_uniform));
- FS::BindBaseColorTexture(cmd, base_color_texture_, sampler_);
- FS::BindNormalTexture(cmd, normal_texture_, sampler_);
+ impeller::SamplerDescriptor sampler_desc;
+ sampler_desc.min_filter = impeller::MinMagFilter::kLinear;
+ sampler_desc.mag_filter = impeller::MinMagFilter::kLinear;
+ const auto& sampler = context.GetSamplerLibrary()->GetSampler(sampler_desc);
+ FS::BindBaseColorTexture(*pass, base_color_texture_, sampler);
+ FS::BindNormalTexture(*pass, normal_texture_, sampler);
FS::BindOcclusionRoughnessMetallicTexture(
- cmd, occlusion_roughness_metallic_texture_, sampler_);
+ *pass, occlusion_roughness_metallic_texture_, sampler);
- if (!pass->AddCommand(std::move(cmd))) {
+ if (!pass->Draw().ok()) {
return false;
}
diff --git a/src/examples/mesh/mesh_example.h b/src/examples/mesh/mesh_example.h
index 0b019b3..b48be8a 100644
--- a/src/examples/mesh/mesh_example.h
+++ b/src/examples/mesh/mesh_example.h
@@ -34,11 +34,11 @@
private:
example::Clock clock_;
+ std::shared_ptr<impeller::HostBuffer> transients_buffer_;
+
std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>> pipeline_;
impeller::VertexBuffer vertex_buffer_;
- std::shared_ptr<const impeller::Sampler> sampler_;
-
std::shared_ptr<impeller::Texture> base_color_texture_;
std::shared_ptr<impeller::Texture> normal_texture_;
std::shared_ptr<impeller::Texture> occlusion_roughness_metallic_texture_;
diff --git a/src/examples/the_impeller/the_impeller_example.cc b/src/examples/the_impeller/the_impeller_example.cc
index b56cb2f..c9e6f3c 100644
--- a/src/examples/the_impeller/the_impeller_example.cc
+++ b/src/examples/the_impeller/the_impeller_example.cc
@@ -7,11 +7,13 @@
#include <filesystem>
#include <iostream>
+#include "impeller/core/host_buffer.h"
#include "impeller/renderer/command.h"
#include "impeller/renderer/pipeline_library.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/render_target.h"
#include "impeller/renderer/sampler_library.h"
+#include "impeller/renderer/vertex_buffer_builder.h"
#include "examples/assets.h"
@@ -30,6 +32,9 @@
}
bool TheImpellerExample::Setup(impeller::Context& context) {
+ transients_buffer_ =
+ impeller::HostBuffer::Create(context.GetResourceAllocator());
+
const auto fixture_path =
std::filesystem::current_path() /
"third_party/impeller-cmake/third_party/flutter/impeller/fixtures/";
@@ -43,12 +48,6 @@
std::cerr << "Failed to load blue noise texture." << std::endl;
return false;
}
- impeller::SamplerDescriptor noise_sampler_desc;
- noise_sampler_desc.width_address_mode = impeller::SamplerAddressMode::kRepeat;
- noise_sampler_desc.height_address_mode =
- impeller::SamplerAddressMode::kRepeat;
- blue_noise_sampler_ =
- context.GetSamplerLibrary()->GetSampler(noise_sampler_desc);
cube_map_texture_ =
example::LoadTextureCube({fixture_path / "table_mountain_px.png",
@@ -58,7 +57,6 @@
fixture_path / "table_mountain_pz.png",
fixture_path / "table_mountain_nz.png"},
*context.GetResourceAllocator());
- cube_map_sampler_ = context.GetSamplerLibrary()->GetSampler({});
auto pipeline_desc =
impeller::PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(context);
@@ -76,15 +74,15 @@
const impeller::RenderTarget& render_target,
impeller::CommandBuffer& command_buffer) {
clock_.Tick();
+ transients_buffer_->Reset();
auto pass = command_buffer.CreateRenderPass(render_target);
if (!pass) {
return false;
}
- impeller::Command cmd;
- DEBUG_COMMAND_INFO(cmd, "Impeller SDF showcase");
- cmd.pipeline = pipeline_;
+ pass->SetCommandLabel("Impeller SDF showcase");
+ pass->SetPipeline(pipeline_);
auto size = render_target.GetRenderTargetSize();
@@ -95,21 +93,28 @@
{impeller::Point(size.width, 0)},
{impeller::Point(0, size.height)},
{impeller::Point(size.width, size.height)}});
- cmd.BindVertices(builder.CreateVertexBuffer(pass->GetTransientsBuffer()));
+ pass->SetVertexBuffer(builder.CreateVertexBuffer(*transients_buffer_));
VS::FrameInfo vs_uniform;
vs_uniform.mvp = impeller::Matrix::MakeOrthographic(size);
- VS::BindFrameInfo(cmd,
- pass->GetTransientsBuffer().EmplaceUniform((vs_uniform)));
+ VS::BindFrameInfo(*pass, transients_buffer_->EmplaceUniform((vs_uniform)));
FS::FragInfo fs_uniform;
fs_uniform.texture_size = impeller::Point(size);
fs_uniform.time = clock_.GetTime();
- FS::BindFragInfo(cmd, pass->GetTransientsBuffer().EmplaceUniform(fs_uniform));
- FS::BindBlueNoise(cmd, blue_noise_texture_, blue_noise_sampler_);
- FS::BindCubeMap(cmd, cube_map_texture_, cube_map_sampler_);
+ FS::BindFragInfo(*pass, transients_buffer_->EmplaceUniform(fs_uniform));
- if (!pass->AddCommand(std::move(cmd))) {
+ impeller::SamplerDescriptor noise_sampler_desc;
+ noise_sampler_desc.width_address_mode = impeller::SamplerAddressMode::kRepeat;
+ noise_sampler_desc.height_address_mode =
+ impeller::SamplerAddressMode::kRepeat;
+ FS::BindBlueNoise(
+ *pass, blue_noise_texture_,
+ context.GetSamplerLibrary()->GetSampler(noise_sampler_desc));
+ FS::BindCubeMap(*pass, cube_map_texture_,
+ context.GetSamplerLibrary()->GetSampler({}));
+
+ if (!pass->Draw().ok()) {
return false;
}
diff --git a/src/examples/the_impeller/the_impeller_example.h b/src/examples/the_impeller/the_impeller_example.h
index 5f9a414..48701c0 100644
--- a/src/examples/the_impeller/the_impeller_example.h
+++ b/src/examples/the_impeller/the_impeller_example.h
@@ -7,6 +7,7 @@
#include <memory>
#include "examples/clock.h"
+#include "impeller/core/host_buffer.h"
#include "impeller/core/sampler.h"
#include "impeller/core/texture.h"
#include "impeller/renderer/pipeline.h"
@@ -33,11 +34,11 @@
private:
example::Clock clock_;
+ std::shared_ptr<impeller::HostBuffer> transients_buffer_;
+
std::shared_ptr<impeller::Texture> blue_noise_texture_;
- std::shared_ptr<const impeller::Sampler> blue_noise_sampler_;
std::shared_ptr<impeller::Texture> cube_map_texture_;
- std::shared_ptr<const impeller::Sampler> cube_map_sampler_;
std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>> pipeline_;
};
diff --git a/src/main_gles.cc b/src/main_gles.cc
index 5b077d1..adb810a 100644
--- a/src/main_gles.cc
+++ b/src/main_gles.cc
@@ -198,7 +198,7 @@
ImGui::SetNextWindowPos({10, 10});
impeller::Renderer::RenderCallback render_callback =
- [&renderer, &examples,
+ [&context, &renderer, &examples,
&example_names](impeller::RenderTarget& render_target) -> bool {
static int selected_example_index = 1;
auto example = examples[selected_example_index].get();
@@ -286,7 +286,10 @@
}
}
- return buffer->SubmitCommands();
+ // TODO(bdero): GetComandQueue shouldn't be private...
+ std::shared_ptr<impeller::Context>(context)->GetCommandQueue()->Submit(
+ {buffer});
+ return true;
};
renderer->Render(std::move(surface), render_callback);
diff --git a/third_party/impeller-cmake b/third_party/impeller-cmake
index ffb5582..6f08855 160000
--- a/third_party/impeller-cmake
+++ b/third_party/impeller-cmake
@@ -1 +1 @@
-Subproject commit ffb558292d7e50f8e4bbc65efdd6f37760d8c9a8
+Subproject commit 6f08855647ade0f84ec86e8b149708e02810544f