moved relationship to RenderableInstance whose the Material and Renderable.
This commit is contained in:
@@ -46,18 +46,19 @@ class TestApp:public VulkanApplicationFramework
|
||||
private:
|
||||
|
||||
vulkan::PipelineData * pipeline_data =nullptr;;
|
||||
vulkan::Renderable * render_obj =nullptr;
|
||||
|
||||
struct MP
|
||||
{
|
||||
vulkan::Material * material =nullptr;
|
||||
vulkan::Pipeline * pipeline =nullptr;
|
||||
vulkan::Renderable * render_obj =nullptr;
|
||||
}mp_normal,mp_hq;
|
||||
|
||||
struct MIR
|
||||
{
|
||||
MP * mp =nullptr;
|
||||
vulkan::MaterialInstance * material_instance =nullptr;
|
||||
vulkan::RenderableInstance *renderable_instance =nullptr;
|
||||
}mir_nearest,mir_linear,mir_nearest_hq,mir_linear_hq;
|
||||
|
||||
vulkan::Texture2D * texture =nullptr;
|
||||
@@ -99,6 +100,18 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitRenderObject()
|
||||
{
|
||||
render_obj=db->CreateRenderable(VERTEX_COUNT);
|
||||
if(!render_obj)return(false);
|
||||
|
||||
render_obj->Set(VAN::Position,vertex_buffer);
|
||||
render_obj->Set(VAN::TexCoord,tex_coord_buffer);
|
||||
render_obj->Set(index_buffer);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
vulkan::Sampler *InitSampler(VkFilter filter)
|
||||
{
|
||||
VkSamplerCreateInfo sampler_create_info;
|
||||
@@ -139,11 +152,6 @@ private:
|
||||
mp->pipeline=CreatePipeline(mp->material,pipeline_data);
|
||||
if(!mp->pipeline)return(false);
|
||||
|
||||
mp->render_obj=db->CreateRenderable(mp->material,VERTEX_COUNT);
|
||||
mp->render_obj->Set(VAN::Position,vertex_buffer);
|
||||
mp->render_obj->Set(VAN::TexCoord,tex_coord_buffer);
|
||||
mp->render_obj->Set(index_buffer);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -168,18 +176,17 @@ private:
|
||||
|
||||
mir->mp=mp;
|
||||
|
||||
mir->renderable_instance=db->CreateRenderableInstance(render_obj,mir->material_instance,mp->pipeline);
|
||||
|
||||
if(!mir->renderable_instance)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Add(struct MIR *mir,const Matrix4f &offset)
|
||||
{
|
||||
RenderableInstance *ri=db->CreateRenderableInstance(mir->mp->pipeline,
|
||||
mir->material_instance,
|
||||
mir->mp->render_obj);
|
||||
|
||||
if(!ri)return(false);
|
||||
|
||||
render_root.Add(ri,offset);
|
||||
render_root.Add(mir->renderable_instance,offset);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@@ -207,6 +214,9 @@ public:
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
if(!InitRenderObject())
|
||||
return(false);
|
||||
|
||||
if(!InitTexture())
|
||||
return(false);
|
||||
|
||||
|
@@ -173,39 +173,39 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32_t index,vulkan::Pipeline *p,vulkan::MaterialInstance *mi,vulkan::Renderable *r)
|
||||
void BuildCommandBuffer(uint32_t index,vulkan::RenderableInstance *ri)
|
||||
{
|
||||
if(!p||!mi||!r)
|
||||
if(!ri)
|
||||
return;
|
||||
|
||||
const vulkan::IndexBuffer *ib=r->GetIndexBuffer();
|
||||
const vulkan::IndexBuffer *ib=ri->GetIndexBuffer();
|
||||
|
||||
vulkan::CommandBuffer *cb=cmd_buf[index];
|
||||
|
||||
cb->Begin();
|
||||
cb->BeginRenderPass(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
||||
cb->Bind(p);
|
||||
cb->Bind(mi->GetDescriptorSets());
|
||||
cb->Bind(r);
|
||||
cb->BeginRenderPass(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
||||
cb->BindPipeline(ri->GetPipeline());
|
||||
cb->BindDescriptorSets(ri->GetDescriptorSets());
|
||||
cb->BindVAB(ri);
|
||||
|
||||
if (ib)
|
||||
cb->DrawIndexed(ib->GetCount());
|
||||
else
|
||||
cb->Draw(r->GetDrawCount());
|
||||
if (ib)
|
||||
cb->DrawIndexed(ib->GetCount());
|
||||
else
|
||||
cb->Draw(ri->GetDrawCount());
|
||||
|
||||
cb->EndRenderPass();
|
||||
cb->EndRenderPass();
|
||||
cb->End();
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(vulkan::Pipeline *p,vulkan::MaterialInstance *mi,vulkan::Renderable *r)
|
||||
void BuildCommandBuffer(vulkan::RenderableInstance *ri)
|
||||
{
|
||||
for(int32_t i=0;i<swap_chain_count;i++)
|
||||
BuildCommandBuffer(i,p,mi,r);
|
||||
BuildCommandBuffer(i,ri);
|
||||
}
|
||||
|
||||
void BuildCurrentCommandBuffer(vulkan::Pipeline *p,vulkan::MaterialInstance *mi,vulkan::Renderable *r)
|
||||
void BuildCurrentCommandBuffer(vulkan::RenderableInstance *ri)
|
||||
{
|
||||
BuildCommandBuffer(sc_render_target->GetCurrentFrameIndices(),p,mi,r);
|
||||
BuildCommandBuffer(sc_render_target->GetCurrentFrameIndices(),ri);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32_t index,RenderList *rl)
|
||||
|
Reference in New Issue
Block a user