renamed DeviceBuffer/DeviceMemory instead of GPUBuffer/GPUMemory,
This commit is contained in:
@@ -23,7 +23,7 @@ void GPUDevice::Clear(TextureCreateInfo *tci)
|
||||
delete tci;
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture(Texture *tex,GPUBuffer *buf,const VkBufferImageCopy *buffer_image_copy,const int count,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
bool GPUDevice::CommitTexture(Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *buffer_image_copy,const int count,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf)
|
||||
return(false);
|
||||
|
@@ -87,7 +87,7 @@ Texture2D *GPUDevice::CreateTexture2D(TextureCreateInfo *tci)
|
||||
return tex;
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture2D(Texture2D *tex,GPUBuffer *buf,VkPipelineStageFlags destinationStage)
|
||||
bool GPUDevice::CommitTexture2D(Texture2D *tex,DeviceBuffer *buf,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf)return(false);
|
||||
|
||||
@@ -96,7 +96,7 @@ bool GPUDevice::CommitTexture2D(Texture2D *tex,GPUBuffer *buf,VkPipelineStageFla
|
||||
return CommitTexture(tex,buf,&buffer_image_copy,1,1,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,GPUBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||extent.width*extent.height<=0)
|
||||
@@ -142,7 +142,7 @@ bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,GPUBuffer *buf,const VkExt
|
||||
return CommitTexture(tex,buf,buffer_image_copy,miplevel,1,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf||ir_list.GetCount()<=0)
|
||||
return(false);
|
||||
@@ -182,7 +182,7 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,const List<Image2D
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height,VkPipelineStageFlags destinationStage)
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||left<0||left+width>tex->GetWidth()
|
||||
@@ -208,7 +208,7 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,void *data,uint32_t left,uint32_t
|
||||
||size<=0)
|
||||
return(false);
|
||||
|
||||
GPUBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
DeviceBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
|
||||
bool result=ChangeTexture2D(tex,buf,left,top,width,height,destinationStage);
|
||||
|
||||
|
@@ -83,7 +83,7 @@ TextureCube *GPUDevice::CreateTextureCube(TextureCreateInfo *tci)
|
||||
return tex;
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTextureCube(TextureCube *tex,GPUBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags destinationStage)
|
||||
bool GPUDevice::CommitTextureCube(TextureCube *tex,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf||!mipmaps_zero_bytes)return(false);
|
||||
|
||||
@@ -92,7 +92,7 @@ bool GPUDevice::CommitTextureCube(TextureCube *tex,GPUBuffer *buf,const uint32_t
|
||||
return CommitTexture(tex,buf,&buffer_image_copy,1,6,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,GPUBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||extent.width*extent.height<=0)
|
||||
@@ -142,7 +142,7 @@ bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,GPUBuffer *buf,const V
|
||||
return CommitTexture(tex,buf,buffer_image_copy,miplevel,6,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
}
|
||||
|
||||
//bool GPUDevice::ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
//bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
//{
|
||||
// if(!tex||!buf||ir_list.GetCount()<=0)
|
||||
// return(false);
|
||||
@@ -182,7 +182,7 @@ bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,GPUBuffer *buf,const V
|
||||
// return result;
|
||||
//}
|
||||
//
|
||||
//bool GPUDevice::ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height,VkPipelineStageFlags destinationStage)
|
||||
//bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height,VkPipelineStageFlags destinationStage)
|
||||
//{
|
||||
// if(!tex||!buf
|
||||
// ||left<0||left+width>tex->GetWidth()
|
||||
@@ -208,7 +208,7 @@ bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,GPUBuffer *buf,const V
|
||||
// ||size<=0)
|
||||
// return(false);
|
||||
//
|
||||
// GPUBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
// DeviceBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
//
|
||||
// bool result=ChangeTexture2D(tex,buf,left,top,width,height,destinationStage);
|
||||
//
|
||||
|
@@ -11,7 +11,7 @@ template<typename T,typename TL> class VkTextureLoader:public TL
|
||||
protected:
|
||||
|
||||
GPUDevice *device;
|
||||
GPUBuffer *buf;
|
||||
DeviceBuffer *buf;
|
||||
T *tex;
|
||||
|
||||
bool auto_mipmaps;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUBuffer::~GPUBuffer()
|
||||
DeviceBuffer::~DeviceBuffer()
|
||||
{
|
||||
if(buf.memory)delete buf.memory;
|
||||
vkDestroyBuffer(device,buf.buffer,nullptr);
|
||||
|
@@ -39,7 +39,7 @@ namespace
|
||||
{
|
||||
public:
|
||||
|
||||
DescriptorBufferInfo(const GPUBuffer *buf,const VkDeviceSize off,const VkDeviceSize rng)
|
||||
DescriptorBufferInfo(const DeviceBuffer *buf,const VkDeviceSize off,const VkDeviceSize rng)
|
||||
{
|
||||
buffer=buf->GetBuffer();
|
||||
offset=off;
|
||||
@@ -76,7 +76,7 @@ void DescriptorSets::Clear()
|
||||
is_dirty=true;
|
||||
}
|
||||
|
||||
bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf,bool dynamic)
|
||||
bool DescriptorSets::BindUBO(const int binding,const DeviceBuffer *buf,bool dynamic)
|
||||
{
|
||||
if(binding<0||!buf)
|
||||
return(false);
|
||||
@@ -92,7 +92,7 @@ bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf,bool dynamic
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic)
|
||||
bool DescriptorSets::BindUBO(const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic)
|
||||
{
|
||||
if(binding<0||!buf)
|
||||
return(false);
|
||||
@@ -112,7 +112,7 @@ bool DescriptorSets::BindUBO(const int binding,const GPUBuffer *buf,const VkDevi
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool DescriptorSets::BindSSBO(const int binding,const GPUBuffer *buf,bool dynamic)
|
||||
bool DescriptorSets::BindSSBO(const int binding,const DeviceBuffer *buf,bool dynamic)
|
||||
{
|
||||
if(binding<0||!buf)
|
||||
return(false);
|
||||
@@ -128,7 +128,7 @@ bool DescriptorSets::BindSSBO(const int binding,const GPUBuffer *buf,bool dynami
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool DescriptorSets::BindSSBO(const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic)
|
||||
bool DescriptorSets::BindSSBO(const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic)
|
||||
{
|
||||
if(binding<0||!buf)
|
||||
return(false);
|
||||
|
@@ -9,7 +9,7 @@ const VkDeviceSize GPUDevice::GetUBOAlign()
|
||||
return attr->physical_device->GetUBOAlign();
|
||||
}
|
||||
|
||||
bool GPUDevice::CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode)
|
||||
bool GPUDevice::CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode)
|
||||
{
|
||||
BufferCreateInfo buf_info;
|
||||
|
||||
@@ -26,7 +26,7 @@ bool GPUDevice::CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage,VkD
|
||||
|
||||
vkGetBufferMemoryRequirements(attr->device,buf->buffer,&mem_reqs);
|
||||
|
||||
GPUMemory *dm=CreateMemory(mem_reqs,VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||
DeviceMemory *dm=CreateMemory(mem_reqs,VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||
|
||||
if(dm&&dm->BindBuffer(buf->buffer))
|
||||
{
|
||||
@@ -61,7 +61,7 @@ VBO *GPUDevice::CreateVBO(VkFormat format,uint32_t count,const void *data,Sharin
|
||||
|
||||
const VkDeviceSize size=stride*count;
|
||||
|
||||
GPUBufferData buf;
|
||||
DeviceBufferData buf;
|
||||
|
||||
if(!CreateBuffer(&buf,VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,size,size,data,sharing_mode))
|
||||
return(nullptr);
|
||||
@@ -79,7 +79,7 @@ IndexBuffer *GPUDevice::CreateIBO(IndexType index_type,uint32_t count,const void
|
||||
|
||||
const VkDeviceSize size=stride*count;
|
||||
|
||||
GPUBufferData buf;
|
||||
DeviceBufferData buf;
|
||||
|
||||
if(!CreateBuffer(&buf,VK_BUFFER_USAGE_INDEX_BUFFER_BIT,size,data,sharing_mode))
|
||||
return(nullptr);
|
||||
@@ -87,13 +87,13 @@ IndexBuffer *GPUDevice::CreateIBO(IndexType index_type,uint32_t count,const void
|
||||
return(new IndexBuffer(attr->device,buf,index_type,count));
|
||||
}
|
||||
|
||||
GPUBuffer *GPUDevice::CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode)
|
||||
DeviceBuffer *GPUDevice::CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode)
|
||||
{
|
||||
GPUBufferData buf;
|
||||
DeviceBufferData buf;
|
||||
|
||||
if(!CreateBuffer(&buf,buf_usage,range,size,data,sharing_mode))
|
||||
return(nullptr);
|
||||
|
||||
return(new GPUBuffer(attr->device,buf));
|
||||
return(new DeviceBuffer(attr->device,buf));
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUMemory *GPUDevice::CreateMemory(VkImage image,const uint32_t flag)
|
||||
DeviceMemory *GPUDevice::CreateMemory(VkImage image,const uint32_t flag)
|
||||
{
|
||||
VkMemoryRequirements memReqs;
|
||||
|
||||
vkGetImageMemoryRequirements(attr->device,image,&memReqs);
|
||||
|
||||
GPUMemory *mem=CreateMemory(memReqs,flag);
|
||||
DeviceMemory *mem=CreateMemory(memReqs,flag);
|
||||
|
||||
if(!mem)return(nullptr);
|
||||
|
||||
|
@@ -45,7 +45,7 @@ MaterialParameters *MaterialInstance::GetMP(const DescriptorSetsType &type)
|
||||
return material->GetMP(type);
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic)
|
||||
bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||
{
|
||||
MaterialParameters *mp_global=GetMP(type);
|
||||
|
||||
@@ -58,7 +58,7 @@ bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic)
|
||||
bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||
{
|
||||
MaterialParameters *mp_global=GetMP(type);
|
||||
|
||||
|
@@ -16,7 +16,7 @@ MaterialParameters::~MaterialParameters()
|
||||
delete descriptor_sets;
|
||||
}
|
||||
|
||||
bool MaterialParameters::BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic)
|
||||
bool MaterialParameters::BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic)
|
||||
{
|
||||
if(name.IsEmpty()||!ubo)
|
||||
return(false);
|
||||
@@ -32,7 +32,7 @@ bool MaterialParameters::BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dyna
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool MaterialParameters::BindSSBO(const AnsiString &name,GPUBuffer *ssbo,bool dynamic)
|
||||
bool MaterialParameters::BindSSBO(const AnsiString &name,DeviceBuffer *ssbo,bool dynamic)
|
||||
{
|
||||
if(name.IsEmpty()||!ssbo)
|
||||
return(false);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include<hgl/graph/VKMemory.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUMemory *GPUDevice::CreateMemory(const VkMemoryRequirements &req,uint32_t properties)
|
||||
DeviceMemory *GPUDevice::CreateMemory(const VkMemoryRequirements &req,uint32_t properties)
|
||||
{
|
||||
const int index=attr->physical_device->GetMemoryType(req.memoryTypeBits,properties);
|
||||
|
||||
@@ -16,10 +16,10 @@ GPUMemory *GPUDevice::CreateMemory(const VkMemoryRequirements &req,uint32_t prop
|
||||
if(vkAllocateMemory(attr->device,&alloc_info,nullptr,&memory)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new GPUMemory(attr->device,memory,req,index,properties,attr->physical_device->GetLimits().nonCoherentAtomSize));
|
||||
return(new DeviceMemory(attr->device,memory,req,index,properties,attr->physical_device->GetLimits().nonCoherentAtomSize));
|
||||
}
|
||||
|
||||
GPUMemory::GPUMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas)
|
||||
DeviceMemory::DeviceMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas)
|
||||
{
|
||||
device=dev;
|
||||
memory=dm;
|
||||
@@ -34,12 +34,12 @@ GPUMemory::GPUMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &
|
||||
nonCoherentAtomSize=cas;
|
||||
}
|
||||
|
||||
GPUMemory::~GPUMemory()
|
||||
DeviceMemory::~DeviceMemory()
|
||||
{
|
||||
vkFreeMemory(device,memory,nullptr);
|
||||
}
|
||||
|
||||
void *GPUMemory::Map()
|
||||
void *DeviceMemory::Map()
|
||||
{
|
||||
void *result;
|
||||
|
||||
@@ -49,7 +49,7 @@ void *GPUMemory::Map()
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
void *GPUMemory::Map(const VkDeviceSize offset,const VkDeviceSize size)
|
||||
void *DeviceMemory::Map(const VkDeviceSize offset,const VkDeviceSize size)
|
||||
{
|
||||
if(offset<0||offset+size>=req.size)
|
||||
return(nullptr);
|
||||
@@ -62,12 +62,12 @@ void *GPUMemory::Map(const VkDeviceSize offset,const VkDeviceSize size)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
void GPUMemory::Unmap()
|
||||
void DeviceMemory::Unmap()
|
||||
{
|
||||
vkUnmapMemory(device,memory);
|
||||
}
|
||||
|
||||
void GPUMemory::Flush(VkDeviceSize offset,VkDeviceSize size)
|
||||
void DeviceMemory::Flush(VkDeviceSize offset,VkDeviceSize size)
|
||||
{
|
||||
memory_range.offset =offset;
|
||||
memory_range.size =size>0?hgl_align(size,nonCoherentAtomSize):0;
|
||||
@@ -75,7 +75,7 @@ void GPUMemory::Flush(VkDeviceSize offset,VkDeviceSize size)
|
||||
vkFlushMappedMemoryRanges(device,1,&memory_range);
|
||||
}
|
||||
|
||||
bool GPUMemory::Write(const void *ptr,VkDeviceSize start,VkDeviceSize size)
|
||||
bool DeviceMemory::Write(const void *ptr,VkDeviceSize start,VkDeviceSize size)
|
||||
{
|
||||
if(!ptr)return(false);
|
||||
|
||||
@@ -89,14 +89,14 @@ bool GPUMemory::Write(const void *ptr,VkDeviceSize start,VkDeviceSize size)
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool GPUMemory::BindBuffer(VkBuffer buffer)
|
||||
bool DeviceMemory::BindBuffer(VkBuffer buffer)
|
||||
{
|
||||
if(!buffer)return(false);
|
||||
|
||||
return(vkBindBufferMemory(device,buffer,memory,0)==VK_SUCCESS);
|
||||
}
|
||||
|
||||
bool GPUMemory::BindImage(VkImage image)
|
||||
bool DeviceMemory::BindImage(VkImage image)
|
||||
{
|
||||
if(!image)return(false);
|
||||
|
||||
|
@@ -17,18 +17,18 @@ VBO *RenderResource::CreateVBO(VkFormat format,uint32_t count,const void *data,S
|
||||
return vb;
|
||||
}
|
||||
|
||||
#define SCENE_DB_CREATE_BUFFER(name) GPUBuffer *RenderResource::Create##name(VkDeviceSize size,void *data,SharingMode sharing_mode) \
|
||||
#define SCENE_DB_CREATE_BUFFER(name) DeviceBuffer *RenderResource::Create##name(VkDeviceSize size,void *data,SharingMode sharing_mode) \
|
||||
{ \
|
||||
GPUBuffer *buf=device->Create##name(size,data,sharing_mode); \
|
||||
DeviceBuffer *buf=device->Create##name(size,data,sharing_mode); \
|
||||
\
|
||||
if(!buf)return(nullptr); \
|
||||
rm_buffers.Add(buf); \
|
||||
return(buf); \
|
||||
} \
|
||||
\
|
||||
GPUBuffer *RenderResource::Create##name(VkDeviceSize size,SharingMode sharing_mode) \
|
||||
DeviceBuffer *RenderResource::Create##name(VkDeviceSize size,SharingMode sharing_mode) \
|
||||
{ \
|
||||
GPUBuffer *buf=device->Create##name(size,sharing_mode); \
|
||||
DeviceBuffer *buf=device->Create##name(size,sharing_mode); \
|
||||
\
|
||||
if(!buf)return(nullptr); \
|
||||
rm_buffers.Add(buf); \
|
||||
|
Reference in New Issue
Block a user