diff --git a/openVulkanoCpp/Vulkan/Pipeline.hpp b/openVulkanoCpp/Vulkan/Pipeline.hpp index b40b579..365ee7c 100644 --- a/openVulkanoCpp/Vulkan/Pipeline.hpp +++ b/openVulkanoCpp/Vulkan/Pipeline.hpp @@ -1,42 +1,48 @@ +/* + * 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 #include "Base/ICloseable.hpp" -namespace openVulkanoCpp +namespace openVulkanoCpp::Vulkan { - namespace Vulkan + struct Pipeline : virtual ICloseable { - struct Pipeline : virtual ICloseable + vk::Device device; + vk::DescriptorSetLayout descriptorSetLayout; + vk::PipelineLayout pipelineLayout; + vk::DescriptorPool descriptorPool; + + void Init(const vk::Device& device) { - vk::Device device; - vk::DescriptorSetLayout descriptorSetLayout; - vk::PipelineLayout pipelineLayout; - vk::DescriptorPool descriptorPool; + this->device = device; - void Init(vk::Device& device) - { - this->device = device; + CreatePipelineLayout(); + } - CreatePipelineLayout(); - } + void Close() override + { + device.destroyPipelineLayout(pipelineLayout); + device.destroyDescriptorSetLayout(descriptorSetLayout); + } - 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::DescriptorSetLayoutBinding nodeLayoutBinding = { 0, vk::DescriptorType::eUniformBufferDynamic, 1, vk::ShaderStageFlagBits::eVertex }; - std::array layoutBindings = { nodeLayoutBinding }; - vk::DescriptorSetLayoutCreateInfo dslci = { {}, layoutBindings.size(), layoutBindings.data() }; - descriptorSetLayout = device.createDescriptorSetLayout(dslci); - vk::PipelineLayoutCreateInfo plci = { {}, 1, &descriptorSetLayout, 1, &camPushConstantDesc }; - pipelineLayout = this->device.createPipelineLayout(plci); - } - }; - } + 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 camPushConstantDescs = { camPushConstantDesc, camPushConstantDescFrag }; + vk::DescriptorSetLayoutBinding nodeLayoutBinding = { 0, vk::DescriptorType::eUniformBufferDynamic, 1, vk::ShaderStageFlagBits::eVertex }; + std::array 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); + } + }; }