convert two_triangle example to RenderList edition.

This commit is contained in:
hyzboy 2020-12-09 21:33:29 +08:00
parent fa0be2dfa8
commit 0c091a929a
4 changed files with 35 additions and 22 deletions

2
CMCore

@ -1 +1 @@
Subproject commit a6ca121707e249368d9fe5b0573ed50ed1684106
Subproject commit 162a6ce2f2cc5d24a177acf9b3c2ce9a0055e1f5

View File

@ -32,6 +32,9 @@ private:
Camera cam;
SceneNode render_root;
RenderList render_list;
MaterialInstance * material_instance =nullptr;
RenderableInstance *render_instance =nullptr;
GPUBuffer * ubo_world_matrix =nullptr;
@ -71,7 +74,7 @@ private:
material_instance->Update();
return(true);
}
bool InitVBO()
{
Renderable *render_obj=db->CreateRenderable(VERTEX_COUNT);
@ -81,6 +84,10 @@ private:
if(!render_obj->Set(VAN::Color, db->CreateVAB(VAF_VEC4,VERTEX_COUNT,color_data)))return(false);
render_instance=db->CreateRenderableInstance(render_obj,material_instance,pipeline);
render_root.Add(render_instance,scale(0.5,0.5));
render_root.RefreshMatrix();
render_root.ExpendToList(&render_list);
return(true);
}
@ -100,8 +107,7 @@ public:
if(!InitVBO())
return(false);
if(!BuildCommandBuffer(render_instance))
return(false);
BuildCommandBuffer(&render_list);
return(true);
}
@ -115,7 +121,7 @@ public:
ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(render_instance);
BuildCommandBuffer(&render_list);
}
};//class TestApp:public VulkanApplicationFramework

View File

@ -11,13 +11,13 @@ VK_NAMESPACE_BEGIN
*/
class RenderableInstance
{
Pipeline * pipeline;
MaterialInstance *mat_inst;
Renderable * render_obj;
Pipeline * pipeline;
MaterialInstance * mat_inst;
Renderable * render_obj;
uint32_t buffer_count;
VkBuffer *buffer_list;
VkDeviceSize *buffer_size;
uint32_t buffer_count;
VkBuffer * buffer_list;
VkDeviceSize * buffer_size;
private:
@ -29,19 +29,19 @@ public:
virtual ~RenderableInstance();
Pipeline * GetPipeline (){return pipeline;}
MaterialInstance * GetMaterialInstance (){return mat_inst;}
Renderable * GetRenderable (){return render_obj;}
const AABB & GetBoundingBox ()const{return render_obj->GetBoundingBox();}
Pipeline * GetPipeline (){return pipeline;}
MaterialInstance * GetMaterialInstance (){return mat_inst;}
Renderable * GetRenderable (){return render_obj;}
const AABB & GetBoundingBox ()const{return render_obj->GetBoundingBox();}
const uint32_t GetBufferCount ()const{return buffer_count;}
VkBuffer * GetBuffer ()const{return buffer_list;}
VkDeviceSize * GetBufferSize ()const{return buffer_size;}
IndexBuffer * GetIndexBuffer ()const{return render_obj->GetIndexBuffer();}
const uint32_t GetIndexBufferOffset ()const{return render_obj->GetIndexBufferOffset();}
const uint32_t GetDrawCount ()const{return render_obj->GetDrawCount();}
const uint32_t GetBufferCount ()const{return buffer_count;}
VkBuffer * GetBuffer ()const{return buffer_list;}
VkDeviceSize * GetBufferSize ()const{return buffer_size;}
IndexBuffer * GetIndexBuffer ()const{return render_obj->GetIndexBuffer();}
const uint32_t GetIndexBufferOffset()const{return render_obj->GetIndexBufferOffset();}
const uint32_t GetDrawCount ()const{return render_obj->GetDrawCount();}
DescriptorSets *GetDescriptorSets ()const{return mat_inst->GetDescriptorSets();}
DescriptorSets * GetDescriptorSets ()const{return mat_inst->GetDescriptorSets();}
public:

View File

@ -57,6 +57,11 @@ namespace hgl
void RenderList::End()
{
const uint32_t count=scene_node_list.GetCount();
for(SceneNode *node:scene_node_list)
{
}
}
void RenderList::Render(SceneNode *node,RenderableInstance *ri)
@ -126,6 +131,8 @@ namespace hgl
for(int i=0;i<count;i++)
{
// cmb_buf->....offset L2W Matrix
Render(*node,(*node)->renderable_instances);
++node;
}