VKPrimitiveData change to C version. next step is change to pure virtual struct.

This commit is contained in:
hyzboy 2024-05-20 02:12:13 +08:00
parent 3af753ee36
commit 6892a64393
2 changed files with 49 additions and 42 deletions

View File

@ -3,7 +3,7 @@
#include<hgl/type/Map.h> #include<hgl/type/Map.h>
#include<hgl/type/String.h> #include<hgl/type/String.h>
#include<hgl/graph/AABB.h> #include<hgl/graph/AABB.h>
#include<hgl/graph/VK.h> #include<hgl/graph/VKPrimitiveData.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN

View File

@ -31,64 +31,71 @@ struct PrimitiveData
VABAccess vab_access[HGL_MAX_VERTEX_ATTRIB_COUNT]; VABAccess vab_access[HGL_MAX_VERTEX_ATTRIB_COUNT];
IBAccess ib_access; IBAccess ib_access;
};
AABB BoundingBox; 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);
public: hgl_zero(*pd);
PrimitiveData(const VIL *_vil,const VkDeviceSize vc,const VkDeviceSize ic=0,const IndexType &it=IndexType::AUTO) pd->vil=_vil;
{ pd->vertex_count=vc;
Clear(); pd->ib_access.count=ic;
vil=_vil; return(true);
}
vertex_count=vc; inline int GetVABIndex(const PrimitiveData *pd,const AnsiString &name)
{
if(!pd)return(-1);
if(!pd->vil)return(-1);
if(name.IsEmpty())return(-1);
ib_access.count=ic; return pd->vil->GetIndex(name);
} }
void Clear() inline const VABAccess *GetVAB(const PrimitiveData *pd,const AnsiString &name)
{ {
hgl_zero(*this); if(!pd)return(nullptr);
} if(name.IsEmpty())return(nullptr);
const int GetVABIndex(const AnsiString &name)const{return vil->GetIndex(name);} const int index=GetVABIndex(pd,name);
VABAccess *GetVAB(const AnsiString &name)
{
const int index=GetVABIndex(name);
if(index==-1) if(index==-1)
return(nullptr); return(nullptr);
return vab_access+index; return pd->vab_access+index;
} }
const int AddVAB(const char *name,VAB *vab,VkDeviceSize start=0) inline VABAccess *SetVAB(PrimitiveData *pd,const AnsiString &name,VAB *vab,VkDeviceSize start=0)
{ {
if(va_count>=HGL_MAX_VERTEX_ATTRIB_COUNT) if(!pd)return(nullptr);
return(-1); if(name.IsEmpty())return(nullptr);
VABAccessInfo *vai=vab_list+va_count; const int index=GetVABIndex(pd,name);
hgl::strcpy(vai->va_name,VERTEX_ATTRIB_NAME_MAX_LENGTH,name); if(index==-1)
vai->vab_access.vab=vab; return(nullptr);
vai->vab_access.start=start;
#ifdef _DEBUG VABAccess *vaba=pd->vab_access+index;
DebugUtils *du=device->GetDebugUtils();
if(du) vaba->vab=vab;
{ vaba->start=start;
du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
}
#endif//_DEBUG
return(va_count++); //#ifdef _DEBUG
} // DebugUtils *du=device->GetDebugUtils();
};//struct PrimitiveData
constexpr const uint PRIMITIVE_DATA_SIZE=sizeof(PrimitiveData); // if(du)
// {
// du->SetBuffer(vab->GetBuffer(),prim_name+":VAB:Buffer:"+name);
// du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VAB:Memory:"+name);
// }
//#endif//_DEBUG
return vaba;
}
VK_NAMESPACE_END VK_NAMESPACE_END