upgrade the PipelineCreater, it don't need use RenderTarge when construct.
This commit is contained in:
parent
e7ed72d6e2
commit
5df8466cc8
@ -87,12 +87,12 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material);
|
||||
pipeline_creater->SetDepthTest(true);
|
||||
pipeline_creater->SetDepthWrite(true);
|
||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||
pipeline_creater->Set(Prim::Triangles);
|
||||
pipeline_solid=pipeline_creater->Create();
|
||||
pipeline_solid=pipeline_creater->Create(sc_render_target);
|
||||
|
||||
if(!pipeline_solid)
|
||||
return(false);
|
||||
|
@ -40,7 +40,6 @@ constexpr size_t VK_DYNAMIC_STATE_RANGE_SIZE=VK_DYNAMIC_STATE_END_RANGE-VK_DYNAM
|
||||
class PipelineCreater
|
||||
{
|
||||
VkDevice device;
|
||||
VkExtent2D extent;
|
||||
VkPipelineCache cache;
|
||||
VkGraphicsPipelineCreateInfo pipelineInfo;
|
||||
|
||||
@ -55,7 +54,7 @@ class PipelineCreater
|
||||
VkRect2D scissor;
|
||||
VkPipelineViewportStateCreateInfo viewportState;
|
||||
|
||||
void InitViewportState();
|
||||
void InitViewportState(const VkExtent2D &);
|
||||
|
||||
VkPipelineRasterizationStateCreateInfo rasterizer;
|
||||
|
||||
@ -77,8 +76,8 @@ class PipelineCreater
|
||||
|
||||
public:
|
||||
|
||||
PipelineCreater(Device *dev,const Material *,const RenderTarget *);
|
||||
PipelineCreater(Device *dev,const Material *,const RenderTarget *,uchar *data,uint size);
|
||||
PipelineCreater(Device *dev,const Material *,const uint32_t color_attachment_count=1);
|
||||
PipelineCreater(Device *dev,const Material *,uchar *data,uint size);
|
||||
~PipelineCreater()=default;
|
||||
|
||||
bool Set(const Prim prim,bool=false);
|
||||
@ -193,7 +192,7 @@ public:
|
||||
bool SaveToStream(io::DataOutputStream *dos);
|
||||
bool LoadFromMemory(uchar *,uint);
|
||||
|
||||
Pipeline *Create();
|
||||
Pipeline *Create(const RenderTarget *);
|
||||
};//class PipelineCreater
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_PIPELINE_INCLUDE
|
||||
|
@ -27,7 +27,7 @@ void PipelineCreater::InitVertexInputState(const Material *material)
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineCreater::InitViewportState()
|
||||
void PipelineCreater::InitViewportState(const VkExtent2D &extent)
|
||||
{
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
@ -70,10 +70,9 @@ void PipelineCreater::InitDynamicState()
|
||||
|
||||
//为什么一定要把ext放在这里,因为如果不放在这里,总是会让人遗忘它的重要性
|
||||
|
||||
PipelineCreater::PipelineCreater(Device *dev,const Material *material,const RenderTarget *rt)
|
||||
PipelineCreater::PipelineCreater(Device *dev,const Material *material,const uint32_t color_attachment_count)
|
||||
{
|
||||
device=dev->GetDevice();
|
||||
extent=rt->GetExtent();
|
||||
cache=dev->GetPipelineCache();
|
||||
|
||||
//未来这里需要增加是否有vs/fs的检测
|
||||
@ -89,8 +88,6 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
||||
|
||||
pipelineInfo.pTessellationState=&tessellation;
|
||||
|
||||
InitViewportState();
|
||||
|
||||
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
rasterizer.pNext = nullptr;
|
||||
rasterizer.flags = 0;
|
||||
@ -151,7 +148,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
||||
cba.srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||
cba.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||
|
||||
colorBlendAttachments.Add(cba,rt->GetColorCount()); //这个需要和subpass中的color attachment数量相等,所以添加多份
|
||||
colorBlendAttachments.Add(cba,color_attachment_count); //这个需要和subpass中的color attachment数量相等,所以添加多份
|
||||
|
||||
alpha_blend=false;
|
||||
|
||||
@ -172,10 +169,6 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
||||
InitDynamicState();
|
||||
|
||||
pipelineInfo.layout = material->GetPipelineLayout();
|
||||
{
|
||||
pipelineInfo.renderPass = rt->GetRenderPass();
|
||||
pipelineInfo.subpass = 0; //subpass由于还不知道有什么用,所以暂时写0,待知道功用后,需改进
|
||||
}
|
||||
|
||||
{
|
||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||
@ -183,21 +176,17 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
||||
}
|
||||
}
|
||||
|
||||
PipelineCreater::PipelineCreater(Device *dev,const Material *material,const RenderTarget *rt,uchar *data,uint size)
|
||||
PipelineCreater::PipelineCreater(Device *dev,const Material *material,uchar *data,uint size)
|
||||
{
|
||||
LoadFromMemory(data,size);
|
||||
|
||||
device=dev->GetDevice();
|
||||
extent=rt->GetExtent();
|
||||
cache=dev->GetPipelineCache();
|
||||
|
||||
InitVertexInputState(material);
|
||||
|
||||
pipelineInfo.pInputAssemblyState=&inputAssembly;
|
||||
pipelineInfo.pTessellationState =&tessellation;
|
||||
|
||||
InitViewportState();
|
||||
|
||||
pipelineInfo.pRasterizationState=&rasterizer;
|
||||
pipelineInfo.pMultisampleState =&multisampling;
|
||||
pipelineInfo.pDepthStencilState =&depthStencilState;
|
||||
@ -206,10 +195,6 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
||||
InitDynamicState();
|
||||
|
||||
pipelineInfo.layout = material->GetPipelineLayout();
|
||||
{
|
||||
pipelineInfo.renderPass = rt->GetRenderPass();
|
||||
pipelineInfo.subpass = 0; //subpass由于还不知道有什么用,所以暂时写0,待知道功用后,需改进
|
||||
}
|
||||
|
||||
{
|
||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||
@ -232,10 +217,17 @@ bool PipelineCreater::Set(const Prim topology,bool restart)
|
||||
return(true);
|
||||
}
|
||||
|
||||
Pipeline *PipelineCreater::Create()
|
||||
Pipeline *PipelineCreater::Create(const RenderTarget *rt)
|
||||
{
|
||||
VkPipeline graphicsPipeline;
|
||||
|
||||
InitViewportState(rt->GetExtent());
|
||||
|
||||
{
|
||||
pipelineInfo.renderPass = rt->GetRenderPass();
|
||||
pipelineInfo.subpass = 0; //subpass由于还不知道有什么用,所以暂时写0,待知道功用后,需改进
|
||||
}
|
||||
|
||||
if (vkCreateGraphicsPipelines(device, cache, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user