to set few functions to private in VKPrimitive

This commit is contained in:
hyzboy 2024-04-27 03:09:16 +08:00
parent 21a63f4a9b
commit 6ad3b9edb7
10 changed files with 137 additions and 75 deletions

View File

@ -4,6 +4,8 @@
#include<hgl/graph/VKRenderResource.h>
#include<hgl/graph/VertexAttribDataAccess.h>
#include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKIndexBuffer.h>
namespace hgl
{
namespace graph

View File

@ -59,6 +59,20 @@ struct VertexInputData;
class VertexAttribBuffer;
using VAB=VertexAttribBuffer;
struct VABAccess
{
VAB *vab;
VkDeviceSize start;
void *map_ptr;
public:
CompOperatorMemcmp(const VABAccess &);
};//class VABAccess
using VABAccessMap=Map<AnsiString,VABAccess>;
class IndexBuffer;
struct IndexBufferAccess

View File

@ -3,9 +3,11 @@
#include<hgl/type/Map.h>
#include<hgl/type/String.h>
#include<hgl/math/Math.h>
#include<hgl/graph/VKPrimitiveData.h>
#include<hgl/graph/AABB.h>
#include<hgl/graph/VK.h>
VK_NAMESPACE_BEGIN
/**
*
*/
@ -26,7 +28,14 @@ protected:
protected:
friend class RenderableNode;
bool SetVAB(const AnsiString &name,VAB *vb,VkDeviceSize start=0);
bool SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count);
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
friend class PrimitiveCreater;
friend class RenderablePrimitiveCreater;
public:
@ -39,22 +48,14 @@ public:
virtual ~Primitive()=default;
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
const AABB & GetBoundingBox()const {return BoundingBox;}
bool SetVAB(const AnsiString &name,VAB *vb,VkDeviceSize start=0);
bool SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count);
public:
const VkDeviceSize GetVertexCount ()const {return vertex_count;}
const VkDeviceSize GetVertexCount ()const{return vertex_count;}
const int GetVACount ()const{return buffer_list.GetCount();}
const bool GetVABAccess (const AnsiString &,VABAccess *);
const IBAccess * GetIBAccess ()const{return ib_access.buffer?&ib_access:nullptr;}
const int GetBufferCount ()const {return buffer_list.GetCount();}
bool GetVABAccess (const AnsiString &,VABAccess *);
const IBAccess * GetIBAccess ()const {return ib_access.buffer?&ib_access:nullptr;}
const AABB & GetBoundingBox ()const{return BoundingBox;}
};//class Primitive
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE

View File

@ -1,46 +1,101 @@
#pragma once
#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处理
*/
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;
};//struct PrimitiveData
constexpr const uint PRIMITIVE_DATA_SIZE=sizeof(PrimitiveData);
//
//#include<hgl/graph/VKVertexAttribBuffer.h>
//#include<hgl/graph/VKIndexBuffer.h>
//#include<hgl/graph/AABB.h>
//
//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<va_count;i++)
// {
// if(hgl::strcmp(vab_list[i].va_name,name)==0)
// return(i);
// }
//
// return(-1);
// }
//
// VABAccess *GetVAB(const char *name)
// {
// if(!name||!*name)
// return(nullptr);
//
// const int index=GetVABIndex(name);
//
// if(index==-1)
// return(nullptr);
//
// return &(vab_list[index].vab_access);
// }
//
// 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);
VK_NAMESPACE_END

View File

@ -36,20 +36,6 @@ namespace hgl
};//class VertexAttribBuffer:public DeviceBuffer
using VAB=VertexAttribBuffer;
struct VABAccess
{
VAB *vab;
VkDeviceSize start;
void *map_ptr;
public:
CompOperatorMemcmp(const VABAccess &);
};//class VABAccess
using VABAccessMap=Map<AnsiString,VABAccess>;
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE

View File

@ -1,6 +1,7 @@
#include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKPrimitive.h>
#include<hgl/graph/VertexDataManager.h>
namespace hgl

View File

@ -4,6 +4,7 @@
#include<hgl/graph/VKRenderable.h>
#include<hgl/graph/VKDeviceAttribute.h>
#include<hgl/graph/VKPhysicalDevice.h>
#include<hgl/graph/VKIndexBuffer.h>
VK_NAMESPACE_BEGIN
RenderCmdBuffer::RenderCmdBuffer(const GPUDeviceAttribute *attr,VkCommandBuffer cb):GPUCmdBuffer(attr,cb)

View File

@ -2,6 +2,7 @@
#include<hgl/graph/VKBuffer.h>
#include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKIndexBuffer.h>
#ifdef _DEBUG
#include<hgl/graph/VKDevice.h>
@ -52,7 +53,7 @@ bool Primitive::SetVAB(const AnsiString &name,VAB *vab,VkDeviceSize start)
return(true);
}
bool Primitive::GetVABAccess(const AnsiString &name,VABAccess *vad)
const bool Primitive::GetVABAccess(const AnsiString &name,VABAccess *vad)
{
if(name.IsEmpty())return(false);
if(!vad)return(false);

View File

@ -3,6 +3,7 @@
#include<hgl/graph/VKRenderable.h>
#include<hgl/graph/VKInlinePipeline.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKIndexBuffer.h>
VK_NAMESPACE_BEGIN
VAB *RenderResource::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode)

View File

@ -51,7 +51,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
const uint32_t input_count=vil->GetCount(VertexInputGroup::Basic); //不统计Bone/LocalToWorld组的
const UTF8String &mtl_name=mi->GetMaterial()->GetName();
if(prim->GetBufferCount()<input_count) //小于材质要求的数量?那自然是不行的
if(prim->GetVACount()<input_count) //小于材质要求的数量?那自然是不行的
{
LOG_ERROR("[FATAL ERROR] input buffer count of Renderable lesser than Material, Material name: "+mtl_name);