PipelineCreater传递参数分开Renderpass+extent,改为传一个RenderTarget

This commit is contained in:
hyzboy 2019-07-16 20:22:29 +08:00
parent 32db6678cc
commit d23abfade0
17 changed files with 39 additions and 33 deletions

View File

@ -88,7 +88,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->SetDepthTest(true);
pipeline_creater->SetDepthWrite(true);
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);

View File

@ -251,7 +251,7 @@ private:
bool InitCompositionPipeline(SubpassParam *sp)
{
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,sc_render_target);
pipeline_creater->SetDepthTest(false);
pipeline_creater->SetDepthWrite(false);
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);

View File

@ -115,7 +115,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->CloseCullFace();
pipeline_creater->Set(PRIM_TRIANGLE_FAN);

View File

@ -58,7 +58,7 @@ private:
bool InitPipeline(MDP *mdp,const VkPrimitiveTopology primitive)
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,sc_render_target);
pipeline_creater->CloseCullFace();
pipeline_creater->Set(primitive);

View File

@ -137,7 +137,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->Set(PRIM_LINES);
pipeline_line=pipeline_creater->Create();

View File

@ -163,7 +163,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->SetDepthTest(false);
pipeline_creater->SetDepthWrite(false);
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_LINE);

View File

@ -75,7 +75,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->SetDepthTest(true);
pipeline_creater->SetDepthWrite(true);
pipeline_creater->CloseCullFace();

View File

@ -104,7 +104,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->CloseCullFace();
pipeline_creater->Set(PRIM_TRIANGLES);

View File

@ -108,7 +108,7 @@ private:
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->CloseCullFace();
pipeline_creater->Set(PRIM_TRIANGLES);
@ -119,7 +119,7 @@ private:
void *data;
uint size=filesystem::LoadFileToMemory(PIPELINE_FILENAME,(void **)&data);
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent(),(uchar *)data,size);
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target,(uchar *)data,size);
pipeline=pipeline_creater->Create();
}

View File

@ -149,7 +149,7 @@ private:
bool InitPipeline()
{
AutoDelete<vulkan::PipelineCreater>
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
pipeline_creater->CloseCullFace();
pipeline_creater->Set(PRIM_TRIANGLES);

View File

@ -91,7 +91,7 @@ public:
vkCmdCopyImageToBuffer(cmd_buf,srcImage,srcImageLayout,dstBuffer,regionCount,pRegions);
}
bool BeginRenderPass(RenderPass *rp,Framebuffer *fb);
bool BeginRenderPass(VkRenderPass rp,VkFramebuffer fb);
bool Bind(Pipeline *p)
{

View File

@ -37,8 +37,8 @@ public:
~Framebuffer();
VkFramebuffer GetFramebuffer (){return frame_buffer;}
VkRenderPass GetRenderPass (){return fb_info->renderPass;}
const VkFramebuffer GetFramebuffer ()const{return frame_buffer;}
const VkRenderPass GetRenderPass ()const{return fb_info->renderPass;}
const VkExtent2D & GetExtent ()const{return extent;}

View File

@ -67,8 +67,8 @@ class PipelineCreater
public:
PipelineCreater(Device *dev,const Material *,RenderPass *rp,const VkExtent2D &);
PipelineCreater(Device *dev,const Material *,RenderPass *rp,const VkExtent2D &,uchar *,uint);
PipelineCreater(Device *dev,const Material *,const RenderTarget *);
PipelineCreater(Device *dev,const Material *,const RenderTarget *,uchar *,uint);
~PipelineCreater()=default;
bool Set(const VkPrimitiveTopology,bool=false);

View File

@ -35,6 +35,8 @@ class RenderTarget:public SubmitQueue
protected:
Framebuffer *fb;
VkExtent2D extent;
protected:
@ -46,6 +48,9 @@ public:
virtual ~RenderTarget()=default;
const VkExtent2D & GetExtent()const{return extent;}
virtual const VkRenderPass GetRenderPass()const{return fb->GetRenderPass();}
virtual const uint32_t GetColorCount()const{return fb->GetColorCount();}
};//class RenderTarget
/**
@ -60,7 +65,6 @@ class SwapchainRenderTarget:public RenderTarget
RenderPass *main_rp=nullptr;
uint32_t swap_chain_count;
VkExtent2D extent;
uint32_t current_frame;
ObjectList<Framebuffer> render_frame;
@ -70,13 +74,13 @@ public:
SwapchainRenderTarget(Device *dev,Swapchain *sc);
~SwapchainRenderTarget();
const uint32_t GetImageCount()const{return swap_chain_count;}
const VkExtent2D & GetExtent()const{return extent;}
const VkRenderPass GetRenderPass()const override{return *main_rp;}
VkFramebuffer GetFramebuffer(const uint32_t index){return render_frame[index]->GetFramebuffer();}
RenderPass * GetRenderPass(){return main_rp;}
Framebuffer * GetFramebuffer(const uint32_t index){return render_frame[index];}
const uint32_t GetColorCount()const override{return 1;}
const uint32_t GetImageCount()const{return swap_chain_count;}
const uint32_t GetCurrentFrameIndices()const{return current_frame;}
const uint32_t GetCurrentFrameIndices()const{return current_frame;}
public:

View File

@ -57,14 +57,14 @@ bool CommandBuffer::Begin()
return(true);
}
bool CommandBuffer::BeginRenderPass(RenderPass *rp,Framebuffer *fb)
bool CommandBuffer::BeginRenderPass(VkRenderPass rp,VkFramebuffer fb)
{
VkRenderPassBeginInfo rp_begin;
rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rp_begin.pNext = nullptr;
rp_begin.renderPass = *rp;
rp_begin.framebuffer = fb->GetFramebuffer();
rp_begin.renderPass = rp;
rp_begin.framebuffer = fb;
rp_begin.renderArea = render_area;
rp_begin.clearValueCount = cv_count;
rp_begin.pClearValues = clear_values;

View File

@ -2,6 +2,8 @@
#include<hgl/graph/vulkan/VKDevice.h>
#include<hgl/graph/vulkan/VKMaterial.h>
#include<hgl/graph/vulkan/VKRenderPass.h>
#include<hgl/graph/vulkan/VKRenderTarget.h>
#include<hgl/graph/vulkan/VKFramebuffer.h>
VK_NAMESPACE_BEGIN
Pipeline::~Pipeline()
@ -65,10 +67,10 @@ void PipelineCreater::InitDynamicState()
//为什么一定要把ext放在这里因为如果不放在这里总是会让人遗忘它的重要性
PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass *rp,const VkExtent2D &ext)
PipelineCreater::PipelineCreater(Device *dev,const Material *material,const RenderTarget *rt)
{
device=dev->GetDevice();
extent=ext;
extent=rt->GetExtent();
cache=dev->GetPipelineCache();
//未来这里需要增加是否有vs/fs的检测
@ -146,7 +148,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
cba.srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
cba.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
colorBlendAttachments.Add(cba,rp->GetColorCount()); //这个需要和subpass中的color attachment数量相等所以添加多份
colorBlendAttachments.Add(cba,rt->GetColorCount()); //这个需要和subpass中的color attachment数量相等所以添加多份
alpha_blend=false;
@ -168,7 +170,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
pipelineInfo.layout = material->GetPipelineLayout();
{
pipelineInfo.renderPass = *rp;
pipelineInfo.renderPass = rt->GetRenderPass();
pipelineInfo.subpass = 0; //subpass由于还不知道有什么用所以暂时写0待知道功用后需改进
}
@ -178,12 +180,12 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
}
}
PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass *rp,const VkExtent2D &ext,uchar *data,uint size)
PipelineCreater::PipelineCreater(Device *dev,const Material *material,const RenderTarget *rt,uchar *data,uint size)
{
LoadFromMemory(data,size);
device=dev->GetDevice();
extent=ext;
extent=rt->GetExtent();
cache=dev->GetPipelineCache();
InitVertexInputState(material);
@ -202,7 +204,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
pipelineInfo.layout = material->GetPipelineLayout();
{
pipelineInfo.renderPass = *rp;
pipelineInfo.renderPass = rt->GetRenderPass();
pipelineInfo.subpass = 0; //subpass由于还不知道有什么用所以暂时写0待知道功用后需改进
}

View File

@ -1241,7 +1241,7 @@ namespace hgl
else
{
const float *sp=points;
float *vp=gc.GetVertexPointer();
float *vp=(float *)(vertex->Get());
for(uint i=0;i<8;i++)
{