2019-05-18 15:41:49 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
|
|
|
|
#include<hgl/graph/VKMemory.h>
|
|
|
|
|
#include<hgl/graph/VKImageView.h>
|
2020-07-27 14:14:03 +08:00
|
|
|
|
#include<hgl/graph/Bitmap.h>
|
2020-09-05 17:54:21 +08:00
|
|
|
|
#include<hgl/type/String.h>
|
2020-10-23 21:21:09 +08:00
|
|
|
|
#include<hgl/graph/VKTextureCreateInfo.h>
|
2019-05-18 15:41:49 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2020-07-27 14:14:03 +08:00
|
|
|
|
|
|
|
|
|
BitmapData *LoadBitmapFromFile(const OSString &filename);
|
|
|
|
|
|
2019-05-18 15:41:49 +08:00
|
|
|
|
class Texture
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
VkDevice device;
|
|
|
|
|
TextureData *data;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-07-25 18:53:50 +08:00
|
|
|
|
TextureData * GetData () {return data;}
|
2019-06-25 22:26:09 +08:00
|
|
|
|
|
2020-07-25 18:53:50 +08:00
|
|
|
|
VkDeviceMemory GetDeviceMemory () {return data?data->memory->operator VkDeviceMemory():VK_NULL_HANDLE;}
|
|
|
|
|
VkImage GetImage () {return data?data->image:VK_NULL_HANDLE;}
|
|
|
|
|
VkImageLayout GetImageLayout () {return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
|
|
|
|
VkImageView GetVulkanImageView () {return data?data->image_view->operator VkImageView():VK_NULL_HANDLE;}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
2020-10-23 21:21:09 +08:00
|
|
|
|
GPUMemory * GetMemory () {return data?data->memory:nullptr;}
|
2020-07-25 18:53:50 +08:00
|
|
|
|
ImageView * GetImageView () {return data?data->image_view:nullptr;}
|
2019-07-03 19:45:39 +08:00
|
|
|
|
|
2020-10-24 21:50:36 +08:00
|
|
|
|
const uint32 GetMipLevel ()const {return data?data->miplevel:0;}
|
2020-07-25 18:53:50 +08:00
|
|
|
|
const bool IsOptimal ()const {return data?data->tiling==VK_IMAGE_TILING_OPTIMAL:false;}
|
|
|
|
|
const bool IsLinear ()const {return data?data->tiling==VK_IMAGE_TILING_LINEAR:false;}
|
2019-06-26 11:10:34 +08:00
|
|
|
|
|
2020-07-25 18:53:50 +08:00
|
|
|
|
const VkFormat GetFormat ()const {return data?data->image_view->GetFormat():VK_FORMAT_UNDEFINED;}
|
|
|
|
|
const VkImageAspectFlags GetAspect ()const {return data?data->image_view->GetAspectFlags():0;}
|
|
|
|
|
const VkExtent3D * GetExtent ()const {return data?&data->image_view->GetExtent():nullptr;}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
Texture(VkDevice dev,TextureData *td)
|
|
|
|
|
{
|
|
|
|
|
device=dev;
|
|
|
|
|
data=td;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ~Texture();
|
|
|
|
|
};//class Texture
|
|
|
|
|
|
|
|
|
|
//class Texture1D:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t length;
|
|
|
|
|
//};//class Texture1D:public Texture
|
|
|
|
|
|
|
|
|
|
//class Texture1DArray:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t length,count;
|
|
|
|
|
//};//class Texture1DArray:public Texture
|
|
|
|
|
|
|
|
|
|
class Texture2D:public Texture
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2019-11-25 22:05:05 +08:00
|
|
|
|
Texture2D(VkDevice dev,TextureData *td):Texture(dev,td){}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
~Texture2D()=default;
|
2019-05-18 16:10:42 +08:00
|
|
|
|
|
2022-01-05 11:26:24 +08:00
|
|
|
|
static VkImageViewType GetImageViewType(){return VK_IMAGE_VIEW_TYPE_2D;}
|
|
|
|
|
|
2020-07-25 18:53:50 +08:00
|
|
|
|
const uint32_t GetWidth ()const{return data?data->image_view->GetExtent().width:0;}
|
2019-11-25 22:05:05 +08:00
|
|
|
|
const uint32_t GetHeight()const{return data?data->image_view->GetExtent().height:0;}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
};//class Texture2D:public Texture
|
|
|
|
|
|
|
|
|
|
//class Texture2DArray:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t width,height,count;
|
|
|
|
|
//};//class Texture2DArray:public Texture
|
|
|
|
|
|
|
|
|
|
//class Texture3D:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t width,height,depth;
|
|
|
|
|
//};//class Texture3D:public Texture
|
|
|
|
|
|
2022-01-05 16:10:42 +08:00
|
|
|
|
class TextureCube:public Texture
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
TextureCube(VkDevice dev,TextureData *td):Texture(dev,td){}
|
|
|
|
|
~TextureCube()=default;
|
|
|
|
|
|
|
|
|
|
static VkImageViewType GetImageViewType(){return VK_IMAGE_VIEW_TYPE_CUBE;}
|
|
|
|
|
|
|
|
|
|
const uint32_t GetWidth ()const{return data?data->image_view->GetExtent().width:0;}
|
|
|
|
|
const uint32_t GetHeight()const{return data?data->image_view->GetExtent().height:0;}
|
|
|
|
|
};//class TextureCube:public Texture
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
2022-01-05 16:10:42 +08:00
|
|
|
|
//class TextureCubeArray:public Texture
|
2019-05-18 15:41:49 +08:00
|
|
|
|
//{
|
|
|
|
|
// uint32_t width,height,count;
|
2022-01-05 16:10:42 +08:00
|
|
|
|
//};//class TextureCubeArray:public Texture
|
2019-06-26 15:45:20 +08:00
|
|
|
|
|
2019-05-18 15:41:49 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|