fixed RenderList2D and third_triangle example.
This commit is contained in:
@@ -12,50 +12,31 @@ namespace hgl
|
||||
{
|
||||
/**
|
||||
* 渲染对象列表<br>
|
||||
* 已经展开的渲染对象列表,产生mvp用UBO/SSBO等数据,最终创建RenderCommandBuffer
|
||||
* 该类会长期保存使用过的材质信息,避重新分配造成的时间和空间浪费。如需彻底清空列表请使用Clear()函数
|
||||
*/
|
||||
class RenderList2D
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice * device;
|
||||
RenderCmdBuffer * cmd_buf;
|
||||
|
||||
private:
|
||||
|
||||
uint renderable_count; ///<可渲染对象数量
|
||||
|
||||
MaterialRenderMap2D mrl_map; ///<按材质分类的渲染列表
|
||||
|
||||
RenderNode2DComparator render_node_comparator;
|
||||
|
||||
private:
|
||||
|
||||
VkDescriptorSet ds_list[DESCRIPTOR_SET_TYPE_COUNT];
|
||||
DescriptorSet *renderable_desc_sets;
|
||||
uint renderable_count; ///<可渲染对象数量
|
||||
MaterialRenderMap2D mrl_map; ///<按材质分类的渲染列表
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool Begin();
|
||||
virtual bool ExpendNode(SceneNode *);
|
||||
virtual void End();
|
||||
|
||||
private:
|
||||
|
||||
Pipeline * last_pipeline;
|
||||
MaterialParameters *last_mp[DESCRIPTOR_SET_TYPE_COUNT];
|
||||
uint32_t last_vbo;
|
||||
|
||||
void Render(Renderable *);
|
||||
virtual bool ExpendNode(SceneNode *);
|
||||
|
||||
public:
|
||||
|
||||
RenderList2D(GPUDevice *);
|
||||
virtual ~RenderList2D();
|
||||
|
||||
virtual bool Expend(SceneNode *);
|
||||
virtual bool Expend(SceneNode *); ///<展开场景树到渲染列表
|
||||
|
||||
virtual bool Render(RenderCmdBuffer *);
|
||||
virtual bool Render(RenderCmdBuffer *); ///<渲染所有对象
|
||||
|
||||
virtual void Clear(); ///<彻底清理
|
||||
};//class RenderList2D
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -78,7 +78,7 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
MaterialRenderList2D(GPUDevice *d,RenderCmdBuffer *,Material *m);
|
||||
MaterialRenderList2D(GPUDevice *d,Material *m);
|
||||
~MaterialRenderList2D();
|
||||
|
||||
void Add(Renderable *ri,const Matrix3x4f &mat);
|
||||
@@ -90,7 +90,7 @@ namespace hgl
|
||||
|
||||
void End();
|
||||
|
||||
void Render();
|
||||
void Render(RenderCmdBuffer *);
|
||||
};
|
||||
|
||||
class MaterialRenderMap2D:public ObjectMap<Material *,MaterialRenderList2D>
|
||||
@@ -111,6 +111,14 @@ namespace hgl
|
||||
for(auto *it:data_list)
|
||||
it->value->End();
|
||||
}
|
||||
|
||||
void Render(RenderCmdBuffer *rcb)
|
||||
{
|
||||
if(!rcb)return;
|
||||
|
||||
for(auto *it:data_list)
|
||||
it->value->Render(rcb);
|
||||
}
|
||||
};
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
const bool Comp(const VertexInputData *vid)const
|
||||
{
|
||||
if(!vid)return(false);
|
||||
|
||||
if(binding_count!=vid->binding_count)return(false);
|
||||
|
||||
for(uint32_t i=0;i<binding_count;i++)
|
||||
@@ -75,10 +77,6 @@ public:
|
||||
const VertexInputData * GetVertexInputData ()const{return vertex_input;}
|
||||
|
||||
MaterialParameters *GetMP (const DescriptorSetType &type){return mat_inst->GetMP(type);}
|
||||
|
||||
public: //instance support
|
||||
|
||||
virtual const uint32_t GetInstanceCount ()const{return 1;}
|
||||
};//class Renderable
|
||||
|
||||
Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
Reference in New Issue
Block a user