add VKArrayBuffer.cpp/.h
This commit is contained in:
parent
cc014e9b31
commit
eeff738f56
39
inc/hgl/graph/VKArrayBuffer.h
Normal file
39
inc/hgl/graph/VKArrayBuffer.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||||
|
#define HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/graph/VKBuffer.h>
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* GPU数据阵列缓冲区<br>
|
||||||
|
* 它用于储存多份相同格式的数据,常用于多物件渲染,instance等
|
||||||
|
*/
|
||||||
|
class GPUArrayBuffer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
uint32_t item_size; ///<单个数据长度
|
||||||
|
uint32_t alloc_count; ///<总计分配的数据个数
|
||||||
|
uint32_t count; ///<实际使用的数据个数
|
||||||
|
|
||||||
|
GPUBuffer * buf_gpu; ///<实际数据GPU缓冲区
|
||||||
|
uint8 * buf_cpu;
|
||||||
|
uint32_t * offset; ///<数据偏移地址
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本类构造函数
|
||||||
|
* @param s 单个数据长度
|
||||||
|
* @param c 数据个数
|
||||||
|
*/
|
||||||
|
GPUArrayBuffer(const uint32_t s=0,const uint32_t c=0);
|
||||||
|
virtual ~GPUArrayBuffer();
|
||||||
|
|
||||||
|
void Clear(); ///<清空缓冲区
|
||||||
|
};//class GPUArrayBuffer
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
@ -102,8 +102,12 @@ SET(VK_DEBUG_SOURCE ${SG_INCLUDE_PATH}/VKDebugOut.h
|
|||||||
|
|
||||||
SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
|
SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
|
||||||
${SG_INCLUDE_PATH}/VKBuffer.h
|
${SG_INCLUDE_PATH}/VKBuffer.h
|
||||||
|
${SG_INCLUDE_PATH}/VKVertexAttribBuffer.h
|
||||||
|
${SG_INCLUDE_PATH}/VKIndexBuffer.h
|
||||||
|
${SG_INCLUDE_PATH}/VKArrayBuffer.h
|
||||||
Vulkan/VKMemory.cpp
|
Vulkan/VKMemory.cpp
|
||||||
Vulkan/VKBuffer.cpp)
|
Vulkan/VKBuffer.cpp
|
||||||
|
Vulkan/VKArrayBuffer.cpp)
|
||||||
|
|
||||||
SET(VK_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKDevice.h
|
SET(VK_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKDevice.h
|
||||||
${SG_INCLUDE_PATH}/VKDeviceAttribute.h
|
${SG_INCLUDE_PATH}/VKDeviceAttribute.h
|
||||||
|
35
src/SceneGraph/Vulkan/VKArrayBuffer.cpp
Normal file
35
src/SceneGraph/Vulkan/VKArrayBuffer.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include<hgl/graph/VKArrayBuffer.h>
|
||||||
|
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 本类构造函数
|
||||||
|
* @param s 单个数据长度
|
||||||
|
* @param c 数据个数
|
||||||
|
*/
|
||||||
|
GPUArrayBuffer::GPUArrayBuffer(const uint32_t s,const uint32_t c)
|
||||||
|
{
|
||||||
|
item_size=s;
|
||||||
|
count=c;
|
||||||
|
alloc_count=power_to_2(c);
|
||||||
|
|
||||||
|
buf_gpu=nullptr;
|
||||||
|
buf_cpu=nullptr;
|
||||||
|
offset=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
GPUArrayBuffer::~GPUArrayBuffer()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(buf_gpu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPUArrayBuffer::Clear()
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
Loading…
x
Reference in New Issue
Block a user