ULRE/inc/hgl/graph/VKPrimitive.h

83 lines
1.8 KiB
C
Raw Normal View History

2022-06-24 17:51:39 +08:00
#ifndef HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
#define HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
#include<hgl/graph/VKIndexBuffer.h>
#include<hgl/type/Map.h>
#include<hgl/type/String.h>
#include<hgl/math/Math.h>
#include<hgl/graph/AABB.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
2022-06-24 17:51:39 +08:00
VK_NAMESPACE_BEGIN
2024-04-24 01:38:55 +08:00
struct PrimitiveData
{
uint32_t vertex_count;
uint32_t va_count;
VABAccess *vab_list;
IndexBufferAccess ib_access;
2024-04-24 01:38:55 +08:00
AABB BoundingBox;
};
2022-06-24 17:51:39 +08:00
/**
*
*/
class Primitive
{
2023-10-12 05:55:39 +08:00
GPUDevice *device;
AnsiString prim_name;
2022-06-24 17:51:39 +08:00
protected:
uint32_t vertex_count;
2022-06-24 17:51:39 +08:00
2024-04-24 01:38:55 +08:00
VABAccessMap buffer_list;
2022-06-24 17:51:39 +08:00
IndexBufferAccess ib_access;
2022-06-24 17:51:39 +08:00
AABB BoundingBox;
protected:
friend class RenderableNode;
uint ref_count=0;
uint RefInc(){return ++ref_count;}
uint RefDec(){return --ref_count;}
public:
2023-10-12 05:55:39 +08:00
Primitive(GPUDevice *dev,const AnsiString &n,const uint32_t vc=0)
{
device=dev;
prim_name=n;
vertex_count=vc;
}
2022-06-24 17:51:39 +08:00
virtual ~Primitive()=default;
const uint GetRefCount()const{return ref_count;}
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
2022-06-24 17:51:39 +08:00
const AABB & GetBoundingBox()const {return BoundingBox;}
2024-04-24 01:38:55 +08:00
bool Set(const AnsiString &name,VAB *vb,VkDeviceSize offset=0);
2022-06-24 17:51:39 +08:00
2023-10-12 05:55:39 +08:00
bool Set(IndexBuffer *ib,VkDeviceSize offset=0);
2022-06-24 17:51:39 +08:00
public:
const uint32_t GetVertexCount ()const {return vertex_count;}
2022-06-24 17:51:39 +08:00
2024-04-24 01:44:01 +08:00
bool GetVABAccess (const AnsiString &,VABAccess *);
const int GetBufferCount ()const {return buffer_list.GetCount();}
2022-06-24 17:51:39 +08:00
const IndexBufferAccess * GetIndexBufferAccess()const {return &ib_access;}
2022-06-24 17:51:39 +08:00
};//class Primitive
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE