Fixup names of pipeline descriptors.

This commit is contained in:
Chinmay Garde
2021-11-08 14:16:09 -08:00
committed by Dan Field
parent 3b5d0de968
commit b7cb641d6a
6 changed files with 46 additions and 44 deletions

View File

@@ -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);

View File

@@ -12,7 +12,7 @@ namespace impeller {
MTLRenderPipelineColorAttachmentDescriptor*
ToMTLRenderPipelineColorAttachmentDescriptor(
PipelineColorAttachment descriptor) {
ColorAttachmentDescriptor descriptor) {
auto des = [[MTLRenderPipelineColorAttachmentDescriptor alloc] init];
des.pixelFormat = ToMTLPixelFormat(descriptor.format);
@@ -35,7 +35,7 @@ ToMTLRenderPipelineColorAttachmentDescriptor(
}
MTLStencilDescriptor* ToMTLStencilDescriptor(
const PipelineStencilAttachment& descriptor) {
const StencilAttachmentDescriptor& descriptor) {
auto des = [[MTLStencilDescriptor alloc] init];
des.stencilCompareFunction = ToMTLCompareFunction(descriptor.stencil_compare);
des.stencilFailureOperation =
@@ -51,11 +51,11 @@ MTLStencilDescriptor* ToMTLStencilDescriptor(
}
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,

View File

@@ -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;
@@ -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 && //
@@ -254,7 +254,7 @@ enum class StencilOperation {
kDecrementWrap,
};
struct PipelineDepthAttachment {
struct DepthAttachmentDescriptor {
//----------------------------------------------------------------------------
/// Indicates how to compare the value with that in the depth buffer.
///
@@ -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;
}
@@ -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
@@ -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 &&
@@ -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();
}
};

View File

@@ -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));

View File

@@ -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;
@@ -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;

View File

@@ -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_;
}
@@ -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