49 lines
1.7 KiB
C++
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, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) };
|
|
vk::PushConstantRange camPushConstantDescFrag = { vk::ShaderStageFlagBits::eFragment, 0, 3 * sizeof(Math::Matrix4f) + sizeof(Math::Vector4f) };
|
|
std::array<vk::PushConstantRange, 2> camPushConstantDescs = { camPushConstantDesc, camPushConstantDescFrag };
|
|
vk::DescriptorSetLayoutBinding nodeLayoutBinding = { 0, vk::DescriptorType::eUniformBufferDynamic, 1, vk::ShaderStageFlagBits::eVertex };
|
|
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);
|
|
}
|
|
};
|
|
}
|