optimized BuildCommandBuffer of VulkanAppFramework
This commit is contained in:
parent
0ecd947f8a
commit
e2b9983add
@ -141,6 +141,11 @@ public:
|
|||||||
virtual void MouseMove(){}
|
virtual void MouseMove(){}
|
||||||
virtual void MouseWheel(int,int,uint){}
|
virtual void MouseWheel(int,int,uint){}
|
||||||
|
|
||||||
|
void SetClearColor(COLOR cc)
|
||||||
|
{
|
||||||
|
clear_color.Use(cc,1.0);
|
||||||
|
}
|
||||||
|
|
||||||
void OnResize(int w,int h)
|
void OnResize(int w,int h)
|
||||||
{
|
{
|
||||||
if(w>0&&h>0)
|
if(w>0&&h>0)
|
||||||
@ -168,46 +173,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildCommandBuffer(RenderTarget *rt,RenderableInstance *ri)
|
bool BuildCommandBuffer(GPUCmdBuffer *cb,VkRenderPass rp,VkFramebuffer fb,RenderableInstance *ri)
|
||||||
{
|
|
||||||
if(!rt||!ri)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GPUCmdBuffer *cb=rt->GetCommandBuffer();
|
|
||||||
const IndexBuffer *ib=ri->GetIndexBuffer();
|
|
||||||
|
|
||||||
cb->Begin();
|
|
||||||
cb->BindFramebuffer(rt);
|
|
||||||
cb->BindPipeline(ri->GetPipeline());
|
|
||||||
cb->BindDescriptorSets(ri->GetDescriptorSets());
|
|
||||||
cb->BindVAB(ri);
|
|
||||||
|
|
||||||
if (ib)
|
|
||||||
cb->DrawIndexed(ib->GetCount());
|
|
||||||
else
|
|
||||||
cb->Draw(ri->GetDrawCount());
|
|
||||||
|
|
||||||
cb->EndRenderPass();
|
|
||||||
cb->End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetClearColor(COLOR cc)
|
|
||||||
{
|
|
||||||
clear_color.Use(cc,1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BuildCommandBuffer(uint32_t index,RenderableInstance *ri)
|
|
||||||
{
|
{
|
||||||
if(!ri)return(false);
|
if(!ri)return(false);
|
||||||
|
|
||||||
const IndexBuffer *ib=ri->GetIndexBuffer();
|
const IndexBuffer *ib=ri->GetIndexBuffer();
|
||||||
|
|
||||||
GPUCmdBuffer *cb=cmd_buf[index];
|
|
||||||
|
|
||||||
cb->SetClearColor(0,clear_color.r,clear_color.g,clear_color.b);
|
cb->SetClearColor(0,clear_color.r,clear_color.g,clear_color.b);
|
||||||
|
|
||||||
cb->Begin();
|
cb->Begin();
|
||||||
cb->BindFramebuffer(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
cb->BindFramebuffer(rp,fb);
|
||||||
cb->BindPipeline(ri->GetPipeline());
|
cb->BindPipeline(ri->GetPipeline());
|
||||||
cb->BindDescriptorSets(ri->GetDescriptorSets());
|
cb->BindDescriptorSets(ri->GetDescriptorSets());
|
||||||
cb->BindVAB(ri);
|
cb->BindVAB(ri);
|
||||||
@ -223,6 +198,21 @@ public:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuildCommandBuffer(RenderTarget *rt,RenderableInstance *ri)
|
||||||
|
{
|
||||||
|
if(!rt||!ri)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BuildCommandBuffer(rt->GetCommandBuffer(),rt->GetRenderPass(),rt->GetFramebuffer(),ri);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BuildCommandBuffer(uint32_t index,RenderableInstance *ri)
|
||||||
|
{
|
||||||
|
if(!ri)return(false);
|
||||||
|
|
||||||
|
return BuildCommandBuffer(cmd_buf[index],sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index),ri);
|
||||||
|
}
|
||||||
|
|
||||||
bool BuildCommandBuffer(RenderableInstance *ri)
|
bool BuildCommandBuffer(RenderableInstance *ri)
|
||||||
{
|
{
|
||||||
if(!ri)return(false);
|
if(!ri)return(false);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
template<typename ...ARGS> void BlitImage (ARGS...args){vkCmdBlitImage (cmd_buf,args...);}
|
template<typename ...ARGS> void BlitImage (ARGS...args){vkCmdBlitImage (cmd_buf,args...);}
|
||||||
|
|
||||||
bool BindFramebuffer(VkRenderPass rp,VkFramebuffer fb);
|
bool BindFramebuffer(VkRenderPass rp,VkFramebuffer fb);
|
||||||
bool BindFramebuffer(Framebuffer *);
|
// bool BindFramebuffer(Framebuffer *);
|
||||||
bool BindFramebuffer(RenderTarget *);
|
bool BindFramebuffer(RenderTarget *);
|
||||||
|
|
||||||
bool BindPipeline(Pipeline *p)
|
bool BindPipeline(Pipeline *p)
|
||||||
|
@ -93,10 +93,10 @@ bool GPUCmdBuffer::BindFramebuffer(VkRenderPass rp,VkFramebuffer fb)
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPUCmdBuffer::BindFramebuffer(Framebuffer *fbo)
|
//bool GPUCmdBuffer::BindFramebuffer(Framebuffer *fbo)
|
||||||
{
|
//{
|
||||||
return BindFramebuffer(fbo->GetRenderPass(),fbo->GetFramebuffer());
|
// return BindFramebuffer(fbo->GetRenderPass(),fbo->GetFramebuffer());
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool GPUCmdBuffer::BindFramebuffer(RenderTarget *rt)
|
bool GPUCmdBuffer::BindFramebuffer(RenderTarget *rt)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,GPUCm
|
|||||||
if(color_count>0)
|
if(color_count>0)
|
||||||
{
|
{
|
||||||
color_textures=new Texture2D *[color_count];
|
color_textures=new Texture2D *[color_count];
|
||||||
hgl_cpy<Texture2D *>(color_textures,ctl,color_count);
|
hgl_cpy(color_textures,ctl,color_count);
|
||||||
|
|
||||||
extent.width=color_textures[0]->GetWidth();
|
extent.width=color_textures[0]->GetWidth();
|
||||||
extent.height=color_textures[0]->GetHeight();
|
extent.height=color_textures[0]->GetHeight();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user