1.added GetRangeSize at VKArrayBuffer
2.renamed to align_size instead of unit_size
This commit is contained in:
parent
0e589e8bcd
commit
d163f914c7
@ -19,7 +19,8 @@ namespace hgl
|
||||
{
|
||||
protected:
|
||||
|
||||
uint unit_size;
|
||||
uint align_size;
|
||||
uint range_size;
|
||||
|
||||
VKMemoryAllocator *vk_ma;
|
||||
|
||||
@ -32,7 +33,7 @@ namespace hgl
|
||||
|
||||
private:
|
||||
|
||||
GPUArrayBuffer(VKMemoryAllocator *,const uint);
|
||||
GPUArrayBuffer(VKMemoryAllocator *,const uint,const uint);
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
@ -40,10 +41,12 @@ namespace hgl
|
||||
|
||||
virtual ~GPUArrayBuffer();
|
||||
|
||||
const uint32_t GetUnitSize()const{return unit_size;}
|
||||
const uint32_t GetAlignSize()const{return align_size;} ///<数据对齐字节数
|
||||
const uint32_t GetRangeSize()const{return range_size;} ///<单次渲染访问最大字节数
|
||||
|
||||
DeviceBuffer * GetBuffer();
|
||||
|
||||
uint32 Alloc(const uint32 max_count); ///<预分配空间
|
||||
uint32 Alloc(const uint32 max_count); ///<预分配空间
|
||||
void Clear();
|
||||
|
||||
template<typename T>
|
||||
@ -55,7 +58,7 @@ namespace hgl
|
||||
|
||||
if(!ptr)return(false);
|
||||
|
||||
ubo_access->Start((uchar *)ptr,unit_size,count);
|
||||
ubo_access->Start((uchar *)ptr,align_size,count);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,8 @@ public: //Buffer相关
|
||||
|
||||
const VkDeviceSize GetUBOAlign();
|
||||
const VkDeviceSize GetSSBOAlign();
|
||||
const VkDeviceSize GetUBORange();
|
||||
const VkDeviceSize GetSSBORange();
|
||||
|
||||
#define CREATE_BUFFER_OBJECT(LargeName,type) DeviceBuffer *Create##LargeName( VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,data, sm);} \
|
||||
DeviceBuffer *Create##LargeName( VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,nullptr, sm);} \
|
||||
|
@ -10,33 +10,34 @@ namespace hgl
|
||||
{
|
||||
GPUArrayBuffer *GPUDevice::CreateUBO(const VkDeviceSize &item_length)
|
||||
{
|
||||
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetUBOAlign());
|
||||
const uint align_size=hgl_align<VkDeviceSize>(item_length,GetUBOAlign());
|
||||
|
||||
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,unit_size);
|
||||
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,align_size);
|
||||
|
||||
return(new GPUArrayBuffer(vk_ma,unit_size));
|
||||
return(new GPUArrayBuffer(vk_ma,align_size,GetUBORange()));
|
||||
}
|
||||
|
||||
GPUArrayBuffer *GPUDevice::CreateSSBO(const VkDeviceSize &item_length)
|
||||
{
|
||||
const uint unit_size=hgl_align<VkDeviceSize>(item_length,GetSSBOAlign());
|
||||
const uint align_size=hgl_align<VkDeviceSize>(item_length,GetSSBOAlign());
|
||||
|
||||
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,unit_size);
|
||||
auto vk_ma=new VKMemoryAllocator(this,VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,align_size);
|
||||
|
||||
return(new GPUArrayBuffer(vk_ma,unit_size));
|
||||
return(new GPUArrayBuffer(vk_ma,align_size,GetSSBORange()));
|
||||
}
|
||||
}//namespace graph
|
||||
|
||||
namespace graph
|
||||
{
|
||||
GPUArrayBuffer::GPUArrayBuffer(VKMemoryAllocator *va,const uint us)
|
||||
GPUArrayBuffer::GPUArrayBuffer(VKMemoryAllocator *va,const uint as,const uint rs)
|
||||
{
|
||||
vk_ma=va;
|
||||
unit_size=us;
|
||||
align_size=as;
|
||||
range_size=rs;
|
||||
|
||||
MemoryBlock *mb=new MemoryBlock(vk_ma);
|
||||
|
||||
coll=new Collection(unit_size,mb);
|
||||
coll=new Collection(align_size,mb);
|
||||
}
|
||||
|
||||
GPUArrayBuffer::~GPUArrayBuffer()
|
||||
@ -69,7 +70,7 @@ namespace hgl
|
||||
|
||||
void GPUArrayBuffer::Flush(const uint32 count)
|
||||
{
|
||||
vk_ma->Flush(count*unit_size);
|
||||
vk_ma->Flush(count*align_size);
|
||||
}
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -4,15 +4,10 @@
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
const VkDeviceSize GPUDevice::GetUBOAlign()
|
||||
{
|
||||
return attr->physical_device->GetUBOAlign();
|
||||
}
|
||||
|
||||
const VkDeviceSize GPUDevice::GetSSBOAlign()
|
||||
{
|
||||
return attr->physical_device->GetSSBOAlign();
|
||||
}
|
||||
const VkDeviceSize GPUDevice::GetUBOAlign (){return attr->physical_device->GetUBOAlign();}
|
||||
const VkDeviceSize GPUDevice::GetSSBOAlign (){return attr->physical_device->GetSSBOAlign();}
|
||||
const VkDeviceSize GPUDevice::GetUBORange (){return attr->physical_device->GetUBORange();}
|
||||
const VkDeviceSize GPUDevice::GetSSBORange (){return attr->physical_device->GetSSBORange();}
|
||||
|
||||
bool GPUDevice::CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user