Renamed argument when providing array of vertex binding attributes to reflect that they are, in fact attributes and not the binding description
Extended pipeline to support adding vertex bindings Vertex bindings can now be added via a template function that assumes that the type implements the following; - A function matching the signature of PFN_GetVertexInputBindingDescription and with the name get_binding_description - A function matching the signature of PFN_GetVertexAttributeDescriptions and with the name get_attribute_descriptions GetVertexAttributeDescriptions should set the num_attachments to the number of attachments if and only if the attachment output pointer is nullptr. If the output pointer is not nullptr, num_attachments should be treated as a size. Return VK_SUCCESS on success, or a different value otherwise.
This commit is contained in:
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
namespace basalt
|
namespace basalt
|
||||||
{
|
{
|
||||||
|
typedef VkVertexInputBindingDescription (*PFN_GetVertexInputBindingDescription)(void);
|
||||||
|
typedef VkResult(*PFN_GetVertexAttributeDescriptions)(VkVertexInputAttributeDescription* out_attachments, u32* num_attachments);
|
||||||
|
|
||||||
|
|
||||||
class Pipeline
|
class Pipeline
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,7 +38,10 @@ namespace basalt
|
|||||||
PipelineBuilder& add_dynamic_states(const basalt::darray<VkDynamicState>& states);
|
PipelineBuilder& add_dynamic_states(const basalt::darray<VkDynamicState>& states);
|
||||||
PipelineBuilder& set_render_pass(VkRenderPass render_pass);
|
PipelineBuilder& set_render_pass(VkRenderPass render_pass);
|
||||||
PipelineBuilder& add_colour_attachment(VkPipelineColorBlendAttachmentState attachment);
|
PipelineBuilder& add_colour_attachment(VkPipelineColorBlendAttachmentState attachment);
|
||||||
PipelineBuilder& add_vertex_binding(VkVertexInputBindingDescription binding, VkVertexInputAttributeDescription* attributes, u32 num_bindings);
|
PipelineBuilder& add_vertex_binding(VkVertexInputBindingDescription binding, VkVertexInputAttributeDescription* attributes, u32 num_attributes);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
PipelineBuilder& add_vertex_binding(void);
|
||||||
|
|
||||||
Pipeline build();
|
Pipeline build();
|
||||||
|
|
||||||
@@ -70,4 +77,16 @@ namespace basalt
|
|||||||
/// <returns>Number of bytes read from the file</returns>
|
/// <returns>Number of bytes read from the file</returns>
|
||||||
static size_t read_file(const char* fpath, char*& outptr, size_t& outptr_size);
|
static size_t read_file(const char* fpath, char*& outptr, size_t& outptr_size);
|
||||||
};
|
};
|
||||||
|
template<typename T>
|
||||||
|
inline PipelineBuilder& PipelineBuilder::add_vertex_binding(void)
|
||||||
|
{
|
||||||
|
VkResult err = VK_SUCCESS;
|
||||||
|
this->vertex_binding_description.push_back(T::get_binding_description());
|
||||||
|
u32 sz = 0;
|
||||||
|
VK_ASSERT(T::get_attribute_descriptions(nullptr, &sz), "Failed to get number of vertex attribute descriptions for object\n\tAt %s:%d\n\tError %s\n\tObject %s\n", typeid(T).name());
|
||||||
|
this->vertex_input_attributes.expand(sz);
|
||||||
|
VK_ASSERT(T::get_attribute_descriptions(this->vertex_input_attributes.end(), &sz), "Failed to get vertex attribute descriptions for object\n\tAt %s:%d\n\tError %s\n\tObject %s\n", typeid(T).name());
|
||||||
|
this->vertex_input_attributes.resize(this->vertex_input_attributes.m_nelements + sz);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user