From 2e8fd8346073bfdf207b9dfb87c1ad4a1ab8daaf Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sun, 18 Jul 2021 14:59:17 -0700 Subject: [PATCH] Rename vertex descriptor to pipeline vertex descriptor. --- .../flutter/impeller/compositor/command.mm | 3 ++- .../impeller/compositor/pipeline_builder.h | 4 ++-- .../impeller/compositor/pipeline_descriptor.h | 6 ++--- .../compositor/pipeline_descriptor.mm | 2 +- .../impeller/compositor/vertex_descriptor.h | 23 +++++++++++++------ .../impeller/compositor/vertex_descriptor.mm | 13 ++++++----- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/engine/src/flutter/impeller/compositor/command.mm b/engine/src/flutter/impeller/compositor/command.mm index 3e505af69b..bc7427eed5 100644 --- a/engine/src/flutter/impeller/compositor/command.mm +++ b/engine/src/flutter/impeller/compositor/command.mm @@ -11,7 +11,8 @@ namespace impeller { bool Command::BindVertices(const VertexBuffer& buffer) { - vertex_bindings.buffers[VertexDescriptor::kReservedVertexBufferIndex] = + vertex_bindings + .buffers[PipelineVertexDescriptor::kReservedVertexBufferIndex] = buffer.vertex_buffer; index_buffer = buffer.index_buffer; index_count = buffer.index_count; diff --git a/engine/src/flutter/impeller/compositor/pipeline_builder.h b/engine/src/flutter/impeller/compositor/pipeline_builder.h index dd5dd22e08..9a84e4e63c 100644 --- a/engine/src/flutter/impeller/compositor/pipeline_builder.h +++ b/engine/src/flutter/impeller/compositor/pipeline_builder.h @@ -32,7 +32,7 @@ struct PipelineBuilder { using FragmentShader = FragmentShader_; static constexpr size_t kVertexBufferIndex = - VertexDescriptor::kReservedVertexBufferIndex; + PipelineVertexDescriptor::kReservedVertexBufferIndex; //---------------------------------------------------------------------------- /// @brief Create a default pipeline descriptor using the combination @@ -70,7 +70,7 @@ struct PipelineBuilder { // Setup the vertex descriptor from reflected information. { - auto vertex_descriptor = std::make_shared(); + auto vertex_descriptor = std::make_shared(); if (!vertex_descriptor->SetStageInputs( VertexShader::kAllShaderStageInputs)) { FML_LOG(ERROR) << "Could not configure vertex descriptor."; diff --git a/engine/src/flutter/impeller/compositor/pipeline_descriptor.h b/engine/src/flutter/impeller/compositor/pipeline_descriptor.h index 0e60d4585c..a048da412f 100644 --- a/engine/src/flutter/impeller/compositor/pipeline_descriptor.h +++ b/engine/src/flutter/impeller/compositor/pipeline_descriptor.h @@ -22,7 +22,7 @@ namespace impeller { class ShaderFunction; -class VertexDescriptor; +class PipelineVertexDescriptor; class PipelineDescriptor final : public Comparable { public: @@ -38,7 +38,7 @@ class PipelineDescriptor final : public Comparable { std::shared_ptr function); PipelineDescriptor& SetVertexDescriptor( - std::shared_ptr vertex_descriptor); + std::shared_ptr vertex_descriptor); PipelineDescriptor& SetColorAttachmentDescriptor( size_t index, @@ -77,7 +77,7 @@ class PipelineDescriptor final : public Comparable { size_t sample_count_ = 1; std::map> entrypoints_; std::map color_attachment_descriptors_; - std::shared_ptr vertex_descriptor_; + std::shared_ptr vertex_descriptor_; PixelFormat depth_pixel_format_ = PixelFormat::kUnknown; PixelFormat stencil_pixel_format_ = PixelFormat::kUnknown; std::optional depth_attachment_descriptor_; diff --git a/engine/src/flutter/impeller/compositor/pipeline_descriptor.mm b/engine/src/flutter/impeller/compositor/pipeline_descriptor.mm index 91fc29bf0f..9713ee8540 100644 --- a/engine/src/flutter/impeller/compositor/pipeline_descriptor.mm +++ b/engine/src/flutter/impeller/compositor/pipeline_descriptor.mm @@ -82,7 +82,7 @@ PipelineDescriptor& PipelineDescriptor::AddStageEntrypoint( } PipelineDescriptor& PipelineDescriptor::SetVertexDescriptor( - std::shared_ptr vertex_descriptor) { + std::shared_ptr vertex_descriptor) { vertex_descriptor_ = std::move(vertex_descriptor); return *this; } diff --git a/engine/src/flutter/impeller/compositor/vertex_descriptor.h b/engine/src/flutter/impeller/compositor/vertex_descriptor.h index d6c97de75e..1fb20ca4e3 100644 --- a/engine/src/flutter/impeller/compositor/vertex_descriptor.h +++ b/engine/src/flutter/impeller/compositor/vertex_descriptor.h @@ -14,14 +14,23 @@ namespace impeller { -class VertexDescriptor final : public Comparable { +//------------------------------------------------------------------------------ +/// @brief Describes the format and layout of vertices expected by the +/// pipeline. While it is possible to construct these descriptors +/// manually, it would be tedious to do so. These are usually +/// constructed using shader information reflected using +/// `impellerc`. The usage of this class is indirectly via +/// `PipelineBuilder`. +/// +class PipelineVertexDescriptor final + : public Comparable { public: static constexpr size_t kReservedVertexBufferIndex = 30u; // The final slot available. Regular buffer indices go up from 0. - VertexDescriptor(); + PipelineVertexDescriptor(); - virtual ~VertexDescriptor(); + virtual ~PipelineVertexDescriptor(); template bool SetStageInputs( @@ -32,13 +41,13 @@ class VertexDescriptor final : public Comparable { bool SetStageInputs(const ShaderStageIOSlot* const stage_inputs[], size_t count); - MTLVertexDescriptor* GetMTLVertexDescriptor() const; - //| Comparable| std::size_t GetHash() const override; // |Comparable| - bool IsEqual(const VertexDescriptor& other) const override; + bool IsEqual(const PipelineVertexDescriptor& other) const override; + + MTLVertexDescriptor* GetMTLVertexDescriptor() const; private: struct StageInput { @@ -56,7 +65,7 @@ class VertexDescriptor final : public Comparable { }; std::vector stage_inputs_; - FML_DISALLOW_COPY_AND_ASSIGN(VertexDescriptor); + FML_DISALLOW_COPY_AND_ASSIGN(PipelineVertexDescriptor); }; } // namespace impeller diff --git a/engine/src/flutter/impeller/compositor/vertex_descriptor.mm b/engine/src/flutter/impeller/compositor/vertex_descriptor.mm index 9707db0e7e..6a729b4df1 100644 --- a/engine/src/flutter/impeller/compositor/vertex_descriptor.mm +++ b/engine/src/flutter/impeller/compositor/vertex_descriptor.mm @@ -8,9 +8,9 @@ namespace impeller { -VertexDescriptor::VertexDescriptor() = default; +PipelineVertexDescriptor::PipelineVertexDescriptor() = default; -VertexDescriptor::~VertexDescriptor() = default; +PipelineVertexDescriptor::~PipelineVertexDescriptor() = default; static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) { if (input.columns != 1) { @@ -168,7 +168,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) { } } -bool VertexDescriptor::SetStageInputs( +bool PipelineVertexDescriptor::SetStageInputs( const ShaderStageIOSlot* const stage_inputs[], size_t count) { stage_inputs_.clear(); @@ -188,7 +188,7 @@ bool VertexDescriptor::SetStageInputs( return true; } -MTLVertexDescriptor* VertexDescriptor::GetMTLVertexDescriptor() const { +MTLVertexDescriptor* PipelineVertexDescriptor::GetMTLVertexDescriptor() const { auto descriptor = [MTLVertexDescriptor vertexDescriptor]; const size_t vertex_buffer_index = kReservedVertexBufferIndex; @@ -214,7 +214,7 @@ MTLVertexDescriptor* VertexDescriptor::GetMTLVertexDescriptor() const { } // |Comparable| -std::size_t VertexDescriptor::GetHash() const { +std::size_t PipelineVertexDescriptor::GetHash() const { auto seed = fml::HashCombine(); for (const auto& input : stage_inputs_) { fml::HashCombineSeed(seed, input.location, input.format); @@ -223,7 +223,8 @@ std::size_t VertexDescriptor::GetHash() const { } // |Comparable| -bool VertexDescriptor::IsEqual(const VertexDescriptor& other) const { +bool PipelineVertexDescriptor::IsEqual( + const PipelineVertexDescriptor& other) const { return stage_inputs_ == other.stage_inputs_; }