From f31437bf677d63980204ec23be7154b0c5d8c878 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 14 May 2024 21:09:19 +0800 Subject: [PATCH] remove VABView --- inc/hgl/graph/VK.h | 2 - inc/hgl/graph/VKPrimitive.h | 7 +- inc/hgl/graph/VKPrimitiveData.h | 201 ++++++++++++++------------- inc/hgl/graph/VKVertexAttribBuffer.h | 15 -- 4 files changed, 109 insertions(+), 116 deletions(-) diff --git a/inc/hgl/graph/VK.h b/inc/hgl/graph/VK.h index 7d95d310..e256e831 100644 --- a/inc/hgl/graph/VK.h +++ b/inc/hgl/graph/VK.h @@ -73,8 +73,6 @@ public: using VABAccessMap=Map; -class VABView; - class IndexBuffer; struct IndexBufferAccess diff --git a/inc/hgl/graph/VKPrimitive.h b/inc/hgl/graph/VKPrimitive.h index bd7534ca..fce81027 100644 --- a/inc/hgl/graph/VKPrimitive.h +++ b/inc/hgl/graph/VKPrimitive.h @@ -8,7 +8,12 @@ VK_NAMESPACE_BEGIN /** - * 单一图元数据 + * 单一图元数据访问接口
+ * + * 这个只是单纯的提供原始VAB/IB数据,派生为两类 + * + * 一类是传统的,使用独统的独立VAB的 + * 一类是使用VDM的 */ class Primitive { diff --git a/inc/hgl/graph/VKPrimitiveData.h b/inc/hgl/graph/VKPrimitiveData.h index 7a3f7663..aa836db0 100644 --- a/inc/hgl/graph/VKPrimitiveData.h +++ b/inc/hgl/graph/VKPrimitiveData.h @@ -1,101 +1,106 @@ #pragma once -// -//#include -//#include -//#include -// -//VK_NAMESPACE_BEGIN -// -///* -// 1.截止2024.4.27,根据vulkan.gpuinfo.org统计,只有9%的设备maxVertexInputAttributes为16,不存在低于16的设备。 -// 9.0%的设备为28 - 31 -// 70.7%的设备为32 -// 9.6%的设备为64 -// -// 由于我们暂时没有发现需要使用16个以上属性的情况,所以这里暂定使用16。 -// (如果时间过去久远,可再次查询此值是否可改成更高的值,以及是否需要) -// -// 2.为何va_name使用char[][]而不是String以及动态分配内存? -// -// 就是为了必避动态分配内存,以及可以直接memcpy处理,所以此处这样定义。 -//*/ -// -//struct VABAccessInfo -//{ -// char va_name[VERTEX_ATTRIB_NAME_MAX_LENGTH+1]; -// VABAccess vab_access; -//}; -// -//constexpr const uint HGL_MAX_VERTEX_ATTRIB_COUNT=16; ///<最大顶点属性数量 -// -//struct PrimitiveData -//{ -// VkDeviceSize vertex_count; -// -// uint32_t va_count; -// -// VABAccessInfo vab_list[HGL_MAX_VERTEX_ATTRIB_COUNT]; -// -// IBAccess ib_access; -// -// AABB BoundingBox; -// -//public: -// -// void Clear() -// { -// hgl_zero(*this); -// } -// -// const int GetVABIndex(const char *name)const -// { -// for(int i=0;i=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); + +#include +#include +#include +#include + +VK_NAMESPACE_BEGIN + +/* + 1.截止2024.4.27,根据vulkan.gpuinfo.org统计,只有9%的设备maxVertexInputAttributes为16,不存在低于16的设备。 + 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); + } + + const int GetVABIndex(const char *name)const + { + for(int i=0;i=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); VK_NAMESPACE_END diff --git a/inc/hgl/graph/VKVertexAttribBuffer.h b/inc/hgl/graph/VKVertexAttribBuffer.h index 25d28c47..2958e8f3 100644 --- a/inc/hgl/graph/VKVertexAttribBuffer.h +++ b/inc/hgl/graph/VKVertexAttribBuffer.h @@ -36,21 +36,6 @@ namespace hgl };//class VertexAttribBuffer:public DeviceBuffer using VAB=VertexAttribBuffer; - - class VABView - { - public: - - VABView()=default; - virtual ~VABView()=default; - - virtual VAB *GetVAB()=0; - virtual VkDeviceSize GetStart()const=0; - virtual VkDeviceSize GetSize()const=0; - - virtual void *Map()=0; - virtual void Unmap()=0; - };//class VABView }//namespace graph }//namespace hgl #endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE