Update how camera data is communicated to shader

This commit is contained in:
2023-08-31 21:16:11 +02:00
parent 93c75763c7
commit df4194be51
21 changed files with 265 additions and 177 deletions

View File

@@ -23,7 +23,8 @@ namespace openVulkanoCpp::Vulkan
device.destroyShaderModule(shaderModule);
}
device.destroyPipelineLayout(pipelineLayout);
device.destroyDescriptorSetLayout(descriptorSetLayout);
for(auto& descriptorSetLayout : descriptorSetLayouts)
device.destroyDescriptorSetLayout(descriptorSetLayout);
}
void VulkanShader::Init(Context* context, Scene::Shader* shader, IShaderOwner* owner)
@@ -128,12 +129,15 @@ namespace openVulkanoCpp::Vulkan
void VulkanShader::CreatePipelineLayout()
{
vk::PushConstantRange camPushConstantDesc = { vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) + 8 * sizeof(float) };
std::array<vk::PushConstantRange, 1> camPushConstantDescs = { camPushConstantDesc };
std::array<vk::DescriptorSetLayoutBinding, 1> layoutBindings = { reinterpret_cast<const vk::DescriptorSetLayoutBinding&>(NODE_LAYOUT_BINDING) };
vk::DescriptorSetLayoutCreateInfo dslci = { {}, layoutBindings.size(), layoutBindings.data() };
descriptorSetLayout = device.createDescriptorSetLayout(dslci);
vk::PipelineLayoutCreateInfo plci = { {}, 1, &descriptorSetLayout, camPushConstantDescs.size(), camPushConstantDescs.data() };
//vk::PushConstantRange camPushConstantDesc = { vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) + 8 * sizeof(float) };
//std::array<vk::PushConstantRange, 1> camPushConstantDescs = { camPushConstantDesc };
std::array<vk::DescriptorSetLayoutBinding, 1> layoutBindings1 = { reinterpret_cast<const vk::DescriptorSetLayoutBinding&>(NODE_LAYOUT_BINDING) };
std::array<vk::DescriptorSetLayoutBinding, 1> layoutBindings2 = { reinterpret_cast<const vk::DescriptorSetLayoutBinding&>(CAM_LAYOUT_BINDING) };
vk::DescriptorSetLayoutCreateInfo dslci = { {}, layoutBindings1.size(), layoutBindings1.data() };
vk::DescriptorSetLayoutCreateInfo dslci2 = { {}, layoutBindings2.size(), layoutBindings2.data() };
descriptorSetLayouts.push_back(device.createDescriptorSetLayout(dslci));
descriptorSetLayouts.push_back(device.createDescriptorSetLayout(dslci2));
vk::PipelineLayoutCreateInfo plci = { {}, static_cast<uint32_t>(descriptorSetLayouts.size()), descriptorSetLayouts.data(), 0, nullptr };
pipelineLayout = this->device.createPipelineLayout(plci);
}
}