From 907354c2cdcf3cdc48cc41e729584226024f69ad Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Mon, 10 Jul 2023 15:30:21 -0700 Subject: [PATCH] Interface changes for asymmetric stencil specification --- impeller/core/formats.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/impeller/core/formats.h b/impeller/core/formats.h index ff031d96008b1..fca356c2c1357 100644 --- a/impeller/core/formats.h +++ b/impeller/core/formats.h @@ -526,7 +526,7 @@ struct DepthAttachmentDescriptor { } }; -struct StencilAttachmentDescriptor { +struct StencilAttachmentFaceDescriptor { //---------------------------------------------------------------------------- /// Indicates the operation to perform between the reference value and the /// value in the stencil buffer. Both values have the read_mask applied to @@ -546,6 +546,26 @@ struct StencilAttachmentDescriptor { /// Indicates what to do when both the stencil and depth tests pass. /// StencilOperation depth_stencil_pass = StencilOperation::kKeep; + + constexpr bool operator==(const StencilAttachmentFaceDescriptor& o) const { + return stencil_compare == o.stencil_compare && + stencil_failure == o.stencil_failure && + depth_failure == o.depth_failure && + depth_stencil_pass == o.depth_stencil_pass; + } + + constexpr size_t GetHash() const { + return fml::HashCombine(stencil_compare, stencil_failure, depth_failure, + depth_stencil_pass); + } +}; + +struct StencilAttachmentDescriptor { + // The stencil state applied to front-facing primitives. + StencilAttachmentFaceDescriptor front; + // The stencil state applied to back-facing primitives. + StencilAttachmentFaceDescriptor back; + //---------------------------------------------------------------------------- /// The mask applied to the reference and stencil buffer values before /// performing the stencil_compare operation. @@ -558,16 +578,13 @@ struct StencilAttachmentDescriptor { uint32_t write_mask = ~0; constexpr bool operator==(const StencilAttachmentDescriptor& o) const { - return stencil_compare == o.stencil_compare && - stencil_failure == o.stencil_failure && - depth_failure == o.depth_failure && - depth_stencil_pass == o.depth_stencil_pass && - read_mask == o.read_mask && write_mask == o.write_mask; + return front == o.front && back == o.back && read_mask == o.read_mask && + write_mask == o.write_mask; } constexpr size_t GetHash() const { - return fml::HashCombine(stencil_compare, stencil_failure, depth_failure, - depth_stencil_pass, read_mask); + return fml::HashCombine(front.GetHash(), back.GetHash(), read_mask, + write_mask); } };