Skip to content

Commit

Permalink
create ubo bindings;
Browse files Browse the repository at this point in the history
  • Loading branch information
NateSeymour committed Nov 23, 2024
1 parent 2341508 commit f875932
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/calculator/renderer/VulkanPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,29 @@ ui::VulkanPipeline::VulkanPipeline(QVulkanWindow *window, const char *vert, cons
.blendConstants = { 0.f, 0.f, 0.f, 0.f },
};

VkDescriptorSetLayoutBinding descriptor_layout_binding {
.binding = 0,
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS,
.pImmutableSamplers = nullptr,
};

VkDescriptorSetLayoutCreateInfo descriptor_set_layout_info {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.bindingCount = 1,
.pBindings = &descriptor_layout_binding,
};

if(this->dev_->vkCreateDescriptorSetLayout(this->window_->device(), &descriptor_set_layout_info, nullptr, &this->descriptor_set_layout_) != VK_SUCCESS)
{
throw std::runtime_error("failed to create descriptor set layout");
}

VkPipelineLayoutCreateInfo pipeline_layout_info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 0,
.pSetLayouts = nullptr,
.setLayoutCount = 1,
.pSetLayouts = &this->descriptor_set_layout_,
.pushConstantRangeCount = 0,
.pPushConstantRanges = nullptr,
};
Expand Down Expand Up @@ -203,6 +222,7 @@ ui::VulkanPipeline::VulkanPipeline(QVulkanWindow *window, const char *vert, cons

void ui::VulkanPipeline::Destroy()
{
this->dev_->vkDestroyDescriptorSetLayout(this->window_->device(), this->descriptor_set_layout_, nullptr);
this->dev_->vkDestroyPipeline(this->window_->device(), this->pipeline_, nullptr);
this->dev_->vkDestroyPipelineLayout(this->window_->device(), this->pipeline_layout_, nullptr);
}
Expand Down
1 change: 1 addition & 0 deletions src/calculator/renderer/VulkanPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ui
QVulkanWindow *window_;
QVulkanDeviceFunctions *dev_;

VkDescriptorSetLayout descriptor_set_layout_ = nullptr;
VkPipelineLayout pipeline_layout_ = nullptr;
VkPipeline pipeline_ = nullptr;

Expand Down

0 comments on commit f875932

Please sign in to comment.