Merge branch 'devel_37_RenderFramework' of http://www.hyzgame.com:3000/hyzboy/ULRE into devel_37_RenderFramework
# Conflicts: # CMSceneGraph # CMUtil # inc/hgl/graph/module/GraphModule.h
This commit is contained in:
commit
7dd075b495
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 680b7717fc9253b138108b5f59b985f6bbc5b4e3
|
||||
Subproject commit 7295d68a5e6f2b9bc9ad08dc397375850af50bf7
|
@ -1 +1 @@
|
||||
Subproject commit 7bb7dbc31d3cb0d8556ce78d10243e852211326f
|
||||
Subproject commit 441ca9ce5558d6825c92c7dd1b9f93b80404fb41
|
2
CMUtil
2
CMUtil
@ -1 +1 @@
|
||||
Subproject commit 289cf37a6f893aa706988118b2d15edfb4f97dec
|
||||
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
|
||||
|
@ -1,12 +1,15 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using RenderPassHASHCode=util::HashCodeXXH3_128;
|
||||
#define CreateRenderPassHash util::CreateXXH3_128Hash
|
||||
using RenderPassHASHCode=util::HashCode<128/8>;
|
||||
inline util::Hash *CreateRenderPassHash()
|
||||
{
|
||||
return util::CreateHash(util::HASH::xxH3_128);
|
||||
}
|
||||
|
||||
class RenderPassManager:public GraphModule
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
@ -59,12 +59,15 @@ public: //事件
|
||||
|
||||
GraphModuleManager *GetGraphModuleManager(GPUDevice *);
|
||||
|
||||
class GraphModule
|
||||
class GraphModule:public Comparator<GraphModule>
|
||||
{
|
||||
GraphModuleManager *module_manager;
|
||||
|
||||
AnsiIDName module_name;
|
||||
|
||||
SortedSet<AnsiIDName> dependent_module; ///<依赖的模块
|
||||
|
||||
bool module_init;
|
||||
bool module_enable;
|
||||
bool module_ready;
|
||||
|
||||
@ -89,6 +92,9 @@ public:
|
||||
static const AnsiIDName * GetModuleName (){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
||||
virtual const AnsiIDName * GetName ()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
||||
|
||||
virtual const bool IsRender (){return false;} ///<是否为渲染模块
|
||||
|
||||
const bool IsInit ()const{return module_init;} ///<是否已经初始化
|
||||
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
|
||||
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
|
||||
|
||||
@ -99,7 +105,12 @@ public:
|
||||
GraphModule(GraphModuleManager *gmm,const AnsiIDName &name);
|
||||
virtual ~GraphModule();
|
||||
|
||||
virtual bool Init(){return true;} ///<初始化当前模块
|
||||
virtual bool Init(){module_init=true;return true;} ///<初始化当前模块
|
||||
|
||||
const int compare(const GraphModule &gm)const override
|
||||
{
|
||||
return(dependent_module.Contains(gm.module_name)?1:-1); //如果我依赖于他,那么我比他大
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
|
||||
@ -42,4 +42,4 @@ public:
|
||||
|
||||
#define REGISTRY_GRAPH_MODULE(Class) {RegistryGraphModuleFactory(#Class,new RegistryGraphModule<Class>);}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
VK_NAMESPACE_END
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
struct Material2DCreateConfig:public MaterialCreateConfig,public Comparator<Material2DCreateConfig>
|
||||
{
|
||||
CoordinateSystem2D coordinate_system; ///<使用的坐标系
|
||||
|
||||
@ -32,9 +32,9 @@ public:
|
||||
position_format=VAT_VEC2;
|
||||
}
|
||||
|
||||
int Comp(const Material2DCreateConfig &cfg)const
|
||||
const int compare(const Material2DCreateConfig &cfg)const override
|
||||
{
|
||||
int off=MaterialCreateConfig::Comp(cfg);
|
||||
int off=MaterialCreateConfig::compare(cfg);
|
||||
|
||||
if(off)return off;
|
||||
|
||||
@ -48,8 +48,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const Material2DCreateConfig &,Comp)
|
||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
|
||||
struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
struct Material3DCreateConfig:public MaterialCreateConfig,public Comparator<Material3DCreateConfig>
|
||||
{
|
||||
bool camera; ///<包含摄像机矩阵信息
|
||||
|
||||
@ -32,9 +32,9 @@ public:
|
||||
// reverse_depth=false;
|
||||
}
|
||||
|
||||
int Comp(const Material3DCreateConfig &cfg)const
|
||||
const int compare(const Material3DCreateConfig &cfg)const override
|
||||
{
|
||||
int off=MaterialCreateConfig::Comp(cfg);
|
||||
int off=MaterialCreateConfig::compare(cfg);
|
||||
|
||||
if(off)return off;
|
||||
|
||||
@ -48,8 +48,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const Material3DCreateConfig &,Comp)
|
||||
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor3D(const Material3DCreateConfig *);
|
||||
|
@ -13,7 +13,7 @@ class MaterialCreateInfo;
|
||||
/**
|
||||
* 材质配置结构
|
||||
*/
|
||||
struct MaterialCreateConfig
|
||||
struct MaterialCreateConfig:public Comparator<MaterialCreateConfig>
|
||||
{
|
||||
const GPUDeviceAttribute *dev_attr;
|
||||
|
||||
@ -42,7 +42,7 @@ public:
|
||||
prim=p;
|
||||
}
|
||||
|
||||
virtual int Comp(const MaterialCreateConfig &cfg)const
|
||||
const int compare(const MaterialCreateConfig &cfg)const override
|
||||
{
|
||||
int off;
|
||||
|
||||
@ -59,8 +59,6 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
CompOperator(const MaterialCreateConfig &,Comp)
|
||||
};//struct MaterialCreateConfig
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include<hgl/graph/VKInterpolation.h>
|
||||
#include<hgl/graph/VKSamplerType.h>
|
||||
#include<hgl/graph/VKImageType.h>
|
||||
#include<hgl/CompOperator.h>
|
||||
#include<hgl/Comparator.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace hgl
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct ShaderVariableType
|
||||
struct ShaderVariableType:public Comparator<ShaderVariableType>
|
||||
{
|
||||
union
|
||||
{
|
||||
@ -158,9 +158,7 @@ namespace hgl
|
||||
|
||||
const bool Check()const;
|
||||
|
||||
int Comp(const ShaderVariableType &svt)const;
|
||||
|
||||
CompOperator(const ShaderVariableType &,Comp)
|
||||
const int compare(const ShaderVariableType &svt)const override;
|
||||
|
||||
const char *GetTypename()const;
|
||||
|
||||
@ -281,7 +279,7 @@ namespace hgl
|
||||
|
||||
using SVList=List<ShaderVariable>;
|
||||
|
||||
struct ShaderVariableArray
|
||||
struct ShaderVariableArray:public Comparator<ShaderVariableArray>
|
||||
{
|
||||
uint count;
|
||||
|
||||
@ -304,44 +302,36 @@ namespace hgl
|
||||
Clear();
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableArray *sva)const
|
||||
const int compare(const ShaderVariableArray &sva)const override
|
||||
{
|
||||
if(!sva)
|
||||
return 1;
|
||||
|
||||
int off=count-sva->count;
|
||||
int off=count-sva.count;
|
||||
if(off)return off;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
off=items[i].location-sva->items[i].location;
|
||||
off=items[i].location-sva.items[i].location;
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
if(items[i].type.ToCode()>sva->items[i].type.ToCode())
|
||||
if(items[i].type.ToCode()>sva.items[i].type.ToCode())
|
||||
return 1;
|
||||
|
||||
//ToCode返回的是uint64,可能差值超大,所以不能直接用-的结果
|
||||
|
||||
if(items[i].type.ToCode()<sva->items[i].type.ToCode())
|
||||
if(items[i].type.ToCode()<sva.items[i].type.ToCode())
|
||||
return -1;
|
||||
|
||||
off=int(items[i].interpolation)-int(sva->items[i].interpolation);
|
||||
off=int(items[i].interpolation)-int(sva.items[i].interpolation);
|
||||
if(off)
|
||||
return off;
|
||||
|
||||
off=hgl::strcmp(items[i].name,sva->items[i].name);
|
||||
off=hgl::strcmp(items[i].name,sva.items[i].name);
|
||||
if(off)
|
||||
return off;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableArray &sva)const{return Comp(&sva);}
|
||||
|
||||
CompOperator(const ShaderVariableArray *,Comp)
|
||||
CompOperator(const ShaderVariableArray &,Comp)
|
||||
|
||||
bool Init(const uint c=0)
|
||||
{
|
||||
|
@ -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组的
|
||||
|
@ -85,7 +85,7 @@ const bool ShaderVariableType::Check()const
|
||||
return(true);
|
||||
}
|
||||
|
||||
int ShaderVariableType::Comp(const ShaderVariableType &svt)const
|
||||
const int ShaderVariableType::compare(const ShaderVariableType &svt)const
|
||||
{
|
||||
int off=(int)base_type-(int)svt.base_type;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user