diff --git a/impeller/renderer/backend/metal/formats_mtl.h b/impeller/renderer/backend/metal/formats_mtl.h index 4d3d7cc6cee89..0e76ff0926626 100644 --- a/impeller/renderer/backend/metal/formats_mtl.h +++ b/impeller/renderer/backend/metal/formats_mtl.h @@ -251,12 +251,12 @@ constexpr MTLClearColor ToMTLClearColor(const Color& color) { MTLRenderPipelineColorAttachmentDescriptor* ToMTLRenderPipelineColorAttachmentDescriptor( - PipelineColorAttachment descriptor); + ColorAttachmentDescriptor descriptor); MTLDepthStencilDescriptor* ToMTLDepthStencilDescriptor( - std::optional depth, - std::optional front, - std::optional back); + std::optional depth, + std::optional front, + std::optional back); MTLTextureDescriptor* ToMTLTextureDescriptor(const TextureDescriptor& desc); diff --git a/impeller/renderer/backend/metal/formats_mtl.mm b/impeller/renderer/backend/metal/formats_mtl.mm index 2030a07cbe687..e32121b2c66b2 100644 --- a/impeller/renderer/backend/metal/formats_mtl.mm +++ b/impeller/renderer/backend/metal/formats_mtl.mm @@ -12,7 +12,7 @@ MTLRenderPipelineColorAttachmentDescriptor* ToMTLRenderPipelineColorAttachmentDescriptor( - PipelineColorAttachment descriptor) { + ColorAttachmentDescriptor descriptor) { auto des = [[MTLRenderPipelineColorAttachmentDescriptor alloc] init]; des.pixelFormat = ToMTLPixelFormat(descriptor.format); @@ -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 = @@ -51,11 +51,11 @@ } MTLDepthStencilDescriptor* ToMTLDepthStencilDescriptor( - std::optional depth, - std::optional front, - std::optional back) { + std::optional depth, + std::optional front, + std::optional back) { if (!depth) { - depth = PipelineDepthAttachment{ + depth = DepthAttachmentDescriptor{ // Always pass the depth test. .depth_compare = CompareFunction::kAlways, .depth_write_enabled = false, diff --git a/impeller/renderer/formats.h b/impeller/renderer/formats.h index c826d0c26397e..fabbb76e36ee9 100644 --- a/impeller/renderer/formats.h +++ b/impeller/renderer/formats.h @@ -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 write_mask = static_cast(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 { +struct hash { constexpr std::size_t operator()( - const impeller::PipelineDepthAttachment& des) const { + const impeller::DepthAttachmentDescriptor& des) const { return des.GetHash(); } }; template <> -struct hash { +struct hash { constexpr std::size_t operator()( - const impeller::PipelineStencilAttachment& des) const { + const impeller::StencilAttachmentDescriptor& des) const { return des.GetHash(); } }; diff --git a/impeller/renderer/pipeline_builder.h b/impeller/renderer/pipeline_builder.h index 2f9f8bc1ecc34..f157b7fcc9c4b 100644 --- a/impeller/renderer/pipeline_builder.h +++ b/impeller/renderer/pipeline_builder.h @@ -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)); diff --git a/impeller/renderer/pipeline_descriptor.cc b/impeller/renderer/pipeline_descriptor.cc index 828fee19ac64c..b367d4d009636 100644 --- a/impeller/renderer/pipeline_descriptor.cc +++ b/impeller/renderer/pipeline_descriptor.cc @@ -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; diff --git a/impeller/renderer/pipeline_descriptor.h b/impeller/renderer/pipeline_descriptor.h index 17c80ad46bebc..3413b755fd9a7 100644 --- a/impeller/renderer/pipeline_descriptor.h +++ b/impeller/renderer/pipeline_descriptor.h @@ -53,38 +53,38 @@ class PipelineDescriptor final : public Comparable { PipelineDescriptor& SetColorAttachmentDescriptor( size_t index, - PipelineColorAttachment desc); + ColorAttachmentDescriptor desc); - const PipelineColorAttachment* GetColorAttachmentDescriptor( + const ColorAttachmentDescriptor* GetColorAttachmentDescriptor( size_t index) const; - const std::map + const std::map GetColorAttachmentDescriptors() const { return color_attachment_descriptors_; } PipelineDescriptor& SetDepthStencilAttachmentDescriptor( - PipelineDepthAttachment desc); + DepthAttachmentDescriptor desc); - std::optional GetDepthStencilAttachmentDescriptor() + std::optional 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 GetFrontStencilAttachmentDescriptor() - const { + std::optional + GetFrontStencilAttachmentDescriptor() const { return front_stencil_attachment_descriptor_; } - std::optional GetBackStencilAttachmentDescriptor() - const { + std::optional + GetBackStencilAttachmentDescriptor() const { return back_stencil_attachment_descriptor_; } @@ -106,14 +106,16 @@ class PipelineDescriptor final : public Comparable { std::string label_; size_t sample_count_ = 1; std::map> entrypoints_; - std::map + std::map color_attachment_descriptors_; std::shared_ptr vertex_descriptor_; PixelFormat depth_pixel_format_ = PixelFormat::kUnknown; PixelFormat stencil_pixel_format_ = PixelFormat::kUnknown; - std::optional depth_attachment_descriptor_; - std::optional front_stencil_attachment_descriptor_; - std::optional back_stencil_attachment_descriptor_; + std::optional depth_attachment_descriptor_; + std::optional + front_stencil_attachment_descriptor_; + std::optional + back_stencil_attachment_descriptor_; }; } // namespace impeller