BufferImageCopy supported RectScope2<>

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-06-07 20:23:13 +08:00
parent de2926a6d5
commit 18850b0e27

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include<hgl/graph/VKTexture.h> #include<hgl/graph/VKTexture.h>
#include<hgl/type/RectScope.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
struct BufferImageCopy:public VkBufferImageCopy struct BufferImageCopy:public VkBufferImageCopy
{ {
@ -19,14 +20,21 @@ public:
BufferImageCopy(const Texture2D *tex):BufferImageCopy() BufferImageCopy(const Texture2D *tex):BufferImageCopy()
{ {
imageSubresource.aspectMask=tex->GetAspect(); imageSubresource.aspectMask=tex->GetAspect();
SetRectScope(0,0,tex->GetWidth(),tex->GetHeight()); SetRectScope(tex->GetWidth(),tex->GetHeight());
}
template<typename T>
BufferImageCopy(const Texture2D *tex,const RectScope2<T> &rs):BufferImageCopy()
{
imageSubresource.aspectMask=tex->GetAspect();
SetRectScope(rs);
} }
BufferImageCopy(const TextureCube *tex):BufferImageCopy() BufferImageCopy(const TextureCube *tex):BufferImageCopy()
{ {
imageSubresource.aspectMask=tex->GetAspect(); imageSubresource.aspectMask=tex->GetAspect();
imageSubresource.layerCount=6; imageSubresource.layerCount=6;
SetRectScope(0,0,tex->GetWidth(),tex->GetHeight()); SetRectScope(tex->GetWidth(),tex->GetHeight());
} }
void Set(const VkImageAspectFlags aspect_mask,const uint32_t layer_count) void Set(const VkImageAspectFlags aspect_mask,const uint32_t layer_count)
@ -37,20 +45,33 @@ public:
void Set(Image2DRegion *ir) void Set(Image2DRegion *ir)
{ {
imageOffset.x=ir->left; imageOffset.x =ir->left;
imageOffset.y=ir->top; imageOffset.y =ir->top;
imageExtent.width=ir->width; imageOffset.z =0;
imageExtent.height=ir->height; imageExtent.width =ir->width;
imageExtent.depth=1; imageExtent.height =ir->height;
imageExtent.depth =1;
} }
void SetRectScope(int32_t left,int32_t top,uint32_t width,uint32_t height) void SetRectScope(uint32_t width,uint32_t height)
{ {
imageOffset.x=left; imageOffset.x =0;
imageOffset.y=top; imageOffset.y =0;
imageExtent.width=width; imageOffset.z =0;
imageExtent.height=height; imageExtent.width =width;
imageExtent.depth=1; imageExtent.height =height;
imageExtent.depth =1;
}
template<typename T>
void SetRectScope(const RectScope2<T> &rs)
{
imageOffset.x =rs.Left;
imageOffset.y =rs.Top;
imageOffset.z =0;
imageExtent.width =rs.Width;
imageExtent.height =rs.Height;
imageExtent.depth =1;
} }
};// };//
VK_NAMESPACE_END VK_NAMESPACE_END