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
|
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
#include<hgl/graph/vulkan/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;
|
2019-06-14 18:04:41 +08:00
|
|
|
|
|
|
|
|
|
VkImageViewType view_type;
|
|
|
|
|
VkFormat format;
|
|
|
|
|
VkImageAspectFlags aspect_mask;
|
2019-04-22 00:33:48 +08:00
|
|
|
|
|
2019-07-10 21:00:36 +08:00
|
|
|
|
VkExtent3D extent;
|
|
|
|
|
|
2019-04-22 00:33:48 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2019-07-10 21:00:36 +08:00
|
|
|
|
friend ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img);
|
2019-04-22 00:33:48 +08:00
|
|
|
|
|
2019-07-10 21:00:36 +08:00
|
|
|
|
ImageView(VkDevice dev,VkImageView iv,const VkImageViewType vt,const VkFormat fmt,const VkExtent3D &ext,const VkImageAspectFlags am)
|
2019-04-22 00:33:48 +08:00
|
|
|
|
{
|
2019-06-14 18:04:41 +08:00
|
|
|
|
device =dev;
|
|
|
|
|
image_view =iv;
|
|
|
|
|
view_type =vt;
|
|
|
|
|
format =fmt;
|
|
|
|
|
aspect_mask =am;
|
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:
|
|
|
|
|
|
2019-06-14 18:04:41 +08:00
|
|
|
|
const VkImageViewType GetViewType ()const{return view_type;}
|
|
|
|
|
const VkFormat GetFormat ()const{return format;}
|
2019-07-10 21:00:36 +08:00
|
|
|
|
const VkExtent3D & GetExtent ()const{return extent;}
|
2019-06-14 18:04:41 +08:00
|
|
|
|
const VkImageAspectFlags GetAspectFlags ()const{return aspect_mask;}
|
2020-10-15 19:29:26 +08:00
|
|
|
|
|
|
|
|
|
const bool hasColor ()const{return aspect_mask&VK_IMAGE_ASPECT_COLOR_BIT;}
|
|
|
|
|
const bool hasDepth ()const{return aspect_mask&VK_IMAGE_ASPECT_DEPTH_BIT;}
|
|
|
|
|
const bool hasStencil ()const{return aspect_mask&VK_IMAGE_ASPECT_STENCIL_BIT;}
|
|
|
|
|
const bool hasDepthStencil ()const{return aspect_mask&(VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT);}
|
2019-04-22 00:33:48 +08:00
|
|
|
|
};//class ImageView
|
|
|
|
|
|
2019-07-10 21:00:36 +08:00
|
|
|
|
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,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) \
|
|
|
|
|
inline ImageView *CreateImageView##short_name(VkDevice device,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img=VK_NULL_HANDLE) \
|
|
|
|
|
{ \
|
|
|
|
|
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_##larget_name,format,ext,aspectMask,img); \
|
|
|
|
|
}
|
|
|
|
|
|
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
|