Skip to content

Commit

Permalink
Fixup names of pipeline descriptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent e95252f commit b5ed864
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 44 deletions.
8 changes: 4 additions & 4 deletions impeller/renderer/backend/metal/formats_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ constexpr MTLClearColor ToMTLClearColor(const Color& color) {

MTLRenderPipelineColorAttachmentDescriptor*
ToMTLRenderPipelineColorAttachmentDescriptor(
PipelineColorAttachment descriptor);
ColorAttachmentDescriptor descriptor);

MTLDepthStencilDescriptor* ToMTLDepthStencilDescriptor(
std::optional<PipelineDepthAttachment> depth,
std::optional<PipelineStencilAttachment> front,
std::optional<PipelineStencilAttachment> back);
std::optional<DepthAttachmentDescriptor> depth,
std::optional<StencilAttachmentDescriptor> front,
std::optional<StencilAttachmentDescriptor> back);

MTLTextureDescriptor* ToMTLTextureDescriptor(const TextureDescriptor& desc);

Expand Down
12 changes: 6 additions & 6 deletions impeller/renderer/backend/metal/formats_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

MTLRenderPipelineColorAttachmentDescriptor*
ToMTLRenderPipelineColorAttachmentDescriptor(
PipelineColorAttachment descriptor) {
ColorAttachmentDescriptor descriptor) {
auto des = [[MTLRenderPipelineColorAttachmentDescriptor alloc] init];
des.pixelFormat = ToMTLPixelFormat(descriptor.format);

Expand All @@ -35,7 +35,7 @@
}

MTLStencilDescriptor* ToMTLStencilDescriptor(
const PipelineStencilAttachment& descriptor) {
const StencilAttachmentDescriptor& descriptor) {
auto des = [[MTLStencilDescriptor alloc] init];
des.stencilCompareFunction = ToMTLCompareFunction(descriptor.stencil_compare);
des.stencilFailureOperation =
Expand All @@ -51,11 +51,11 @@
}

MTLDepthStencilDescriptor* ToMTLDepthStencilDescriptor(
std::optional<PipelineDepthAttachment> depth,
std::optional<PipelineStencilAttachment> front,
std::optional<PipelineStencilAttachment> back) {
std::optional<DepthAttachmentDescriptor> depth,
std::optional<StencilAttachmentDescriptor> front,
std::optional<StencilAttachmentDescriptor> back) {
if (!depth) {
depth = PipelineDepthAttachment{
depth = DepthAttachmentDescriptor{
// Always pass the depth test.
.depth_compare = CompareFunction::kAlways,
.depth_write_enabled = false,
Expand Down
20 changes: 10 additions & 10 deletions impeller/renderer/formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format) {
/// ```
///
/// The default blend mode is 1 - source alpha.
struct PipelineColorAttachment {
struct ColorAttachmentDescriptor {
PixelFormat format = PixelFormat::kUnknown;
bool blending_enabled = false;

Expand All @@ -196,7 +196,7 @@ struct PipelineColorAttachment {
std::underlying_type_t<ColorWriteMask> write_mask =
static_cast<uint64_t>(ColorWriteMask::kAll);

constexpr bool operator==(const PipelineColorAttachment& o) const {
constexpr bool operator==(const ColorAttachmentDescriptor& o) const {
return format == o.format && //
blending_enabled == o.blending_enabled && //
src_color_blend_factor == o.src_color_blend_factor && //
Expand Down Expand Up @@ -254,7 +254,7 @@ enum class StencilOperation {
kDecrementWrap,
};

struct PipelineDepthAttachment {
struct DepthAttachmentDescriptor {
//----------------------------------------------------------------------------
/// Indicates how to compare the value with that in the depth buffer.
///
Expand All @@ -264,7 +264,7 @@ struct PipelineDepthAttachment {
///
bool depth_write_enabled = false;

constexpr bool operator==(const PipelineDepthAttachment& o) const {
constexpr bool operator==(const DepthAttachmentDescriptor& o) const {
return depth_compare == o.depth_compare &&
depth_write_enabled == o.depth_write_enabled;
}
Expand All @@ -274,7 +274,7 @@ struct PipelineDepthAttachment {
}
};

struct PipelineStencilAttachment {
struct StencilAttachmentDescriptor {
//----------------------------------------------------------------------------
/// 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 Down Expand Up @@ -305,7 +305,7 @@ struct PipelineStencilAttachment {
///
uint32_t write_mask = ~0;

constexpr bool operator==(const PipelineStencilAttachment& o) const {
constexpr bool operator==(const StencilAttachmentDescriptor& o) const {
return stencil_compare == o.stencil_compare &&
stencil_failure == o.stencil_failure &&
depth_failure == o.depth_failure &&
Expand Down Expand Up @@ -344,17 +344,17 @@ struct StencilAttachment : public Attachment {
namespace std {

template <>
struct hash<impeller::PipelineDepthAttachment> {
struct hash<impeller::DepthAttachmentDescriptor> {
constexpr std::size_t operator()(
const impeller::PipelineDepthAttachment& des) const {
const impeller::DepthAttachmentDescriptor& des) const {
return des.GetHash();
}
};

template <>
struct hash<impeller::PipelineStencilAttachment> {
struct hash<impeller::StencilAttachmentDescriptor> {
constexpr std::size_t operator()(
const impeller::PipelineStencilAttachment& des) const {
const impeller::StencilAttachmentDescriptor& des) const {
return des.GetHash();
}
};
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/pipeline_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct PipelineBuilder {
// Configure the sole color attachments pixel format.
// TODO(csg): This can be easily reflected but we are sticking to the
// convention that the first stage output is the color output.
PipelineColorAttachment color0;
ColorAttachmentDescriptor color0;
color0.format = PixelFormat::kB8G8R8A8UNormInt;
color0.blending_enabled = true;
desc.SetColorAttachmentDescriptor(0u, std::move(color0));
Expand Down
14 changes: 7 additions & 7 deletions impeller/renderer/pipeline_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ PipelineDescriptor& PipelineDescriptor::SetVertexDescriptor(

PipelineDescriptor& PipelineDescriptor::SetColorAttachmentDescriptor(
size_t index,
PipelineColorAttachment desc) {
ColorAttachmentDescriptor desc) {
color_attachment_descriptors_[index] = std::move(desc);
return *this;
}

const PipelineColorAttachment* PipelineDescriptor::GetColorAttachmentDescriptor(
size_t index) const {
const ColorAttachmentDescriptor*
PipelineDescriptor::GetColorAttachmentDescriptor(size_t index) const {
auto found = color_attachment_descriptors_.find(index);
return found == color_attachment_descriptors_.end() ? nullptr
: &found->second;
Expand All @@ -114,19 +114,19 @@ PipelineDescriptor& PipelineDescriptor::SetStencilPixelFormat(
}

PipelineDescriptor& PipelineDescriptor::SetDepthStencilAttachmentDescriptor(
PipelineDepthAttachment desc) {
DepthAttachmentDescriptor desc) {
depth_attachment_descriptor_ = desc;
return *this;
}

PipelineDescriptor& PipelineDescriptor::SetStencilAttachmentDescriptors(
PipelineStencilAttachment front_and_back) {
StencilAttachmentDescriptor front_and_back) {
return SetStencilAttachmentDescriptors(front_and_back, front_and_back);
}

PipelineDescriptor& PipelineDescriptor::SetStencilAttachmentDescriptors(
PipelineStencilAttachment front,
PipelineStencilAttachment back) {
StencilAttachmentDescriptor front,
StencilAttachmentDescriptor back) {
front_stencil_attachment_descriptor_ = front;
back_stencil_attachment_descriptor_ = back;
return *this;
Expand Down
34 changes: 18 additions & 16 deletions impeller/renderer/pipeline_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,38 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {

PipelineDescriptor& SetColorAttachmentDescriptor(
size_t index,
PipelineColorAttachment desc);
ColorAttachmentDescriptor desc);

const PipelineColorAttachment* GetColorAttachmentDescriptor(
const ColorAttachmentDescriptor* GetColorAttachmentDescriptor(
size_t index) const;

const std::map<size_t /* index */, PipelineColorAttachment>
const std::map<size_t /* index */, ColorAttachmentDescriptor>
GetColorAttachmentDescriptors() const {
return color_attachment_descriptors_;
}

PipelineDescriptor& SetDepthStencilAttachmentDescriptor(
PipelineDepthAttachment desc);
DepthAttachmentDescriptor desc);

std::optional<PipelineDepthAttachment> GetDepthStencilAttachmentDescriptor()
std::optional<DepthAttachmentDescriptor> GetDepthStencilAttachmentDescriptor()
const {
return depth_attachment_descriptor_;
}

PipelineDescriptor& SetStencilAttachmentDescriptors(
PipelineStencilAttachment front_and_back);
StencilAttachmentDescriptor front_and_back);

PipelineDescriptor& SetStencilAttachmentDescriptors(
PipelineStencilAttachment front,
PipelineStencilAttachment back);
StencilAttachmentDescriptor front,
StencilAttachmentDescriptor back);

std::optional<PipelineStencilAttachment> GetFrontStencilAttachmentDescriptor()
const {
std::optional<StencilAttachmentDescriptor>
GetFrontStencilAttachmentDescriptor() const {
return front_stencil_attachment_descriptor_;
}

std::optional<PipelineStencilAttachment> GetBackStencilAttachmentDescriptor()
const {
std::optional<StencilAttachmentDescriptor>
GetBackStencilAttachmentDescriptor() const {
return back_stencil_attachment_descriptor_;
}

Expand All @@ -106,14 +106,16 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
std::string label_;
size_t sample_count_ = 1;
std::map<ShaderStage, std::shared_ptr<const ShaderFunction>> entrypoints_;
std::map<size_t /* index */, PipelineColorAttachment>
std::map<size_t /* index */, ColorAttachmentDescriptor>
color_attachment_descriptors_;
std::shared_ptr<VertexDescriptor> vertex_descriptor_;
PixelFormat depth_pixel_format_ = PixelFormat::kUnknown;
PixelFormat stencil_pixel_format_ = PixelFormat::kUnknown;
std::optional<PipelineDepthAttachment> depth_attachment_descriptor_;
std::optional<PipelineStencilAttachment> front_stencil_attachment_descriptor_;
std::optional<PipelineStencilAttachment> back_stencil_attachment_descriptor_;
std::optional<DepthAttachmentDescriptor> depth_attachment_descriptor_;
std::optional<StencilAttachmentDescriptor>
front_stencil_attachment_descriptor_;
std::optional<StencilAttachmentDescriptor>
back_stencil_attachment_descriptor_;
};

} // namespace impeller

0 comments on commit b5ed864

Please sign in to comment.