Updated PipelineBuilder to now allow adding vertex bindings

This commit is contained in:
2025-07-10 00:46:33 +10:00
parent f719c5875b
commit d550307011
2 changed files with 19 additions and 2 deletions

View File

@@ -34,11 +34,10 @@ namespace basalt
PipelineBuilder& add_dynamic_states(const basalt::darray<VkDynamicState>& states);
PipelineBuilder& set_render_pass(VkRenderPass render_pass);
PipelineBuilder& add_colour_attachment(VkPipelineColorBlendAttachmentState attachment);
PipelineBuilder& add_vertex_binding(VkVertexInputBindingDescription binding, VkVertexInputAttributeDescription* attributes, u32 num_bindings);
Pipeline build();
basalt::darray<VkShaderModule> shader_modules;
basalt::darray<VkPipelineShaderStageCreateInfo> shader_stages;
VkPipelineRasterizationStateCreateInfo raster_ci;
VkPipelineColorBlendStateCreateInfo colour_blend_ci;
@@ -48,6 +47,10 @@ namespace basalt
VkPipelineViewportStateCreateInfo viewport_ci;
VkPipelineInputAssemblyStateCreateInfo assembly_ci;
VkPipelineDynamicStateCreateInfo dynamic_state_ci;
basalt::darray<VkVertexInputAttributeDescription> vertex_input_attributes;
basalt::darray<VkVertexInputBindingDescription> vertex_binding_description;
basalt::darray<VkShaderModule> shader_modules;
basalt::darray<VkPipelineShaderStageCreateInfo> shader_stages;
basalt::darray<VkPipelineColorBlendAttachmentState> colour_attachments;
basalt::darray<VkDynamicState> dynamic_states;
VkViewport viewport;

View File

@@ -6,6 +6,8 @@ basalt::PipelineBuilder::PipelineBuilder(basalt::Device& device, VkExtent2D exte
shader_modules(MEMORY_TAG_CLASS_DYNARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY),
colour_attachments(MEMORY_TAG_CLASS_DYNARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY),
dynamic_states(MEMORY_TAG_CLASS_DYNARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY),
vertex_input_attributes(MEMORY_TAG_CLASS_DYNARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY),
vertex_binding_description(MEMORY_TAG_CLASS_DYNARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY),
device(device), previous_pipeline(previous_pipeline)
{
dynamic_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
@@ -171,6 +173,11 @@ basalt::Pipeline basalt::PipelineBuilder::build()
colour_blend_ci.attachmentCount = this->colour_attachments.m_nelements;
colour_blend_ci.pAttachments = this->colour_attachments.m_pdata;
vertex_ci.pVertexBindingDescriptions = this->vertex_binding_description.m_pdata;
vertex_ci.vertexBindingDescriptionCount = this->vertex_binding_description.m_nelements;
vertex_ci.pVertexAttributeDescriptions = this->vertex_input_attributes.m_pdata;
vertex_ci.vertexAttributeDescriptionCount = this->vertex_input_attributes.m_nelements;
VkGraphicsPipelineCreateInfo ci = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO };
ci.flags = VK_PIPELINE_CREATE_DERIVATIVE_BIT * (this->previous_pipeline != VK_NULL_HANDLE);
ci.basePipelineHandle = this->previous_pipeline;
@@ -224,3 +231,10 @@ basalt::PipelineBuilder& basalt::PipelineBuilder::add_colour_attachment(VkPipeli
this->colour_attachments.push_back(attachment);
return *this;
}
basalt::PipelineBuilder& basalt::PipelineBuilder::add_vertex_binding(VkVertexInputBindingDescription binding, VkVertexInputAttributeDescription* attributes, u32 num_bindings)
{
this->vertex_input_attributes.push_back(attributes, num_bindings);
this->vertex_binding_description.push_back(binding);
return *this;
}