2019-06-25 22:26:09 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|
2019-04-22 00:33:48 +08:00
|
|
|
|
#define HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2019-04-22 00:33:48 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
class ImageView
|
|
|
|
|
{
|
2019-06-14 18:04:41 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2019-04-22 00:33:48 +08:00
|
|
|
|
VkDevice device;
|
|
|
|
|
VkImageView image_view;
|
2022-01-07 11:56:32 +08:00
|
|
|
|
ImageViewCreateInfo *ivci;
|
2019-06-14 18:04:41 +08:00
|
|
|
|
|
2019-07-10 21:00:36 +08:00
|
|
|
|
VkExtent3D extent;
|
|
|
|
|
|
2019-04-22 00:33:48 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2020-10-24 21:50:36 +08:00
|
|
|
|
friend ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,const uint32_t &miplevel,VkImageAspectFlags aspectMask,VkImage img);
|
2019-04-22 00:33:48 +08:00
|
|
|
|
|
2022-01-07 11:56:32 +08:00
|
|
|
|
ImageView(VkDevice dev,VkImageView iv,ImageViewCreateInfo *ci,const VkExtent3D &ext)
|
2019-04-22 00:33:48 +08:00
|
|
|
|
{
|
2019-06-14 18:04:41 +08:00
|
|
|
|
device =dev;
|
|
|
|
|
image_view =iv;
|
2022-01-07 11:56:32 +08:00
|
|
|
|
ivci =ci;
|
2019-07-10 21:00:36 +08:00
|
|
|
|
extent =ext;
|
2019-04-22 00:33:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-06-26 16:42:15 +08:00
|
|
|
|
virtual ~ImageView();
|
2019-04-22 00:33:48 +08:00
|
|
|
|
|
|
|
|
|
operator VkImageView(){return image_view;}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-01-07 11:56:32 +08:00
|
|
|
|
const VkImageViewType GetViewType ()const{return ivci->viewType;}
|
|
|
|
|
const VkFormat GetFormat ()const{return ivci->format;}
|
2019-07-10 21:00:36 +08:00
|
|
|
|
const VkExtent3D & GetExtent ()const{return extent;}
|
2022-01-07 11:56:32 +08:00
|
|
|
|
const VkImageAspectFlags GetAspectFlags ()const{return ivci->subresourceRange.aspectMask;}
|
|
|
|
|
const uint32_t GetLayerCount ()const{return ivci->subresourceRange.layerCount;}
|
2020-10-15 19:29:26 +08:00
|
|
|
|
|
2022-01-07 11:56:32 +08:00
|
|
|
|
const bool hasColor ()const{return ivci->subresourceRange.aspectMask&VK_IMAGE_ASPECT_COLOR_BIT;}
|
|
|
|
|
const bool hasDepth ()const{return ivci->subresourceRange.aspectMask&VK_IMAGE_ASPECT_DEPTH_BIT;}
|
|
|
|
|
const bool hasStencil ()const{return ivci->subresourceRange.aspectMask&VK_IMAGE_ASPECT_STENCIL_BIT;}
|
|
|
|
|
const bool hasDepthStencil ()const{return ivci->subresourceRange.aspectMask&(VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT);}
|
2019-04-22 00:33:48 +08:00
|
|
|
|
};//class ImageView
|
|
|
|
|
|
2020-10-24 21:50:36 +08:00
|
|
|
|
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,const uint32_t &miplevel,VkImageAspectFlags aspectMask,VkImage img);
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
2020-07-25 18:53:50 +08:00
|
|
|
|
#define CREATE_IMAGE_VIEW(short_name,larget_name) \
|
2020-10-24 21:50:36 +08:00
|
|
|
|
inline ImageView *CreateImageView##short_name(VkDevice device,VkFormat format,const VkExtent3D &ext,const uint32_t &miplevel,VkImageAspectFlags aspectMask,VkImage img=VK_NULL_HANDLE) \
|
2020-07-25 18:53:50 +08:00
|
|
|
|
{ \
|
2020-10-24 21:50:36 +08:00
|
|
|
|
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_##larget_name,format,ext,miplevel,aspectMask,img); \
|
2020-07-25 18:53:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-18 15:41:49 +08:00
|
|
|
|
CREATE_IMAGE_VIEW(1D,1D);
|
|
|
|
|
CREATE_IMAGE_VIEW(2D,2D);
|
|
|
|
|
CREATE_IMAGE_VIEW(3D,3D);
|
|
|
|
|
CREATE_IMAGE_VIEW(Cube,CUBE);
|
|
|
|
|
CREATE_IMAGE_VIEW(1DArray,1D_ARRAY);
|
|
|
|
|
CREATE_IMAGE_VIEW(2DArray,2D_ARRAY);
|
|
|
|
|
CREATE_IMAGE_VIEW(CubeArray,CUBE_ARRAY);
|
|
|
|
|
#undef CREATE_IMAGE_VIEW
|
2019-04-22 00:33:48 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|