2019-04-30 16:42:59 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKPipeline.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKDevice.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKMaterial.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKRenderPass.h>
|
2019-07-16 20:22:29 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKRenderTarget.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKFramebuffer.h>
|
2019-04-18 16:38:58 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-04-18 16:53:14 +08:00
|
|
|
|
Pipeline::~Pipeline()
|
|
|
|
|
{
|
|
|
|
|
vkDestroyPipeline(device,pipeline,nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
Pipeline *CreatePipeline(VkDevice device,VkPipelineCache pipeline_cache,PipelineData *data,const Material *material,const RenderTarget *rt)
|
2019-04-18 16:53:14 +08:00
|
|
|
|
{
|
2020-09-18 20:44:11 +08:00
|
|
|
|
VkPipeline graphicsPipeline;
|
|
|
|
|
|
|
|
|
|
data->InitVertexInputState(material->GetStageCount(),material->GetStages());
|
2019-04-18 16:53:14 +08:00
|
|
|
|
|
2020-09-18 20:44:11 +08:00
|
|
|
|
material->Write(data->vis_create_info);
|
2019-04-18 16:53:14 +08:00
|
|
|
|
|
2020-09-18 20:44:11 +08:00
|
|
|
|
data->InitViewportState(rt->GetExtent());
|
2019-04-18 16:38:58 +08:00
|
|
|
|
|
2020-09-19 14:58:54 +08:00
|
|
|
|
data->pipeline_info.layout = material->GetPipelineLayout();
|
2020-09-18 11:45:52 +08:00
|
|
|
|
|
|
|
|
|
{
|
2020-09-19 14:58:54 +08:00
|
|
|
|
data->pipeline_info.renderPass = rt->GetRenderPass();
|
|
|
|
|
data->pipeline_info.subpass = 0; //subpass由于还不知道有什么用,所以暂时写0,待知道功用后,需改进
|
2020-09-18 11:45:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
if (vkCreateGraphicsPipelines( device,
|
|
|
|
|
pipeline_cache,
|
2020-09-19 14:58:54 +08:00
|
|
|
|
1,&data->pipeline_info,
|
2020-09-18 20:44:11 +08:00
|
|
|
|
nullptr,
|
|
|
|
|
&graphicsPipeline) != VK_SUCCESS)
|
2019-04-18 16:53:14 +08:00
|
|
|
|
return(nullptr);
|
2019-04-18 16:38:58 +08:00
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
return(new Pipeline(device,graphicsPipeline,data));
|
2019-04-18 16:38:58 +08:00
|
|
|
|
}
|
|
|
|
|
VK_NAMESPACE_END
|