Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a8d3369

Browse files
committed
[Impeller] Add depth settings to pipeline variant hash.
1 parent df6b15d commit a8d3369

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

impeller/entity/contents/clip_contents.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ bool ClipContents::Render(const ContentContext& renderer,
8383
auto options = OptionsFromPass(pass);
8484
options.blend_mode = BlendMode::kDestination;
8585
pass.SetStencilReference(entity.GetClipDepth());
86-
options.stencil_compare = CompareFunction::kEqual;
87-
options.stencil_operation = StencilOperation::kIncrementClamp;
8886

8987
if (clip_op_ == Entity::ClipOperation::kDifference) {
9088
{

impeller/entity/contents/content_context.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ void ContentContextOptions::ApplyToPipelineDescriptor(
141141
desc.ClearStencilAttachments();
142142
}
143143

144+
auto maybe_depth = desc.GetDepthStencilAttachmentDescriptor();
145+
if (maybe_depth.has_value()) {
146+
DepthAttachmentDescriptor depth = maybe_depth.value();
147+
depth.depth_write_enabled = depth_write_enabled;
148+
depth.depth_compare = depth_compare;
149+
desc.SetDepthStencilAttachmentDescriptor(depth);
150+
}
151+
144152
auto maybe_stencil = desc.GetFrontStencilAttachmentDescriptor();
145153
if (maybe_stencil.has_value()) {
146154
StencilAttachmentDescriptor stencil = maybe_stencil.value();

impeller/entity/contents/content_context.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,13 @@ using TiledTextureExternalPipeline =
281281
struct ContentContextOptions {
282282
SampleCount sample_count = SampleCount::kCount1;
283283
BlendMode blend_mode = BlendMode::kSourceOver;
284+
CompareFunction depth_compare = CompareFunction::kGreater;
284285
CompareFunction stencil_compare = CompareFunction::kEqual;
285286
StencilOperation stencil_operation = StencilOperation::kKeep;
286287
PrimitiveType primitive_type = PrimitiveType::kTriangle;
287288
PixelFormat color_attachment_pixel_format = PixelFormat::kUnknown;
288289
bool has_depth_stencil_attachments = true;
290+
bool depth_write_enabled = false;
289291
bool wireframe = false;
290292
bool is_for_rrect_blur_clear = false;
291293

@@ -294,6 +296,7 @@ struct ContentContextOptions {
294296
static_assert(sizeof(o.sample_count) == 1);
295297
static_assert(sizeof(o.blend_mode) == 1);
296298
static_assert(sizeof(o.sample_count) == 1);
299+
static_assert(sizeof(o.depth_compare) == 1);
297300
static_assert(sizeof(o.stencil_compare) == 1);
298301
static_assert(sizeof(o.stencil_operation) == 1);
299302
static_assert(sizeof(o.primitive_type) == 1);
@@ -302,11 +305,13 @@ struct ContentContextOptions {
302305
return (o.is_for_rrect_blur_clear ? 1llu : 0llu) << 0 |
303306
(o.wireframe ? 1llu : 0llu) << 1 |
304307
(o.has_depth_stencil_attachments ? 1llu : 0llu) << 2 |
308+
(o.depth_write_enabled ? 1llu : 0llu) << 3 |
305309
// enums
306-
static_cast<uint64_t>(o.color_attachment_pixel_format) << 16 |
307-
static_cast<uint64_t>(o.primitive_type) << 24 |
308-
static_cast<uint64_t>(o.stencil_operation) << 32 |
309-
static_cast<uint64_t>(o.stencil_compare) << 40 |
310+
static_cast<uint64_t>(o.color_attachment_pixel_format) << 8 |
311+
static_cast<uint64_t>(o.primitive_type) << 16 |
312+
static_cast<uint64_t>(o.stencil_operation) << 24 |
313+
static_cast<uint64_t>(o.stencil_compare) << 32 |
314+
static_cast<uint64_t>(o.depth_compare) << 40 |
310315
static_cast<uint64_t>(o.blend_mode) << 48 |
311316
static_cast<uint64_t>(o.sample_count) << 56;
312317
}
@@ -317,6 +322,8 @@ struct ContentContextOptions {
317322
const ContentContextOptions& rhs) const {
318323
return lhs.sample_count == rhs.sample_count &&
319324
lhs.blend_mode == rhs.blend_mode &&
325+
lhs.depth_write_enabled == rhs.depth_write_enabled &&
326+
lhs.depth_compare == rhs.depth_compare &&
320327
lhs.stencil_compare == rhs.stencil_compare &&
321328
lhs.stencil_operation == rhs.stencil_operation &&
322329
lhs.primitive_type == rhs.primitive_type &&
@@ -822,6 +829,10 @@ class ContentContext {
822829
VALIDATION_LOG << "Failed to create default pipeline.";
823830
return;
824831
}
832+
PixelFormat depth_stencil_format =
833+
context.GetCapabilities()->GetDefaultDepthStencilFormat();
834+
desc->SetDepthPixelFormat(depth_stencil_format);
835+
desc->SetStencilPixelFormat(depth_stencil_format);
825836
desc->SetUseSubpassInput(subpass_input);
826837
options.ApplyToPipelineDescriptor(*desc);
827838
SetDefault(options, std::make_unique<PipelineT>(context, desc));

0 commit comments

Comments
 (0)