temp patch

This commit is contained in:
Tyler Murphy 2022-09-19 17:48:10 -04:00
parent 2f99eee7c5
commit 9f3ed45b12

View file

@ -76,8 +76,9 @@ void XeRenderSystem::createPipelineLayout(XeDescriptorSetLayout &xeDescriptorSet
pipelineLayoutInfo.pPushConstantRanges = nullptr; pipelineLayoutInfo.pPushConstantRanges = nullptr;
} }
std::vector<VkDescriptorSetLayout> descriptorSetLayouts{xeDescriptorSetLayout.getDescriptorSetLayout()};
if (uniformBufferDataSize > 0) { if (uniformBufferDataSize > 0) {
std::vector<VkDescriptorSetLayout> descriptorSetLayouts{xeDescriptorSetLayout.getDescriptorSetLayout()};
pipelineLayoutInfo.setLayoutCount = static_cast<uint32_t>(descriptorSetLayouts.size()); pipelineLayoutInfo.setLayoutCount = static_cast<uint32_t>(descriptorSetLayouts.size());
pipelineLayoutInfo.pSetLayouts = descriptorSetLayouts.data(); pipelineLayoutInfo.pSetLayouts = descriptorSetLayouts.data();
} else { } else {
@ -115,13 +116,13 @@ void XeRenderSystem::renderGameObjects(
uint32_t pushConstantSize, uint32_t pushConstantSize,
void* uniformBufferData, void* uniformBufferData,
uint32_t uniformBufferSize) { uint32_t uniformBufferSize) {
uboBuffers[frameIndex]->writeToBuffer(uniformBufferData); uboBuffers[frameIndex]->writeToBuffer(uniformBufferData);
uboBuffers[frameIndex]->flush(); uboBuffers[frameIndex]->flush();
xePipeline->bind(commandBuffer); xePipeline->bind(commandBuffer);
if(pushConstantData == NULL) { if(pushConstantSize > 0) {
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
commandBuffer, commandBuffer,
VK_PIPELINE_BIND_POINT_GRAPHICS, VK_PIPELINE_BIND_POINT_GRAPHICS,
@ -135,14 +136,21 @@ void XeRenderSystem::renderGameObjects(
for (auto& obj: gameObjects) { 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( vkCmdPushConstants(
commandBuffer, commandBuffer,
pipelineLayout, pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
0, 0,
pushConstantSize, pushConstantSize,
&pushConstantData); &pc);
} }
obj.model->bind(commandBuffer); obj.model->bind(commandBuffer);