Skip to content
Snippets Groups Projects
Commit ab4cc615 authored by Mara Vogt's avatar Mara Vogt
Browse files

[#11] added documentation to pipeline class and core

added doc for new function in core class
added doc for pipeline class
reformated some code in pipeline function in core class
parent 703c817a
No related branches found
No related tags found
4 merge requests!12Resolve "Swapchain Class",!7Resolve "Shader Program Class",!5Resolve "Pipeline State Object",!4Resolve "Renderpass Class"
Pipeline #24727 passed
......@@ -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);
};
}
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment