Implemented KRPipeline::bindDescriptorSets

This commit is contained in:
2022-09-20 19:02:54 -07:00
parent 3df8433205
commit 3ba80b1dd8
2 changed files with 15 additions and 0 deletions

View File

@@ -639,6 +639,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Matrix4* value, co
bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera& camera, const KRViewport& viewport, const Matrix4& matModel, const std::vector<KRPointLight*>* point_lights, const std::vector<KRDirectionalLight*>* directional_lights, const std::vector<KRSpotLight*>* spot_lights, const KRNode::RenderPass& renderPass) bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera& camera, const KRViewport& viewport, const Matrix4& matModel, const std::vector<KRPointLight*>* point_lights, const std::vector<KRDirectionalLight*>* directional_lights, const std::vector<KRSpotLight*>* spot_lights, const KRNode::RenderPass& renderPass)
{ {
updateDescriptorSets(); updateDescriptorSets();
bindDescriptorSets(commandBuffer);
setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime()); setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime());
int light_directional_count = 0; int light_directional_count = 0;
@@ -856,6 +857,19 @@ void KRPipeline::updateDescriptorSets()
device->createDescriptorSets(layouts, m_descriptorSets); device->createDescriptorSets(layouts, m_descriptorSets);
} }
void KRPipeline::bindDescriptorSets(VkCommandBuffer& commandBuffer)
{
if (m_descriptorSets.empty()) {
return;
}
VkDescriptorSet descriptorSet = m_descriptorSets[getContext().getCurrentFrame() % m_descriptorSets.size()];
if (descriptorSet == VK_NULL_HANDLE) {
return;
}
// TODO - Vulkan Refactoring - Support multiple descriptor set binding
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
}
const char* KRPipeline::getKey() const const char* KRPipeline::getKey() const
{ {
return m_szKey; return m_szKey;

View File

@@ -309,6 +309,7 @@ public:
VkPipeline& getPipeline(); VkPipeline& getPipeline();
void updateDescriptorSets(); void updateDescriptorSets();
void bindDescriptorSets(VkCommandBuffer& commandBuffer);
private: private:
static const char* KRENGINE_PUSH_CONSTANT_NAMES[]; static const char* KRENGINE_PUSH_CONSTANT_NAMES[];