supported new Comparator<> and ItemComparator<>
This commit is contained in:
parent
dd5a78cbaa
commit
6c160f5c53
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit ae1be856b96aa3d26da8937cca416e8fe4360678
|
||||
Subproject commit 7295d68a5e6f2b9bc9ad08dc397375850af50bf7
|
2
CMUtil
2
CMUtil
@ -1 +1 @@
|
||||
Subproject commit a7f4afab8029f52dff43840062c8b6cb2008bd67
|
||||
Subproject commit 6582b635c9b93284c29dd7e1bc6dc5ecf59a8705
|
@ -8,14 +8,14 @@ class RenderAssignBuffer;
|
||||
class SceneNode;
|
||||
struct CameraInfo;
|
||||
|
||||
struct RenderPipelineIndex
|
||||
struct RenderPipelineIndex:public Comparator<RenderPipelineIndex>
|
||||
{
|
||||
Material *material;
|
||||
Pipeline *pipeline;
|
||||
|
||||
public:
|
||||
|
||||
const int Comp(const RenderPipelineIndex &rli)const
|
||||
const int compare(const RenderPipelineIndex &rli)const override
|
||||
{
|
||||
if(material<rli.material)return(-1);
|
||||
if(material>rli.material)return(1);
|
||||
@ -26,8 +26,6 @@ public:
|
||||
return(0);
|
||||
}
|
||||
|
||||
CompOperator(const RenderPipelineIndex &,Comp)
|
||||
|
||||
public:
|
||||
|
||||
RenderPipelineIndex()
|
||||
|
@ -11,7 +11,7 @@ namespace hgl
|
||||
class MaterialInstance;
|
||||
class SceneNode;
|
||||
|
||||
struct RenderNode
|
||||
struct RenderNode:public Comparator<RenderNode>
|
||||
{
|
||||
uint index; ///<在MaterialRenderList中的索引
|
||||
|
||||
@ -22,6 +22,11 @@ namespace hgl
|
||||
|
||||
Vector3f world_position;
|
||||
float to_camera_distance;
|
||||
|
||||
public:
|
||||
|
||||
//该函数位于MaterialRenderList.cpp
|
||||
const int compare(const RenderNode &)const override;
|
||||
};
|
||||
|
||||
using RenderNodeList=List<RenderNode>;
|
||||
|
@ -12,7 +12,7 @@ VK_NAMESPACE_BEGIN
|
||||
* 原始图元数据缓冲区<Br>
|
||||
* 提供在渲染之前的数据绑定信息
|
||||
*/
|
||||
struct PrimitiveDataBuffer
|
||||
struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
||||
{
|
||||
uint32_t vab_count;
|
||||
VkBuffer * vab_list;
|
||||
@ -32,14 +32,14 @@ public:
|
||||
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
||||
~PrimitiveDataBuffer();
|
||||
|
||||
const bool Comp(const PrimitiveDataBuffer *pdb)const;
|
||||
const int compare(const PrimitiveDataBuffer &pdb)const override;
|
||||
};//struct PrimitiveDataBuffer
|
||||
|
||||
/**
|
||||
* 原始图元渲染数据<Br>
|
||||
* 提供在渲染时的数据
|
||||
*/
|
||||
struct PrimitiveRenderData
|
||||
struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
||||
{
|
||||
//因为要VAB是流式访问,所以我们这个结构会被用做排序依据
|
||||
//也因此,把vertex_offset放在最前面
|
||||
@ -59,9 +59,6 @@ public:
|
||||
vertex_offset =vo;
|
||||
first_index =fi;
|
||||
}
|
||||
|
||||
CompOperatorMemcmp(const PrimitiveRenderData &);
|
||||
CompOperatorMemcmpPointer(PrimitiveRenderData);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ namespace hgl
|
||||
/**
|
||||
* 字体信息
|
||||
*/
|
||||
struct Font
|
||||
struct Font:public ComparatorData<Font>
|
||||
{
|
||||
os_char name[MAX_FONT_NAME_LENGTH]; ///<字体名称
|
||||
|
||||
@ -28,8 +28,6 @@ namespace hgl
|
||||
|
||||
Font();
|
||||
Font(const os_char *,int,int,bool b=false,bool i=false,bool=true);
|
||||
|
||||
CompOperatorMemcmp(const Font &); ///<比较操作符重载
|
||||
};//struct Font
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -26,13 +26,13 @@
|
||||
这样就可以保证所有的渲染操作就算要切VBO,也不需要切换INDIRECT缓冲区,定位指令也很方便。
|
||||
*/
|
||||
|
||||
template<>
|
||||
int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &obj_one,const hgl::graph::RenderNode &obj_two) const
|
||||
VK_NAMESPACE_BEGIN
|
||||
const int RenderNode::compare(const RenderNode &other)const
|
||||
{
|
||||
hgl::int64 off;
|
||||
|
||||
hgl::graph::Renderable *ri_one=obj_one.scene_node->GetRenderable();
|
||||
hgl::graph::Renderable *ri_two=obj_two.scene_node->GetRenderable();
|
||||
hgl::graph::Renderable *ri_one=other.scene_node->GetRenderable();
|
||||
hgl::graph::Renderable *ri_two=scene_node->GetRenderable();
|
||||
|
||||
auto *prim_one=ri_one->GetPrimitive();
|
||||
auto *prim_two=ri_two->GetPrimitive();
|
||||
@ -63,8 +63,8 @@ int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &ob
|
||||
|
||||
//比较距离。。。。。。。。。。。。。。。。。。。。。还不知道这个是正了还是反了,等测出来确认后修改下面的返回值和这里的注释
|
||||
|
||||
float foff=obj_one.to_camera_distance
|
||||
-obj_two.to_camera_distance;
|
||||
float foff=other.to_camera_distance
|
||||
-to_camera_distance;
|
||||
|
||||
if(foff>0)
|
||||
return 1;
|
||||
@ -72,7 +72,6 @@ int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &ob
|
||||
return -1;
|
||||
}
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
MaterialRenderList::MaterialRenderList(GPUDevice *d,bool l2w,const RenderPipelineIndex &rpi)
|
||||
{
|
||||
device=d;
|
||||
@ -280,8 +279,8 @@ void MaterialRenderList::Stat()
|
||||
{
|
||||
ro=rn->scene_node->GetRenderable();
|
||||
|
||||
if(last_data_buffer->Comp(ro->GetDataBuffer()))
|
||||
if(last_render_data->_Comp(ro->GetRenderData())==0)
|
||||
if(*last_data_buffer!=*ro->GetDataBuffer())
|
||||
if(*last_render_data==*ro->GetRenderData())
|
||||
{
|
||||
++ri->instance_count;
|
||||
++rn;
|
||||
@ -399,7 +398,7 @@ void MaterialRenderList::ProcIndirectRender()
|
||||
|
||||
void MaterialRenderList::Render(RenderItem *ri)
|
||||
{
|
||||
if(!ri->pdb->Comp(last_data_buffer)) //换buf了
|
||||
if(*(ri->pdb)!=*last_data_buffer) //换buf了
|
||||
{
|
||||
if(indirect_draw_count) //如果有间接绘制的数据,赶紧给画了
|
||||
ProcIndirectRender();
|
||||
|
@ -24,25 +24,29 @@ PrimitiveDataBuffer::~PrimitiveDataBuffer()
|
||||
delete[] vab_list;
|
||||
}
|
||||
|
||||
const bool PrimitiveDataBuffer::Comp(const PrimitiveDataBuffer *pdb)const
|
||||
const int PrimitiveDataBuffer::compare(const PrimitiveDataBuffer &pdb)const
|
||||
{
|
||||
if(!pdb)return(false);
|
||||
ptrdiff_t off;
|
||||
|
||||
if(vdm&&pdb->vdm)
|
||||
return (vdm==pdb->vdm);
|
||||
off=&vdm-&pdb.vdm;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(vab_count!=pdb->vab_count)return(false);
|
||||
off=vab_count-pdb.vab_count;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
for(uint32_t i=0;i<vab_count;i++)
|
||||
{
|
||||
if(vab_list[i]!=pdb->vab_list[i])return(false);
|
||||
if(vab_offset[i]!=pdb->vab_offset[i])return(false);
|
||||
}
|
||||
off=hgl_cmp(vab_list,pdb.vab_list,vab_count);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(ibo!=pdb->ibo)
|
||||
return(false);
|
||||
off=hgl_cmp(vab_offset,pdb.vab_offset,vab_count);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
return(true);
|
||||
off=ibo-pdb.ibo;
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
Renderable::Renderable(Primitive *r,MaterialInstance *mi,Pipeline *p,PrimitiveDataBuffer *pdb,PrimitiveRenderData *prd)
|
||||
@ -61,7 +65,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
||||
|
||||
const VIL *vil=mi->GetVIL();
|
||||
|
||||
if(vil->Comp(p->GetVIL()))
|
||||
if(*vil!=*p->GetVIL())
|
||||
return(nullptr);
|
||||
|
||||
const uint32_t input_count=vil->GetVertexAttribCount(VertexInputGroup::Basic); //不统计Bone/LocalToWorld组的
|
||||
|
Loading…
x
Reference in New Issue
Block a user