51 lines
2.0 KiB
C++
51 lines
2.0 KiB
C++
#ifndef HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE
|
|
#define HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE
|
|
|
|
#include<hgl/graph/VKBuffer.h>
|
|
|
|
namespace hgl
|
|
{
|
|
namespace graph
|
|
{
|
|
class VertexAttribBuffer:public DeviceBuffer
|
|
{
|
|
VkFormat format; ///<数据格式
|
|
uint32_t stride; ///<单个数据字节数
|
|
uint32_t count; ///<数据数量
|
|
|
|
private:
|
|
|
|
friend class GPUDevice;
|
|
|
|
VertexAttribBuffer(VkDevice d,const DeviceBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):DeviceBuffer(d,vb)
|
|
{
|
|
format=fmt;
|
|
stride=_stride;
|
|
count=_count;
|
|
}
|
|
|
|
public:
|
|
|
|
~VertexAttribBuffer()=default;
|
|
|
|
const VkFormat GetFormat()const { return format; }
|
|
const uint32_t GetStride()const { return stride; }
|
|
const uint32_t GetCount ()const { return count; }
|
|
|
|
const VkDeviceSize GetBytes()const { return stride*count; }
|
|
|
|
public:
|
|
|
|
void * Map (VkDeviceSize start,VkDeviceSize size) override {return DeviceBuffer::Map(start*stride,size*stride);}
|
|
void Flush (VkDeviceSize start,VkDeviceSize size) override {return DeviceBuffer::Flush(start*stride,size*stride); }
|
|
void Flush (VkDeviceSize size) override {return DeviceBuffer::Flush(size*stride);}
|
|
|
|
bool Write (const void *ptr,uint32_t start,uint32_t size) override {return DeviceBuffer::Write(ptr,start*stride,size*stride);}
|
|
bool Write (const void *ptr,uint32_t size) override {return DeviceBuffer::Write(ptr,0,size*stride);}
|
|
};//class VertexAttribBuffer:public DeviceBuffer
|
|
|
|
using VAB=VertexAttribBuffer;
|
|
}//namespace graph
|
|
}//namespace hgl
|
|
#endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE
|