diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-19 17:48:10 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-19 17:48:10 -0400 |
commit | 9f3ed45b12ab541949682b80b2260604f2245e02 (patch) | |
tree | ad2abd872784bf913f31cdc279352a087a772990 | |
parent | even more refactoring (diff) | |
download | minecraftvulkan-9f3ed45b12ab541949682b80b2260604f2245e02.tar.gz minecraftvulkan-9f3ed45b12ab541949682b80b2260604f2245e02.tar.bz2 minecraftvulkan-9f3ed45b12ab541949682b80b2260604f2245e02.zip |
temp patch
-rw-r--r-- | engine/xe_render_system.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/engine/xe_render_system.cpp b/engine/xe_render_system.cpp index 17e62dc..8a28473 100644 --- a/engine/xe_render_system.cpp +++ b/engine/xe_render_system.cpp @@ -76,8 +76,9 @@ void XeRenderSystem::createPipelineLayout(XeDescriptorSetLayout &xeDescriptorSet pipelineLayoutInfo.pPushConstantRanges = nullptr; } + std::vector<VkDescriptorSetLayout> descriptorSetLayouts{xeDescriptorSetLayout.getDescriptorSetLayout()}; + if (uniformBufferDataSize > 0) { - std::vector<VkDescriptorSetLayout> descriptorSetLayouts{xeDescriptorSetLayout.getDescriptorSetLayout()}; pipelineLayoutInfo.setLayoutCount = static_cast<uint32_t>(descriptorSetLayouts.size()); pipelineLayoutInfo.pSetLayouts = descriptorSetLayouts.data(); } else { @@ -115,13 +116,13 @@ void XeRenderSystem::renderGameObjects( uint32_t pushConstantSize, void* uniformBufferData, uint32_t uniformBufferSize) { - + uboBuffers[frameIndex]->writeToBuffer(uniformBufferData); uboBuffers[frameIndex]->flush(); - + xePipeline->bind(commandBuffer); - if(pushConstantData == NULL) { + if(pushConstantSize > 0) { vkCmdBindDescriptorSets( commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, @@ -135,14 +136,21 @@ void XeRenderSystem::renderGameObjects( for (auto& obj: gameObjects) { - if(pushConstantData == NULL) { + struct PushConstant { + glm::mat4 modelMatrix; + glm::mat4 normalMatrix; + }; + + PushConstant pc = PushConstant{obj.transform.mat4(), obj.transform.normalMatrix()}; + + if(pushConstantSize > 0) { vkCmdPushConstants( commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pushConstantSize, - &pushConstantData); + &pc); } obj.model->bind(commandBuffer); |