ULRE/inc/hgl/graph/VKPrimitiveData.h

102 lines
2.5 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;
};
2024-05-14 21:09:19 +08:00
inline bool Init(PrimitiveData *pd,const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0)
{
if(!pd)return(false);
if(!_vil)return(false);
if(vc<=0)return(false);
2024-05-14 21:09:19 +08:00
hgl_zero(*pd);
2024-05-14 21:09:19 +08:00
pd->vil=_vil;
pd->vertex_count=vc;
pd->ib_access.count=ic;
2024-05-14 21:09:19 +08:00
return(true);
}
2024-05-14 21:09:19 +08:00
inline int GetVABIndex(const PrimitiveData *pd,const AnsiString &name)
{
if(!pd)return(-1);
if(!pd->vil)return(-1);
if(name.IsEmpty())return(-1);
2024-05-14 21:09:19 +08:00
return pd->vil->GetIndex(name);
}
2024-05-14 21:09:19 +08:00
inline const VABAccess *GetVAB(const PrimitiveData *pd,const AnsiString &name)
{
if(!pd)return(nullptr);
if(name.IsEmpty())return(nullptr);
2024-05-14 21:09:19 +08:00
const int index=GetVABIndex(pd,name);
2024-05-14 21:09:19 +08:00
if(index==-1)
return(nullptr);
2024-05-14 21:09:19 +08:00
return pd->vab_access+index;
}
2024-05-14 21:09:19 +08:00
inline VABAccess *SetVAB(PrimitiveData *pd,const AnsiString &name,VAB *vab,VkDeviceSize start=0)
{
if(!pd)return(nullptr);
if(name.IsEmpty())return(nullptr);
2024-05-14 21:09:19 +08:00
const int index=GetVABIndex(pd,name);
2024-05-14 21:09:19 +08:00
if(index==-1)
return(nullptr);
2024-05-14 21:09:19 +08:00
VABAccess *vaba=pd->vab_access+index;
2024-05-14 21:09:19 +08:00
vaba->vab=vab;
vaba->start=start;
2024-05-14 21:09:19 +08:00
//#ifdef _DEBUG
// DebugUtils *du=device->GetDebugUtils();
2024-05-14 21:09:19 +08:00
// if(du)
// {
// du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
// du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
// }
//#endif//_DEBUG
2024-05-14 21:09:19 +08:00
return vaba;
}
2024-04-27 02:19:01 +08:00
2024-04-26 01:17:47 +08:00
VK_NAMESPACE_END