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-18 20:44:11 +08:00
|
|
|
|
Pipeline *CreatePipeline(Device *dev,VKPipelineData *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-18 20:44:11 +08:00
|
|
|
|
data->pipelineInfo.layout = material->GetPipelineLayout();
|
2020-09-18 11:45:52 +08:00
|
|
|
|
|
|
|
|
|
{
|
2020-09-18 20:44:11 +08:00
|
|
|
|
data->pipelineInfo.renderPass = rt->GetRenderPass();
|
|
|
|
|
data->pipelineInfo.subpass = 0; //subpass由于还不知道有什么用,所以暂时写0,待知道功用后,需改进
|
2020-09-18 11:45:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-18 20:44:11 +08:00
|
|
|
|
if (vkCreateGraphicsPipelines( dev->GetDevice(),
|
|
|
|
|
dev->GetPipelineCache(),
|
|
|
|
|
1,&data->pipelineInfo,
|
|
|
|
|
nullptr,
|
|
|
|
|
&graphicsPipeline) != VK_SUCCESS)
|
2019-04-18 16:53:14 +08:00
|
|
|
|
return(nullptr);
|
2019-04-18 16:38:58 +08:00
|
|
|
|
|
2020-09-18 20:44:11 +08:00
|
|
|
|
return(new Pipeline(dev->GetDevice(),graphicsPipeline,data->alpha_test>0,data->alpha_blend));
|
2019-04-18 16:38:58 +08:00
|
|
|
|
}
|
|
|
|
|
VK_NAMESPACE_END
|