moved codes to .cpp from VKArrayBuffer.h
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKMemoryAllocator.h>
|
||||
#include<hgl/type/Collection.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
namespace hgl
|
||||
{
|
||||
class Collection;
|
||||
|
||||
namespace graph
|
||||
{
|
||||
class VKMemoryAllocator;
|
||||
|
||||
/**
|
||||
* GPU数据阵列缓冲区<br>
|
||||
* 它用于储存多份相同格式的数据,常用于多物件渲染,instance等
|
||||
@@ -30,66 +31,18 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
GPUArrayBuffer(GPUDevice *dev,VkBufferUsageFlags flags,const uint il)
|
||||
{
|
||||
device=dev;
|
||||
buffer_usage_flags=flags;
|
||||
item_length=il;
|
||||
GPUArrayBuffer(GPUDevice *dev,VkBufferUsageFlags flags,const uint il);
|
||||
virtual ~GPUArrayBuffer();
|
||||
|
||||
{
|
||||
ubo_offset_alignment=device->GetUBOAlign();
|
||||
const uint32_t GetOffsetAlignment()const{return ubo_offset_alignment;}
|
||||
const uint32_t GetUnitSize()const;
|
||||
DeviceBuffer * GetBuffer();
|
||||
|
||||
const uint32_t unit_size=hgl_align<uint32_t>(item_length,ubo_offset_alignment);
|
||||
uint32 Alloc(const uint32 max_count); ///<预分配空间
|
||||
void Clear();
|
||||
|
||||
vk_ma=new VKMemoryAllocator(device,buffer_usage_flags,unit_size); // construct function is going to set AllocUnitSize by minUniformOffsetAlignment
|
||||
MemoryBlock *mb=new MemoryBlock(vk_ma);
|
||||
|
||||
coll=new Collection(unit_size,mb);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~GPUArrayBuffer()
|
||||
{
|
||||
delete coll;
|
||||
}
|
||||
|
||||
const uint32_t GetOffsetAlignment()const
|
||||
{
|
||||
return ubo_offset_alignment;
|
||||
}
|
||||
|
||||
const uint32_t GetUnitSize()const
|
||||
{
|
||||
return coll->GetUnitBytes();
|
||||
}
|
||||
|
||||
DeviceBuffer *GetBuffer()
|
||||
{
|
||||
return vk_ma->GetBuffer();
|
||||
}
|
||||
|
||||
uint32 Alloc(const uint32 max_count) ///<预分配空间
|
||||
{
|
||||
if(!coll->Alloc(max_count))
|
||||
return(0);
|
||||
|
||||
return coll->GetAllocCount();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
coll->Clear();
|
||||
}
|
||||
|
||||
void *Map(const uint32 start,const uint32 count)
|
||||
{
|
||||
return coll->Map(start,count);
|
||||
}
|
||||
|
||||
void Flush(const uint32 count)
|
||||
{
|
||||
vk_ma->Flush(count*GetUnitSize());
|
||||
}
|
||||
void * Map(const uint32 start,const uint32 count);
|
||||
void Flush(const uint32 count);
|
||||
};//class GPUArrayBuffer
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
Reference in New Issue
Block a user