improved TextureLoader and VKTexture2DLoader

This commit is contained in:
2021-12-14 16:32:03 +08:00
parent 3d9c229a20
commit 80bacd2b44
3 changed files with 29 additions and 10 deletions

View File

@@ -93,7 +93,15 @@ namespace hgl
public:
TextureLoader(const VkImageViewType &ivt){type=ivt;}
TextureLoader(const VkImageViewType &ivt)
{
type=ivt;
format=VK_FORMAT_UNDEFINED;
mipmap_zero_total_bytes=0;
total_bytes=0;
}
virtual ~TextureLoader()=default;
virtual bool Load(io::InputStream *);
bool Load(const OSString &filename);

View File

@@ -5,7 +5,10 @@
VK_NAMESPACE_BEGIN
struct TextureCreateInfo
{
VkExtent3D extent;
VkImageViewType type;
VkExtent3D extent; //如为arrays,depth等同于layers
VkFormat format;
uint32_t usage;
uint32_t mipmap_zero_total_bytes;
@@ -149,15 +152,14 @@ public:
return(true);
}
bool SetData(GPUBuffer *buf,const uint32_t w,const uint32_t h)
bool SetData(GPUBuffer *buf,const VkExtent3D &ext)
{
if(!buf||w<=0||h<=0)return(false);
if(!buf)return(false);
if(ext.width<=0||ext.height<=0||ext.depth<=0)return(false);
buffer=buf;
extent.width=w;
extent.height=h;
extent.depth=1;
extent=ext;
return(true);
}