Move push constant related code from KRPipelnie::bind to its own function, KRPipeline::updatePushConstants

This commit is contained in:
2025-08-23 14:36:52 -07:00
parent 2fc46ece57
commit 9df960d181
2 changed files with 12 additions and 6 deletions

View File

@@ -651,11 +651,8 @@ void KRPipeline::updateDescriptorBinding()
// Vulkan Refactoring // Vulkan Refactoring
} }
bool KRPipeline::bind(KRNode::RenderInfo& ri, const Matrix4& matModel) void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matModel)
{ {
updateDescriptorBinding();
updateDescriptorSets();
bindDescriptorSets(ri.commandBuffer);
setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime()); setPushConstant(PushConstant::absolute_time, getContext().getAbsoluteTime());
int light_directional_count = 0; int light_directional_count = 0;
@@ -841,6 +838,14 @@ bool KRPipeline::bind(KRNode::RenderInfo& ri, const Matrix4& matModel)
vkCmdPushConstants(ri.commandBuffer, pushConstants.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, pushConstants.bufferSize, pushConstants.buffer); vkCmdPushConstants(ri.commandBuffer, pushConstants.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, pushConstants.bufferSize, pushConstants.buffer);
} }
} }
}
bool KRPipeline::bind(KRNode::RenderInfo& ri, const Matrix4& matModel)
{
updateDescriptorBinding();
updateDescriptorSets();
bindDescriptorSets(ri.commandBuffer);
updatePushConstants(ri, matModel);
if (ri.pipeline != this) { if (ri.pipeline != this) {
vkCmdBindPipeline(ri.commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline); vkCmdBindPipeline(ri.commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline);

View File

@@ -306,11 +306,12 @@ public:
void setImageBinding(const std::string& name, KRTexture* texture, KRSampler* sampler); void setImageBinding(const std::string& name, KRTexture* texture, KRSampler* sampler);
VkPipeline& getPipeline(); VkPipeline& getPipeline();
void updateDescriptorBinding();
void updateDescriptorSets();
void bindDescriptorSets(VkCommandBuffer& commandBuffer); void bindDescriptorSets(VkCommandBuffer& commandBuffer);
private: private:
void updateDescriptorBinding();
void updateDescriptorSets();
void updatePushConstants(KRNode::RenderInfo& ri, const hydra::Matrix4& matModel);
static const char* KRENGINE_PUSH_CONSTANT_NAMES[]; static const char* KRENGINE_PUSH_CONSTANT_NAMES[];
struct PushConstantInfo struct PushConstantInfo