Give the default render target a stencil buffer.

This commit is contained in:
Chinmay Garde 2021-11-20 13:12:35 -08:00 committed by Dan Field
parent 9f2632abb2
commit 6223a79f95
3 changed files with 30 additions and 0 deletions

View File

@ -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);

View File

@ -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_;

View File

@ -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;
}
};