diff --git a/include/vkcv/Core.hpp b/include/vkcv/Core.hpp index aa5dc52e5a9ca8f973c8103f586aed19c3c60b2a..ad3011b61dcc7892a9b900b5ba4a0edd12ce739a 100644 --- a/include/vkcv/Core.hpp +++ b/include/vkcv/Core.hpp @@ -99,10 +99,19 @@ namespace vkcv std::vector<const char*> instanceExtensions = {}, std::vector<const char*> deviceExtensions = {}); + /** + * Creates a basic vulkan graphics pipeline using @p pipeline from the pipeline class and returns it using the @p handle. + * Fixed Functions for pipeline are set with standard values. + * + * @param pipeline a pipeline object from the pipeline class + * @param handle a handle to return the created vulkan handle + * @return True if Pipeline creation was successfull, False if not + */ + bool createPipeline(const Pipeline &pipeline, PipelineHandle &handle); + // TODO: BufferHandle createBuffer(const Buffer &buf); PassHandle createRenderPass(const Renderpass &pass) ; - bool createPipeline(const Pipeline &pipeline, PipelineHandle &handle); }; } diff --git a/include/vkcv/Pipeline.hpp b/include/vkcv/Pipeline.hpp index a0b5fdd2cb6b1cf93c09c8deed1089524edf37d1..8d39ca63bf75b9df8d464b15f908bf9d88c7bb10 100644 --- a/include/vkcv/Pipeline.hpp +++ b/include/vkcv/Pipeline.hpp @@ -16,7 +16,21 @@ namespace vkcv { class Pipeline { public: + /** + * Default constructer is deleted! + */ Pipeline() = delete; + + /** + * Constructor for the pipeline. Creates a pipeline using @p vertexCode, @p fragmentCode as well as the + * dimensions of the application window @p width and @p height. A handle for the Render Pass is also needed, @p passHandle. + * + * @param vertexCode Spir-V of Vertex Shader + * @param fragCode Spir-V of Fragment Shader + * @param height height of the application window + * @param width width of the application window + * @param passHandle handle for Render Pass + */ Pipeline(const std::vector<uint32_t> &vertexCode, const std::vector<uint32_t> &fragCode, uint32_t height, uint32_t width, PassHandle &passHandle); std::vector<uint32_t> m_vertexCode; diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index eb3195b4085c1471c799d951df747deb743ae483..89ccb1be04cc36d2aa1d2b65cfb5b5fdcf2bf526 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -281,29 +281,49 @@ namespace vkcv // vertex shader stage vk::ShaderModuleCreateInfo vertexModuleInfo({},pipeline.m_vertexCode.size(), pipeline.m_vertexCode.data()); vk::ShaderModule vertexModule{}; - if(m_Context.m_Device.createShaderModule(&vertexModuleInfo, nullptr, &vertexModule) != vk::Result::eSuccess){ + if(m_Context.m_Device.createShaderModule(&vertexModuleInfo, nullptr, &vertexModule) != vk::Result::eSuccess) return false; - }; - vk::PipelineShaderStageCreateInfo pipelineVertexShaderStageInfo({}, vk::ShaderStageFlagBits::eVertex,vertexModule, "main", - nullptr); + + vk::PipelineShaderStageCreateInfo pipelineVertexShaderStageInfo( + {}, + vk::ShaderStageFlagBits::eVertex, + vertexModule, + "main", + nullptr + ); // fragment shader stage vk::ShaderModuleCreateInfo fragmentModuleInfo({},pipeline.m_fragCode.size(), pipeline.m_fragCode.data()); vk::ShaderModule fragmentModule{}; - if(m_Context.m_Device.createShaderModule(&fragmentModuleInfo, nullptr, &fragmentModule) != vk::Result::eSuccess){ + if(m_Context.m_Device.createShaderModule(&fragmentModuleInfo, nullptr, &fragmentModule) != vk::Result::eSuccess) return false; - }; - vk::PipelineShaderStageCreateInfo pipelineFragmentShaderStageInfo({}, vk::ShaderStageFlagBits::eFragment,fragmentModule, "main", - nullptr); + + vk::PipelineShaderStageCreateInfo pipelineFragmentShaderStageInfo( + {}, + vk::ShaderStageFlagBits::eFragment, + fragmentModule, + "main", + nullptr + ); // vertex input state vk::VertexInputBindingDescription vertexInputBindingDescription(0,12,vk::VertexInputRate::eVertex); vk::VertexInputAttributeDescription vertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, 0); - vk::PipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo({}, 1, &vertexInputBindingDescription, 1, &vertexInputAttributeDescription); + vk::PipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo( + {}, + 1, + &vertexInputBindingDescription, + 1, + &vertexInputAttributeDescription + ); // input assembly state - vk::PipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo({}, vk::PrimitiveTopology::eTriangleList, false); + vk::PipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo( + {}, + vk::PrimitiveTopology::eTriangleList, + false + ); // viewport state vk::Viewport viewport(0.f, 0.f, static_cast<float>(pipeline.m_width), static_cast<float>(pipeline.m_height), 0.f, 1.f); @@ -369,9 +389,8 @@ namespace vkcv {} ); vk::PipelineLayout vkPipelineLayout{}; - if(m_Context.m_Device.createPipelineLayout(&pipelineLayoutCreateInfo, nullptr, &vkPipelineLayout) != vk::Result::eSuccess){ + if(m_Context.m_Device.createPipelineLayout(&pipelineLayoutCreateInfo, nullptr, &vkPipelineLayout) != vk::Result::eSuccess) return false; - } // graphics pipeline create std::vector<vk::PipelineShaderStageCreateInfo> shaderStages = {pipelineVertexShaderStageInfo, pipelineFragmentShaderStageInfo}; @@ -396,9 +415,8 @@ namespace vkcv ); vk::Pipeline vkPipeline{}; - if(m_Context.m_Device.createGraphicsPipelines(nullptr, 1, &graphicsPipelineCreateInfo, nullptr, &vkPipeline) != vk::Result::eSuccess){ + if(m_Context.m_Device.createGraphicsPipelines(nullptr, 1, &graphicsPipelineCreateInfo, nullptr, &vkPipeline) != vk::Result::eSuccess) return false; - } m_Pipelines.push_back(vkPipeline); m_PipelineLayouts.push_back(vkPipelineLayout);