diff --git a/impeller/playground/playground.mm b/impeller/playground/playground.mm index dad34f622e110..8459efc16376a 100644 --- a/impeller/playground/playground.mm +++ b/impeller/playground/playground.mm @@ -157,8 +157,26 @@ static void PlaygroundKeyCallback(GLFWwindow* window, color0.load_action = LoadAction::kClear; color0.store_action = StoreAction::kStore; + TextureDescriptor stencil_texture_descriptor; + stencil_texture_descriptor.format = PixelFormat::kD32FloatS8UNormInt; + stencil_texture_descriptor.size = color0_desc.size; + stencil_texture_descriptor.usage = + static_cast(TextureUsage::kShaderRead) | + static_cast(TextureUsage::kShaderWrite); + auto stencil_texture = + renderer_.GetContext()->GetPermanentsAllocator()->CreateTexture( + StorageMode::kDeviceTransient, stencil_texture_descriptor); + stencil_texture->SetLabel("PlaygroundMainStencil"); + + StencilAttachment stencil0; + stencil0.texture = stencil_texture; + stencil0.clear_stencil = 0; + stencil0.load_action = LoadAction::kClear; + stencil0.store_action = StoreAction::kStore; + RenderTarget desc; desc.SetColorAttachment(color0, 0u); + desc.SetStencilAttachment(stencil0); Surface surface(desc); diff --git a/impeller/renderer/pipeline.h b/impeller/renderer/pipeline.h index 4a6521e02ff94..c0601cb41f13c 100644 --- a/impeller/renderer/pipeline.h +++ b/impeller/renderer/pipeline.h @@ -68,6 +68,10 @@ class PipelineT { context, Builder::MakeDefaultPipelineDescriptor(context))) {} + explicit PipelineT(const Context& context, + std::optional desc) + : pipeline_future_(CreatePipelineFuture(context, desc)) {} + std::shared_ptr WaitAndGet() { if (did_wait_) { return pipeline_; diff --git a/impeller/renderer/pipeline_builder.h b/impeller/renderer/pipeline_builder.h index 89a7833995ebe..38d721660d6d3 100644 --- a/impeller/renderer/pipeline_builder.h +++ b/impeller/renderer/pipeline_builder.h @@ -104,6 +104,14 @@ struct PipelineBuilder { desc.SetColorAttachmentDescriptor(0u, std::move(color0)); } + // Setup default stencil buffer descriptions. + { + StencilAttachmentDescriptor stencil0; + stencil0.depth_stencil_pass = StencilOperation::kIncrementClamp; + desc.SetStencilAttachmentDescriptors(stencil0); + desc.SetStencilPixelFormat(PixelFormat::kD32FloatS8UNormInt); + } + return true; } };