2019-05-18 15:41:49 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/graph/vulkan/VK.h>
|
2019-05-20 17:52:23 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKImageView.h>
|
2019-05-18 15:41:49 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
struct TextureData
|
|
|
|
|
{
|
2019-06-26 15:18:31 +08:00
|
|
|
|
Memory * memory =nullptr;
|
2019-06-26 11:10:34 +08:00
|
|
|
|
VkImage image =nullptr;
|
|
|
|
|
VkImageLayout image_layout=VK_IMAGE_LAYOUT_UNDEFINED;
|
|
|
|
|
ImageView * image_view =nullptr;
|
|
|
|
|
uint32 mip_levels =0;
|
|
|
|
|
bool linear =false;
|
|
|
|
|
VkFormat format =VK_FORMAT_UNDEFINED;
|
|
|
|
|
VkImageAspectFlags aspect =0;
|
|
|
|
|
VkExtent3D extent;
|
|
|
|
|
|
|
|
|
|
bool ref =false; //是否是引用
|
2019-05-18 15:41:49 +08:00
|
|
|
|
};//struct TextureData
|
|
|
|
|
|
|
|
|
|
class Texture
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
VkDevice device;
|
|
|
|
|
TextureData *data;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-06-25 22:26:09 +08:00
|
|
|
|
operator TextureData * (){return data;}
|
|
|
|
|
|
2019-06-26 15:18:31 +08:00
|
|
|
|
operator Memory * (){return data?data->memory:nullptr;}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
operator VkImage (){return data?data->image:nullptr;}
|
|
|
|
|
operator VkImageLayout (){return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
2019-05-20 17:52:23 +08:00
|
|
|
|
operator VkImageView (){return data?data->image_view->operator VkImageView():nullptr;}
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
2019-06-26 11:10:34 +08:00
|
|
|
|
const uint32 GetMipLevels()const{return data?data->mip_levels:0;}
|
|
|
|
|
const bool IsLinear ()const{return data?data->linear:false;}
|
|
|
|
|
|
|
|
|
|
const VkFormat GetFormat ()const{return data?data->format:VK_FORMAT_UNDEFINED;}
|
|
|
|
|
const VkImageAspectFlags GetAspect ()const{return data?data->aspect:0;}
|
|
|
|
|
const VkExtent3D * GetExtent ()const{return data?&data->extent: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
|
|
|
|
|
{
|
|
|
|
|
uint32_t width,height;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
Texture2D(uint32_t w,uint32_t h,VkDevice dev,TextureData *td):width(w),height(h),Texture(dev,td){}
|
|
|
|
|
~Texture2D()=default;
|
2019-05-18 16:10:42 +08:00
|
|
|
|
|
|
|
|
|
const uint32_t GetWidth()const{return width;}
|
|
|
|
|
const uint32_t GetHeight()const{return height;}
|
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
|
|
|
|
|
|
|
|
|
|
//class TextureCubemap:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t width,height;
|
|
|
|
|
//};//class TextureCubemap:public Texture
|
|
|
|
|
|
|
|
|
|
//class TextureCubemapArray:public Texture
|
|
|
|
|
//{
|
|
|
|
|
// uint32_t width,height,count;
|
|
|
|
|
//};//class TextureCubemapArray:public Texture
|
2019-06-26 15:45:20 +08:00
|
|
|
|
|
|
|
|
|
Texture2D *CreateTexture2D(VkDevice device,const PhysicalDevice *pd,const VkFormat format,uint32_t width,uint32_t height,const VkImageAspectFlags aspectMask,const uint usage,const VkImageLayout image_layout,const VkImageTiling tiling);
|
|
|
|
|
|
2019-05-18 15:41:49 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_TEXTURE_INCLUDE
|