diff --git a/example/Vulkan/CMakeLists.txt b/example/Vulkan/CMakeLists.txt index 262511e4..f0f795bd 100644 --- a/example/Vulkan/CMakeLists.txt +++ b/example/Vulkan/CMakeLists.txt @@ -21,6 +21,7 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp VKRenderPass.cpp VKShader.cpp VKVertexInput.cpp + VKPipeline.cpp VKSemaphore.cpp ) @@ -39,6 +40,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h VKShader.h VKVertexInput.h VKSemaphore.h + VKPipeline.h Window.h) SET(SHADER_FILES shader_compile.bat diff --git a/example/Vulkan/VKPipeline.cpp b/example/Vulkan/VKPipeline.cpp new file mode 100644 index 00000000..d52cdde3 --- /dev/null +++ b/example/Vulkan/VKPipeline.cpp @@ -0,0 +1,52 @@ +#include"VKPipeline.h" +#include"VKShader.h" +#include"VKVertexInput.h" + +VK_NAMESPACE_BEGIN +bool PipelineCreater::Set(const Shader *s) +{ + if(!s)return(false); + + //未来这里需要增加是否有vs/fs的检测 + + shader=s; + + pipelineInfo.stageCount=shader->GetCount(); + pipelineInfo.pStages=shader->GetStages(); + + return(true); +} + +bool PipelineCreater::Set(const VertexInput *vi) +{ + if(!vi)return(false); + + vertex_input=vi; + + vis_create_info=vertex_input->GetPipelineVertexInputStateCreateInfo(); + + pipelineInfo.pVertexInputState=&vis_create_info; + return(true); +} + +Pipeline *PipelineCreater::Create() +{ + //pipelineInfo.pInputAssemblyState = &inputAssembly; + //pipelineInfo.pViewportState = &viewportState; + //pipelineInfo.pRasterizationState = &rasterizer; + //pipelineInfo.pMultisampleState = &multisampling; + //pipelineInfo.pColorBlendState = &colorBlending; + //pipelineInfo.layout = pipelineLayout; + //pipelineInfo.renderPass = renderPass; + //pipelineInfo.subpass = 0; + //pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; + + //VkPipeline graphicsPipeline; + + //if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS) { + // throw std::runtime_error("failed to create graphics pipeline!"); + //} + + return(nullptr); +} +VK_NAMESPACE_END diff --git a/example/Vulkan/VKPipeline.h b/example/Vulkan/VKPipeline.h new file mode 100644 index 00000000..d0fd2ffe --- /dev/null +++ b/example/Vulkan/VKPipeline.h @@ -0,0 +1,45 @@ +#ifndef HGL_GRAPH_VULKAN_PIPELINE_INCLUDE +#define HGL_GRAPH_VULKAN_PIPELINE_INCLUDE + +#include"VK.h" + +VK_NAMESPACE_BEGIN +class Pipeline +{ + VkPipeline pipeline; + +public: + + Pipeline(VkPipeline p){pipeline=p;} + virtual ~Pipeline(); +};//class GraphicsPipeline + +class Shader; +class VertexInput; + +class PipelineCreater +{ + VkGraphicsPipelineCreateInfo pipelineInfo; + + VkPipelineVertexInputStateCreateInfo vis_create_info; + +private: + + const Shader * shader =nullptr; + const VertexInput * vertex_input=nullptr; + +public: + + PipelineCreater() + { + pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + } + ~PipelineCreater(); + + bool Set(const Shader *); + bool Set(const VertexInput *); + + Pipeline *Create(); +};//class PipelineCreater +VK_NAMESPACE_END +#endif//HGL_GRAPH_VULKAN_PIPELINE_INCLUDE diff --git a/example/Vulkan/VKShader.h b/example/Vulkan/VKShader.h index 37b6da3a..c8b55d11 100644 --- a/example/Vulkan/VKShader.h +++ b/example/Vulkan/VKShader.h @@ -43,7 +43,7 @@ public: shader_stage_list.Clear(); } - const uint32_t GetCount ()const{return shader_stage_list.GetCount();} - const VkPipelineShaderStageCreateInfo * GetShaderStages ()const{return shader_stage_list.GetData();} + const uint32_t GetCount ()const{return shader_stage_list.GetCount();} + const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list.GetData();} };//class ShaderCreater VK_NAMESPACE_END