diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index 75f3d44..d7a7cf2 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -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* point_lights, const std::vector* directional_lights, const std::vector* spot_lights, const KRNode::RenderPass& renderPass) { updateDescriptorSets(); + bindDescriptorSets(commandBuffer); setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime()); int light_directional_count = 0; @@ -856,6 +857,19 @@ void KRPipeline::updateDescriptorSets() 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 { return m_szKey; diff --git a/kraken/KRPipeline.h b/kraken/KRPipeline.h index 5f2fe5d..77a2ff9 100644 --- a/kraken/KRPipeline.h +++ b/kraken/KRPipeline.h @@ -309,6 +309,7 @@ public: VkPipeline& getPipeline(); void updateDescriptorSets(); + void bindDescriptorSets(VkCommandBuffer& commandBuffer); private: static const char* KRENGINE_PUSH_CONSTANT_NAMES[];