mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Give the default render target a stencil buffer.
This commit is contained in:
parent
9f2632abb2
commit
6223a79f95
@ -157,8 +157,26 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
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<TextureUsageMask>(TextureUsage::kShaderRead) |
|
||||
static_cast<TextureUsageMask>(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);
|
||||
|
||||
|
||||
@ -68,6 +68,10 @@ class PipelineT {
|
||||
context,
|
||||
Builder::MakeDefaultPipelineDescriptor(context))) {}
|
||||
|
||||
explicit PipelineT(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc)
|
||||
: pipeline_future_(CreatePipelineFuture(context, desc)) {}
|
||||
|
||||
std::shared_ptr<Pipeline> WaitAndGet() {
|
||||
if (did_wait_) {
|
||||
return pipeline_;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user