Skip to content

Commit

Permalink
Interface changes for asymmetric stencil specification
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccutchan committed Jul 10, 2023
1 parent 2a0dd9d commit 907354c
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions impeller/core/formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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);
}
};

Expand Down

0 comments on commit 907354c

Please sign in to comment.