ULRE/inc/hgl/graph/VKPrimitiveData.h

95 lines
2.4 KiB
C
Raw Normal View History

2024-04-26 01:17:47 +08:00
#pragma once
2024-05-14 21:09:19 +08:00
#include<hgl/graph/VKVertexInputLayout.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKIndexBuffer.h>
#include<hgl/graph/AABB.h>
VK_NAMESPACE_BEGIN
/*
1.2024.4.27vulkan.gpuinfo.org统计9%maxVertexInputAttributes为1616
9.0%28 - 31
70.7%32
9.6%64
使16使16
()
2.va_name使用char[][]String以及动态分配内存
memcpy处理
*/
constexpr const uint HGL_MAX_VERTEX_ATTRIB_COUNT=16; ///<最大顶点属性数量
struct PrimitiveData
{
const VIL * vil;
VkDeviceSize vertex_count;
VABAccess vab_access[HGL_MAX_VERTEX_ATTRIB_COUNT];
IBAccess ib_access;
AABB BoundingBox;
public:
PrimitiveData(const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0,const IndexType &it=IndexType::AUTO)
{
Clear();
vil=_vil;
vertex_count=vc;
ib_access.count=ic;
}
void Clear()
{
hgl_zero(*this);
}
2024-05-16 20:58:44 +08:00
const int GetVABIndex(const AnsiString &name)const{return vil->GetIndex(name);}
2024-05-14 21:09:19 +08:00
2024-05-16 20:58:44 +08:00
VABAccess *GetVAB(const AnsiString &name)
2024-05-14 21:09:19 +08:00
{
const int index=GetVABIndex(name);
if(index==-1)
return(nullptr);
2024-05-16 20:58:44 +08:00
return vab_access+index;
2024-05-14 21:09:19 +08:00
}
const int AddVAB(const char *name,VAB *vab,VkDeviceSize start=0)
{
if(va_count>=HGL_MAX_VERTEX_ATTRIB_COUNT)
return(-1);
VABAccessInfo *vai=vab_list+va_count;
hgl::strcpy(vai->va_name,VERTEX_ATTRIB_NAME_MAX_LENGTH,name);
vai->vab_access.vab=vab;
vai->vab_access.start=start;
#ifdef _DEBUG
DebugUtils *du=device->GetDebugUtils();
if(du)
{
du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
}
#endif//_DEBUG
return(va_count++);
}
};//struct PrimitiveData
constexpr const uint PRIMITIVE_DATA_SIZE=sizeof(PrimitiveData);
2024-04-27 02:19:01 +08:00
2024-04-26 01:17:47 +08:00
VK_NAMESPACE_END