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

Commit 59469d2

Browse files
committed
[Impeller] Add depth settings to pipeline variant hash.
1 parent 6a5fb8f commit 59469d2

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
@@ -140,6 +140,14 @@ void ContentContextOptions::ApplyToPipelineDescriptor(
140140
desc.ClearStencilAttachments();
141141
}
142142

143+
auto maybe_depth = desc.GetDepthStencilAttachmentDescriptor();
144+
if (maybe_depth.has_value()) {
145+
DepthAttachmentDescriptor depth = maybe_depth.value();
146+
depth.depth_write_enabled = depth_write_enabled;
147+
depth.depth_compare = depth_compare;
148+
desc.SetDepthStencilAttachmentDescriptor(depth);
149+
}
150+
143151
auto maybe_stencil = desc.GetFrontStencilAttachmentDescriptor();
144152
if (maybe_stencil.has_value()) {
145153
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,10 +281,12 @@ 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;
289+
bool depth_write_enabled = false;
288290
bool has_stencil_attachment = true;
289291
bool wireframe = false;
290292
bool is_for_rrect_blur_clear = false;
@@ -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_stencil_attachment ? 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 &&
@@ -821,6 +828,10 @@ class ContentContext {
821828
VALIDATION_LOG << "Failed to create default pipeline.";
822829
return;
823830
}
831+
PixelFormat depth_stencil_format =
832+
context.GetCapabilities()->GetDefaultDepthStencilFormat();
833+
desc->SetDepthPixelFormat(depth_stencil_format);
834+
desc->SetStencilPixelFormat(depth_stencil_format);
824835
desc->SetUseSubpassInput(subpass_input);
825836
options.ApplyToPipelineDescriptor(*desc);
826837
SetDefault(options, std::make_unique<PipelineT>(context, desc));

0 commit comments

Comments
 (0)