Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean code
  • Loading branch information
ColdPaleLight committed Nov 9, 2022
commit 493d49156d29b61a6121e0774b8d540fb474f12a
2 changes: 1 addition & 1 deletion impeller/entity/contents/runtime_effect_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
options.primitive_type = geometry_result.type;
options.ApplyToPipelineDescriptor(desc);

auto pipeline = context->GetPipelineLibrary()->GetPipeline(desc).future.get();
auto pipeline = context->GetPipelineLibrary()->GetPipeline(desc).Get();
if (!pipeline) {
VALIDATION_LOG << "Failed to get or create runtime effect pipeline.";
return false;
Expand Down
5 changes: 2 additions & 3 deletions impeller/playground/imgui/imgui_impl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ bool ImGui_ImplImpeller_Init(
desc->SetStencilAttachmentDescriptors(stencil.value());
}

bd->pipeline = context->GetPipelineLibrary()
->GetPipeline(std::move(desc))
.future.get();
bd->pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
IM_ASSERT(bd->pipeline != nullptr && "Could not create ImGui pipeline.");

bd->sampler = context->GetSamplerLibrary()->GetSampler({});
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/compute_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TEST_P(ComputeTest, CanCreateComputePass) {
SamplePipelineBuilder::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(pipeline_desc.has_value());
auto compute_pipeline =
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).future.get();
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
ASSERT_TRUE(compute_pipeline);

auto cmd_buffer = context->CreateCommandBuffer();
Expand Down
12 changes: 8 additions & 4 deletions impeller/renderer/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ template <typename T>
struct PipelineFuture {
std::optional<T> descriptor;
std::shared_future<std::shared_ptr<Pipeline<T>>> future;

const std::shared_ptr<Pipeline<T>> Get() const { return future.get(); }

bool IsValid() const { return future.valid(); }
};

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -104,8 +108,8 @@ class RenderPipelineT {
return pipeline_;
}
did_wait_ = true;
if (pipeline_future_.future.valid()) {
pipeline_ = pipeline_future_.future.get();
if (pipeline_future_.IsValid()) {
pipeline_ = pipeline_future_.Get();
}
return pipeline_;
}
Expand Down Expand Up @@ -146,8 +150,8 @@ class ComputePipelineT {
return pipeline_;
}
did_wait_ = true;
if (pipeline_future_.future.valid()) {
pipeline_ = pipeline_future_.future.get();
if (pipeline_future_.IsValid()) {
pipeline_ = pipeline_future_.Get();
}
return pipeline_;
}
Expand Down
31 changes: 14 additions & 17 deletions impeller/renderer/renderer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST_P(RendererTest, CanCreateBoxPrimitive) {
ASSERT_TRUE(desc.has_value());
desc->SetSampleCount(SampleCount::kCount4);
auto box_pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(box_pipeline);

// Vertex buffer.
Expand Down Expand Up @@ -119,7 +119,7 @@ TEST_P(RendererTest, CanRenderPerspectiveCube) {
desc->SetCullMode(CullMode::kBackFace);
desc->SetSampleCount(SampleCount::kCount4);
auto pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(pipeline);

struct Cube {
Expand Down Expand Up @@ -208,7 +208,7 @@ TEST_P(RendererTest, CanRenderMultiplePrimitives) {
ASSERT_TRUE(desc.has_value());
desc->SetSampleCount(SampleCount::kCount4);
auto box_pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(box_pipeline);

// Vertex buffer.
Expand Down Expand Up @@ -279,7 +279,7 @@ TEST_P(RendererTest, CanRenderToTexture) {
BoxPipelineBuilder::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(pipeline_desc.has_value());
auto box_pipeline =
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).future.get();
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).Get();
ASSERT_TRUE(box_pipeline);

VertexBufferBuilder<VS::PerVertexData> vertex_builder;
Expand Down Expand Up @@ -409,7 +409,7 @@ TEST_P(RendererTest, CanRenderInstanced) {
->GetPipeline(PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(
*GetContext())
->SetSampleCount(SampleCount::kCount4))
.future.get();
.Get();
ASSERT_TRUE(pipeline && pipeline->IsValid());

Command cmd;
Expand Down Expand Up @@ -449,7 +449,7 @@ TEST_P(RendererTest, CanBlitTextureToTexture) {
ASSERT_TRUE(desc.has_value());
desc->SetSampleCount(SampleCount::kCount4);
auto mipmaps_pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(mipmaps_pipeline);

TextureDescriptor texture_desc;
Expand Down Expand Up @@ -559,7 +559,7 @@ TEST_P(RendererTest, CanBlitTextureToBuffer) {
ASSERT_TRUE(desc.has_value());
desc->SetSampleCount(SampleCount::kCount4);
auto mipmaps_pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(mipmaps_pipeline);

auto bridge = CreateTextureForFixture("bay_bridge.jpg");
Expand Down Expand Up @@ -690,7 +690,7 @@ TEST_P(RendererTest, CanGenerateMipmaps) {
ASSERT_TRUE(desc.has_value());
desc->SetSampleCount(SampleCount::kCount4);
auto mipmaps_pipeline =
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).future.get();
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
ASSERT_TRUE(mipmaps_pipeline);

auto boston = CreateTextureForFixture("boston.jpg", true);
Expand Down Expand Up @@ -806,9 +806,8 @@ TEST_P(RendererTest, TheImpeller) {
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(pipeline_descriptor.has_value());
pipeline_descriptor->SetSampleCount(SampleCount::kCount4);
auto pipeline = context->GetPipelineLibrary()
->GetPipeline(pipeline_descriptor)
.future.get();
auto pipeline =
context->GetPipelineLibrary()->GetPipeline(pipeline_descriptor).Get();
ASSERT_TRUE(pipeline && pipeline->IsValid());

auto blue_noise = CreateTextureForFixture("blue_noise.png");
Expand Down Expand Up @@ -867,9 +866,8 @@ TEST_P(RendererTest, ArrayUniforms) {
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(pipeline_descriptor.has_value());
pipeline_descriptor->SetSampleCount(SampleCount::kCount4);
auto pipeline = context->GetPipelineLibrary()
->GetPipeline(pipeline_descriptor)
.future.get();
auto pipeline =
context->GetPipelineLibrary()->GetPipeline(pipeline_descriptor).Get();
ASSERT_TRUE(pipeline && pipeline->IsValid());

SinglePassCallback callback = [&](RenderPass& pass) {
Expand Down Expand Up @@ -924,9 +922,8 @@ TEST_P(RendererTest, InactiveUniforms) {
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(pipeline_descriptor.has_value());
pipeline_descriptor->SetSampleCount(SampleCount::kCount4);
auto pipeline = context->GetPipelineLibrary()
->GetPipeline(pipeline_descriptor)
.future.get();
auto pipeline =
context->GetPipelineLibrary()->GetPipeline(pipeline_descriptor).Get();
ASSERT_TRUE(pipeline && pipeline->IsValid());

SinglePassCallback callback = [&](RenderPass& pass) {
Expand Down
3 changes: 1 addition & 2 deletions impeller/runtime_stage/runtime_stage_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ TEST_P(RuntimeStageTest, CanCreatePipelineFromRuntimeStage) {
desc.SetColorAttachmentDescriptor(0u, color0);
desc.SetStencilAttachmentDescriptors(stencil0);
desc.SetStencilPixelFormat(PixelFormat::kDefaultStencil);
auto pipeline =
GetContext()->GetPipelineLibrary()->GetPipeline(desc).future.get();
auto pipeline = GetContext()->GetPipelineLibrary()->GetPipeline(desc).Get();
ASSERT_NE(pipeline, nullptr);
}

Expand Down