Rename vertex descriptor to pipeline vertex descriptor.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<VertexDescriptor>();
|
||||
auto vertex_descriptor = std::make_shared<PipelineVertexDescriptor>();
|
||||
if (!vertex_descriptor->SetStageInputs(
|
||||
VertexShader::kAllShaderStageInputs)) {
|
||||
FML_LOG(ERROR) << "Could not configure vertex descriptor.";
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
namespace impeller {
|
||||
|
||||
class ShaderFunction;
|
||||
class VertexDescriptor;
|
||||
class PipelineVertexDescriptor;
|
||||
|
||||
class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
public:
|
||||
@@ -38,7 +38,7 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
std::shared_ptr<const ShaderFunction> function);
|
||||
|
||||
PipelineDescriptor& SetVertexDescriptor(
|
||||
std::shared_ptr<VertexDescriptor> vertex_descriptor);
|
||||
std::shared_ptr<PipelineVertexDescriptor> vertex_descriptor);
|
||||
|
||||
PipelineDescriptor& SetColorAttachmentDescriptor(
|
||||
size_t index,
|
||||
@@ -77,7 +77,7 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
size_t sample_count_ = 1;
|
||||
std::map<ShaderStage, std::shared_ptr<const ShaderFunction>> entrypoints_;
|
||||
std::map<size_t, PipelineColorAttachment> color_attachment_descriptors_;
|
||||
std::shared_ptr<VertexDescriptor> vertex_descriptor_;
|
||||
std::shared_ptr<PipelineVertexDescriptor> vertex_descriptor_;
|
||||
PixelFormat depth_pixel_format_ = PixelFormat::kUnknown;
|
||||
PixelFormat stencil_pixel_format_ = PixelFormat::kUnknown;
|
||||
std::optional<PipelineDepthAttachment> depth_attachment_descriptor_;
|
||||
|
||||
@@ -82,7 +82,7 @@ PipelineDescriptor& PipelineDescriptor::AddStageEntrypoint(
|
||||
}
|
||||
|
||||
PipelineDescriptor& PipelineDescriptor::SetVertexDescriptor(
|
||||
std::shared_ptr<VertexDescriptor> vertex_descriptor) {
|
||||
std::shared_ptr<PipelineVertexDescriptor> vertex_descriptor) {
|
||||
vertex_descriptor_ = std::move(vertex_descriptor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -14,14 +14,23 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class VertexDescriptor final : public Comparable<VertexDescriptor> {
|
||||
//------------------------------------------------------------------------------
|
||||
/// @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<VS, FS>`.
|
||||
///
|
||||
class PipelineVertexDescriptor final
|
||||
: public Comparable<PipelineVertexDescriptor> {
|
||||
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 <size_t Size>
|
||||
bool SetStageInputs(
|
||||
@@ -32,13 +41,13 @@ class VertexDescriptor final : public Comparable<VertexDescriptor> {
|
||||
bool SetStageInputs(const ShaderStageIOSlot* const stage_inputs[],
|
||||
size_t count);
|
||||
|
||||
MTLVertexDescriptor* GetMTLVertexDescriptor() const;
|
||||
|
||||
//| Comparable<VertexDescriptor>|
|
||||
std::size_t GetHash() const override;
|
||||
|
||||
// |Comparable<VertexDescriptor>|
|
||||
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<VertexDescriptor> {
|
||||
};
|
||||
std::vector<StageInput> stage_inputs_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(VertexDescriptor);
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineVertexDescriptor);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -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<VertexDescriptor>|
|
||||
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<VertexDescriptor>|
|
||||
bool VertexDescriptor::IsEqual(const VertexDescriptor& other) const {
|
||||
bool PipelineVertexDescriptor::IsEqual(
|
||||
const PipelineVertexDescriptor& other) const {
|
||||
return stage_inputs_ == other.stage_inputs_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user