renamed DeviceBuffer/DeviceMemory instead of GPUBuffer/GPUMemory,
This commit is contained in:
parent
2e6a8e794f
commit
b980457ba2
@ -37,9 +37,9 @@ private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
GPUBuffer * ubo_color_material =nullptr;
|
||||
GPUBuffer * ubo_line_config =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_color_material =nullptr;
|
||||
DeviceBuffer * ubo_line_config =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@ -62,9 +62,9 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
GPUBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
DeviceBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
{
|
||||
GPUBuffer *ubo=db->CreateUBO(size,data);
|
||||
DeviceBuffer *ubo=db->CreateUBO(size,data);
|
||||
|
||||
if(!ubo)
|
||||
return(nullptr);
|
||||
|
@ -44,8 +44,8 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
GPUBuffer * ubo_rb_config =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_rb_config =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@ -74,9 +74,9 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
GPUBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
DeviceBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
{
|
||||
GPUBuffer *ubo=db->CreateUBO(size,data);
|
||||
DeviceBuffer *ubo=db->CreateUBO(size,data);
|
||||
|
||||
if(!ubo)
|
||||
return(nullptr);
|
||||
|
@ -40,10 +40,10 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Pipeline * pipeline_solid =nullptr;
|
||||
|
||||
GPUBuffer * ubo_atomsphere =nullptr;
|
||||
DeviceBuffer * ubo_atomsphere =nullptr;
|
||||
AtmosphereData atomsphere_data;
|
||||
|
||||
Primitive * ro_sphere =nullptr;
|
||||
Primitive * ro_sphere =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -35,8 +35,8 @@ private:
|
||||
Pipeline * sky_pipeline =nullptr;
|
||||
Pipeline * solid_pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
Sampler * sampler =nullptr;
|
||||
TextureCube * texture =nullptr;
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
|
||||
PhongPointLight lights;
|
||||
|
||||
GPUBuffer *ubo_lights;
|
||||
DeviceBuffer *ubo_lights;
|
||||
|
||||
struct SubpassParam
|
||||
{
|
||||
|
@ -26,8 +26,8 @@ private:
|
||||
|
||||
Pipeline * solid_pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
Sampler * sampler =nullptr;
|
||||
Texture2D * texture =nullptr;
|
||||
|
@ -17,7 +17,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -49,8 +49,8 @@ private:
|
||||
Pipeline * axis_pipeline =nullptr;
|
||||
Pipeline * pipeline_solid =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ class TestApp:public CameraAppFramework
|
||||
Camera cam;
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
};
|
||||
|
||||
struct:public RenderObject
|
||||
|
@ -31,7 +31,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -33,8 +33,8 @@ private:
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
|
||||
GPUBuffer * ubo_color =nullptr;
|
||||
GPUBuffer * ubo_sun =nullptr;
|
||||
DeviceBuffer * ubo_color =nullptr;
|
||||
DeviceBuffer * ubo_sun =nullptr;
|
||||
|
||||
Primitive * primitive =nullptr;
|
||||
|
||||
|
@ -21,7 +21,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
SkyColorConfig scc;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@ -32,7 +32,7 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_sky_color =nullptr;
|
||||
DeviceBuffer * ubo_sky_color =nullptr;
|
||||
|
||||
Primitive * ro_skyphere =nullptr;
|
||||
|
||||
|
@ -36,7 +36,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -22,7 +22,8 @@ constexpr float position_data[VERTEX_COUNT][2]=
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT][4]=
|
||||
{ {1,0,0,1},
|
||||
{
|
||||
{1,0,0,1},
|
||||
{0,1,0,1},
|
||||
{0,0,1,1}
|
||||
};
|
||||
|
@ -61,7 +61,7 @@ protected:
|
||||
protected:
|
||||
|
||||
Camera * camera =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
@ -149,7 +149,7 @@ public:
|
||||
return camera->info;
|
||||
}
|
||||
|
||||
GPUBuffer *GetCameraInfoBuffer()
|
||||
DeviceBuffer *GetCameraInfoBuffer()
|
||||
{
|
||||
return ubo_camera_info;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
GPUBuffer *tile_buffer; ///<Tile暂存缓冲区
|
||||
DeviceBuffer *tile_buffer; ///<Tile暂存缓冲区
|
||||
|
||||
List<Image2DRegion> commit_list;
|
||||
uint8 *commit_ptr;
|
||||
|
@ -51,9 +51,9 @@ class TextureCubeArray;
|
||||
|
||||
class Sampler;
|
||||
|
||||
class GPUMemory;
|
||||
class GPUBuffer;
|
||||
struct GPUBufferData;
|
||||
class DeviceMemory;
|
||||
class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
|
||||
class VertexAttribBuffer;
|
||||
using VBO=VertexAttribBuffer;
|
||||
|
@ -59,7 +59,7 @@ namespace hgl
|
||||
return coll->GetUnitBytes();
|
||||
}
|
||||
|
||||
GPUBuffer *GetBuffer()
|
||||
DeviceBuffer *GetBuffer()
|
||||
{
|
||||
return vk_ma->GetBuffer();
|
||||
}
|
||||
|
@ -4,19 +4,19 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKMemory.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct GPUBufferData
|
||||
struct DeviceBufferData
|
||||
{
|
||||
VkBuffer buffer;
|
||||
GPUMemory * memory=nullptr;
|
||||
VkBuffer buffer=nullptr;
|
||||
DeviceMemory * memory=nullptr;
|
||||
VkDescriptorBufferInfo info;
|
||||
};//struct GPUBufferData
|
||||
};//struct DeviceBufferData
|
||||
|
||||
class GPUBuffer
|
||||
class DeviceBuffer
|
||||
{
|
||||
protected:
|
||||
|
||||
VkDevice device;
|
||||
GPUBufferData buf;
|
||||
DeviceBufferData buf;
|
||||
|
||||
private:
|
||||
|
||||
@ -24,7 +24,7 @@ private:
|
||||
friend class VertexAttribBuffer;
|
||||
friend class IndexBuffer;
|
||||
|
||||
GPUBuffer(VkDevice d,const GPUBufferData &b)
|
||||
DeviceBuffer(VkDevice d,const DeviceBufferData &b)
|
||||
{
|
||||
device=d;
|
||||
buf=b;
|
||||
@ -32,10 +32,10 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUBuffer();
|
||||
virtual ~DeviceBuffer();
|
||||
|
||||
VkBuffer GetBuffer ()const{return buf.buffer;}
|
||||
GPUMemory * GetMemory ()const{return buf.memory;}
|
||||
DeviceMemory * GetMemory ()const{return buf.memory;}
|
||||
const VkDescriptorBufferInfo * GetBufferInfo ()const{return &buf.info;}
|
||||
|
||||
void * Map () {return buf.memory->Map();}
|
||||
@ -47,6 +47,6 @@ public:
|
||||
bool Write (const void *ptr,uint32_t start,uint32_t size) {return buf.memory->Write(ptr,start,size);}
|
||||
bool Write (const void *ptr,uint32_t size) {return buf.memory->Write(ptr,0,size);}
|
||||
bool Write (const void *ptr) {return buf.memory->Write(ptr);}
|
||||
};//class GPUBuffer
|
||||
};//class DeviceBuffer
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_BUFFER_INCLUDE
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUBuffer;
|
||||
class DeviceBuffer;
|
||||
|
||||
class DescriptorSets
|
||||
{
|
||||
@ -49,10 +49,10 @@ public:
|
||||
|
||||
void Clear();
|
||||
|
||||
bool BindUBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
|
||||
bool BindSampler(const int binding,Texture *,Sampler *);
|
||||
bool BindInputAttachment(const int binding,ImageView *);
|
||||
|
@ -110,21 +110,21 @@ public:
|
||||
|
||||
public: //内存相关
|
||||
|
||||
GPUMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
||||
GPUMemory *CreateMemory(VkImage,const uint32 flag=VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
DeviceMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
||||
DeviceMemory *CreateMemory(VkImage,const uint32 flag=VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
private: //Buffer相关
|
||||
|
||||
bool CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode);
|
||||
bool CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data,SharingMode sharing_mode){return CreateBuffer(buf,buf_usage,size,size,data,sharing_mode);}
|
||||
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode);
|
||||
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data,SharingMode sharing_mode){return CreateBuffer(buf,buf_usage,size,size,data,sharing_mode);}
|
||||
|
||||
public: //Buffer相关
|
||||
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,range,size,nullptr,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,range,size,nullptr,sm);}
|
||||
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
||||
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
||||
@ -140,10 +140,10 @@ public: //Buffer相关
|
||||
|
||||
const VkDeviceSize GetUBOAlign();
|
||||
|
||||
#define CREATE_BUFFER_OBJECT(LargeName,type) GPUBuffer *Create##LargeName( VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,data, sm);} \
|
||||
GPUBuffer *Create##LargeName( VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,nullptr, sm);} \
|
||||
GPUBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,data, sm);} \
|
||||
GPUBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,nullptr, sm);}
|
||||
#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);} \
|
||||
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,data, sm);} \
|
||||
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,nullptr, sm);}
|
||||
|
||||
CREATE_BUFFER_OBJECT(UBO,UNIFORM)
|
||||
CREATE_BUFFER_OBJECT(SSBO,STORAGE)
|
||||
@ -158,13 +158,13 @@ public: //Image
|
||||
|
||||
private: //texture
|
||||
|
||||
bool CommitTexture (Texture *,GPUBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool CommitTexture (Texture *,DeviceBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
bool CommitTexture2D (Texture2D *,GPUBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,GPUBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
bool CommitTexture2D (Texture2D *,DeviceBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool CommitTextureCube (TextureCube *,GPUBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,GPUBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
bool CommitTextureCube (TextureCube *,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<提交纹理处理到队列
|
||||
|
||||
@ -182,12 +182,12 @@ public: //Texture
|
||||
|
||||
void Clear(TextureCreateInfo *);
|
||||
|
||||
bool ChangeTexture2D(Texture2D *,GPUBuffer *buf,const List<Image2DRegion> &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,GPUBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf,const List<Image2DRegion> &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,void *data, uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
template<typename T>
|
||||
bool ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,const RectScope2<T> &rs)
|
||||
bool ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2<T> &rs)
|
||||
{
|
||||
return ChangeTexture2D( tex,
|
||||
buf,
|
||||
|
@ -7,7 +7,7 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class IndexBuffer:public GPUBuffer
|
||||
class IndexBuffer:public DeviceBuffer
|
||||
{
|
||||
IndexType index_type;
|
||||
uint32_t count;
|
||||
@ -16,7 +16,7 @@ namespace hgl
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
IndexBuffer(VkDevice d,const GPUBufferData &vb,IndexType it,uint32_t _count):GPUBuffer(d,vb)
|
||||
IndexBuffer(VkDevice d,const DeviceBufferData &vb,IndexType it,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
index_type=it;
|
||||
count=_count;
|
||||
@ -28,7 +28,7 @@ namespace hgl
|
||||
|
||||
const IndexType GetType ()const{return index_type;}
|
||||
const uint32 GetCount()const{return count;}
|
||||
};//class IndexBuffer:public GPUBuffer
|
||||
};//class IndexBuffer:public DeviceBuffer
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_VULKAN_INDEX_BUFFER_INCLUDE
|
||||
|
@ -28,8 +28,8 @@ public:
|
||||
MaterialParameters *GetMP(){return mp_value;}
|
||||
MaterialParameters *GetMP(const DescriptorSetsType &type);
|
||||
|
||||
bool BindUBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindUBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const DescriptorSetsType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
};//class MaterialInstance
|
||||
VK_NAMESPACE_END
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
|
||||
virtual ~MaterialParameters();
|
||||
|
||||
bool BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindInputAttachment(const AnsiString &name,ImageView *);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUMemory
|
||||
class DeviceMemory
|
||||
{
|
||||
VkDevice device;
|
||||
VkDeviceMemory memory;
|
||||
@ -18,11 +18,11 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
GPUMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
||||
DeviceMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUMemory();
|
||||
virtual ~DeviceMemory();
|
||||
|
||||
operator VkDeviceMemory(){return memory;}
|
||||
|
||||
@ -47,6 +47,6 @@ public:
|
||||
|
||||
void Flush (VkDeviceSize,VkDeviceSize);
|
||||
void Flush (VkDeviceSize size){Flush(0,size);}
|
||||
};//class GPUMemory
|
||||
};//class DeviceMemory
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MEMORY_INCLUDE
|
||||
|
@ -11,7 +11,7 @@ class VKMemoryAllocator:public AbstractMemoryAllocator
|
||||
|
||||
uint32_t buffer_usage_flag_bits;
|
||||
|
||||
GPUBuffer *gpu_buffer;
|
||||
DeviceBuffer *gpu_buffer;
|
||||
|
||||
VkDeviceSize range; //ubo之类需要一个一次访问范围
|
||||
|
||||
@ -25,7 +25,7 @@ public:
|
||||
|
||||
const uint32_t GetBufferUsageFlagBits ()const{return buffer_usage_flag_bits;}
|
||||
|
||||
GPUBuffer * GetBuffer (){return gpu_buffer;}
|
||||
DeviceBuffer * GetBuffer (){return gpu_buffer;}
|
||||
|
||||
public:
|
||||
|
||||
|
@ -41,7 +41,7 @@ class RenderResource
|
||||
IDResManage<MaterialInstanceID, MaterialInstance> rm_material_instance; ///<材质实例合集
|
||||
IDResManage<DescriptorSetsID, DescriptorSets> rm_desc_sets; ///<描述符合集
|
||||
IDResManage<PrimitiveID, Primitive> rm_primitives; ///<图元合集
|
||||
IDResManage<BufferID, GPUBuffer> rm_buffers; ///<顶点缓冲区合集
|
||||
IDResManage<BufferID, DeviceBuffer> rm_buffers; ///<顶点缓冲区合集
|
||||
IDResManage<SamplerID, Sampler> rm_samplers; ///<采样器合集
|
||||
IDResManage<TextureID, Texture> rm_textures; ///<纹理合集
|
||||
IDResManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||
@ -57,7 +57,7 @@ public: //Add
|
||||
MaterialInstanceID Add(MaterialInstance * mi ){return rm_material_instance.Add(mi);}
|
||||
DescriptorSetsID Add(DescriptorSets * ds ){return rm_desc_sets.Add(ds);}
|
||||
PrimitiveID Add(Primitive * p ){return rm_primitives.Add(p);}
|
||||
BufferID Add(GPUBuffer * buf ){return rm_buffers.Add(buf);}
|
||||
BufferID Add(DeviceBuffer * buf ){return rm_buffers.Add(buf);}
|
||||
SamplerID Add(Sampler * s ){return rm_samplers.Add(s);}
|
||||
TextureID Add(Texture * t ){return rm_textures.Add(t);}
|
||||
RenderableID Add(Renderable * r ){return rm_renderables.Add(r);}
|
||||
@ -68,8 +68,8 @@ public: // VBO/VAO
|
||||
VBO *CreateVBO(VkFormat format,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
||||
VBO *CreateVBO(const VAD *vad,SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sm);}
|
||||
|
||||
#define SCENE_DB_CREATE_FUNC(name) GPUBuffer *Create##name(VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
|
||||
GPUBuffer *Create##name(VkDeviceSize size,SharingMode sm=SharingMode::Exclusive);
|
||||
#define SCENE_DB_CREATE_FUNC(name) DeviceBuffer *Create##name(VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
|
||||
DeviceBuffer *Create##name(VkDeviceSize size,SharingMode sm=SharingMode::Exclusive);
|
||||
|
||||
SCENE_DB_CREATE_FUNC(UBO)
|
||||
SCENE_DB_CREATE_FUNC(SSBO)
|
||||
@ -111,7 +111,7 @@ public: //Get
|
||||
MaterialInstance * GetMaterialInstance (const MaterialInstanceID &id){return rm_material_instance.Get(id);}
|
||||
DescriptorSets * GetDescSets (const DescriptorSetsID &id){return rm_desc_sets.Get(id);}
|
||||
Primitive * GetPrimitive (const PrimitiveID &id){return rm_primitives.Get(id);}
|
||||
GPUBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
DeviceBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
Sampler * GetSampler (const SamplerID &id){return rm_samplers.Get(id);}
|
||||
Texture * GetTexture (const TextureID &id){return rm_textures.Get(id);}
|
||||
Renderable * GetRenderable (const RenderableID &id){return rm_renderables.Get(id);}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
VkImageLayout GetImageLayout () {return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
||||
VkImageView GetVulkanImageView () {return data?data->image_view->GetImageView():VK_NULL_HANDLE;}
|
||||
|
||||
GPUMemory * GetMemory () {return data?data->memory:nullptr;}
|
||||
DeviceMemory * GetMemory () {return data?data->memory:nullptr;}
|
||||
ImageView * GetImageView () {return data?data->image_view:nullptr;}
|
||||
|
||||
const uint32 GetMipLevel ()const {return data?data->miplevel:0;}
|
||||
|
@ -20,13 +20,13 @@ struct TextureCreateInfo
|
||||
VkImageLayout image_layout;
|
||||
|
||||
VkImage image; //如果没有IMAGE,则创建。(交换链等会直接提供image,所以存在外部传入现像)
|
||||
GPUMemory * memory; //同时需分配内存并绑定
|
||||
DeviceMemory * memory; //同时需分配内存并绑定
|
||||
|
||||
ImageView * image_view; //如果没有imageview,则创建
|
||||
|
||||
void * pixels; //如果没有buffer但有pixels,则根据pixels和以上条件创建buffer
|
||||
VkDeviceSize total_bytes;
|
||||
GPUBuffer * buffer; //如果pixels也没有,则代表不会立即写入图像数据
|
||||
DeviceBuffer * buffer; //如果pixels也没有,则代表不会立即写入图像数据
|
||||
|
||||
public:
|
||||
|
||||
@ -152,7 +152,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool SetData(GPUBuffer *buf,const VkExtent3D &ext)
|
||||
bool SetData(DeviceBuffer *buf,const VkExtent3D &ext)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(ext.width<=0||ext.height<=0||ext.depth<=0)return(false);
|
||||
@ -292,7 +292,7 @@ struct SwapchainDepthTextureCreateInfo:public TextureCreateInfo
|
||||
|
||||
struct TextureData
|
||||
{
|
||||
GPUMemory * memory;
|
||||
DeviceMemory * memory;
|
||||
VkImage image;
|
||||
VkImageLayout image_layout;
|
||||
ImageView * image_view;
|
||||
|
@ -7,7 +7,7 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class VertexAttribBuffer:public GPUBuffer
|
||||
class VertexAttribBuffer:public DeviceBuffer
|
||||
{
|
||||
VkFormat format; ///<数据格式
|
||||
uint32_t stride; ///<单个数据字节数
|
||||
@ -17,7 +17,7 @@ namespace hgl
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
VertexAttribBuffer(VkDevice d,const GPUBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):GPUBuffer(d,vb)
|
||||
VertexAttribBuffer(VkDevice d,const DeviceBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
format=fmt;
|
||||
stride=_stride;
|
||||
@ -31,7 +31,7 @@ namespace hgl
|
||||
const VkFormat GetFormat()const { return format; }
|
||||
const uint32_t GetStride()const { return stride; }
|
||||
const uint32_t GetCount ()const { return count; }
|
||||
};//class VertexAttribBuffer:public GPUBuffer
|
||||
};//class VertexAttribBuffer:public DeviceBuffer
|
||||
|
||||
using VBO=VertexAttribBuffer;
|
||||
}//namespace graph
|
||||
|
@ -31,25 +31,25 @@ namespace hgl
|
||||
TextLayout * tl_engine;
|
||||
|
||||
Color4f color;
|
||||
GPUBuffer * ubo_color;
|
||||
DeviceBuffer * ubo_color;
|
||||
|
||||
SortedSets<TextPrimitive *> tr_sets;
|
||||
|
||||
private:
|
||||
|
||||
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit=-1);
|
||||
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit=-1);
|
||||
TextRender(GPUDevice *dev,FontSource *);
|
||||
|
||||
bool InitTileFont(int limit);
|
||||
bool InitTextLayoutEngine();
|
||||
bool InitUBO();
|
||||
bool InitMaterial(RenderPass *,GPUBuffer *);
|
||||
bool InitMaterial(RenderPass *,DeviceBuffer *);
|
||||
|
||||
public:
|
||||
|
||||
~TextRender();
|
||||
|
||||
bool Init(RenderPass *rp,GPUBuffer *ubo_camera_info,int limit);
|
||||
bool Init(RenderPass *rp,DeviceBuffer *ubo_camera_info,int limit);
|
||||
|
||||
public:
|
||||
|
||||
@ -82,7 +82,7 @@ namespace hgl
|
||||
* 创建一个文本渲染器
|
||||
* @param limit 节数限制(-1表示自动)
|
||||
*/
|
||||
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit);
|
||||
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit);
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_TEXT_RENDER_INCLUDE
|
||||
|
@ -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); \
|
||||
|
@ -78,7 +78,7 @@ namespace hgl
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool TextRender::InitMaterial(RenderPass *rp,GPUBuffer *ubo_camera_info)
|
||||
bool TextRender::InitMaterial(RenderPass *rp,DeviceBuffer *ubo_camera_info)
|
||||
{
|
||||
material=db->CreateMaterial(OS_TEXT("res/material/LumTextureRect2D"));
|
||||
|
||||
@ -127,7 +127,7 @@ namespace hgl
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool TextRender::Init(RenderPass *rp,GPUBuffer *ubo_camera_info,int limit)
|
||||
bool TextRender::Init(RenderPass *rp,DeviceBuffer *ubo_camera_info,int limit)
|
||||
{
|
||||
if(!InitTileFont(limit))
|
||||
return(false);
|
||||
@ -212,7 +212,7 @@ namespace hgl
|
||||
return AcquireFontSource(fnt);
|
||||
}
|
||||
|
||||
TextRender *CreateTextRender(GPUDevice *dev,FontSource *fs,RenderPass *rp,GPUBuffer *ubo_camera_info,int limit)
|
||||
TextRender *CreateTextRender(GPUDevice *dev,FontSource *fs,RenderPass *rp,DeviceBuffer *ubo_camera_info,int limit)
|
||||
{
|
||||
if(!dev||!rp||!ubo_camera_info)
|
||||
return(nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user