Files
OpenVulkano/openVulkanoCpp/Vulkan/Pipeline.hpp

49 lines
1.7 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vulkan/vulkan.hpp>
#include "Base/ICloseable.hpp"
namespace openVulkanoCpp::Vulkan
{
struct Pipeline : virtual ICloseable
{
vk::Device device;
vk::DescriptorSetLayout descriptorSetLayout;
vk::PipelineLayout pipelineLayout;
vk::DescriptorPool descriptorPool;
void Init(const vk::Device& device)
{
this->device = device;
CreatePipelineLayout();
}
void Close() override
{
device.destroyPipelineLayout(pipelineLayout);
device.destroyDescriptorSetLayout(descriptorSetLayout);
}
private:
void CreatePipelineLayout()
{
vk::PushConstantRange camPushConstantDesc = { vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) + 4 * sizeof(float) };
std::array<vk::PushConstantRange, 1> camPushConstantDescs = { camPushConstantDesc };
vk::DescriptorSetLayoutBinding nodeLayoutBinding = { 0, vk::DescriptorType::eUniformBufferDynamic, 1, vk::ShaderStageFlagBits::eVertex };
//vk::DescriptorSetLayoutBinding textureLayoutBinding = { 0, vk::DescriptorType::image };
std::array<vk::DescriptorSetLayoutBinding, 1> layoutBindings = { nodeLayoutBinding };
vk::DescriptorSetLayoutCreateInfo dslci = { {}, layoutBindings.size(), layoutBindings.data() };
descriptorSetLayout = device.createDescriptorSetLayout(dslci);
vk::PipelineLayoutCreateInfo plci = { {}, 1, &descriptorSetLayout, camPushConstantDescs.size(), camPushConstantDescs.data() };
pipelineLayout = this->device.createPipelineLayout(plci);
}
};
}