diff --git a/include/c3d/texture.h b/include/c3d/texture.h index 139d720..8a77ccd 100644 --- a/include/c3d/texture.h +++ b/include/c3d/texture.h @@ -4,11 +4,12 @@ typedef struct { void* data; - size_t size; + + GPU_TEXCOLOR fmt : 4; + size_t size : 28; u16 width, height; u32 param; - GPU_TEXCOLOR fmt; } C3D_Tex; bool C3D_TexInit(C3D_Tex* tex, int width, int height, GPU_TEXCOLOR format); diff --git a/source/texture.c b/source/texture.c index f0c3abc..348cd9a 100644 --- a/source/texture.c +++ b/source/texture.c @@ -22,17 +22,18 @@ bool C3D_TexInit(C3D_Tex* tex, int width, int height, GPU_TEXCOLOR format) { if (tex->data) return false; - tex->size = fmtSize(format); - if (!tex->size) return false; - tex->size *= width * height; + u32 size = fmtSize(format); + if (!size) return false; + size *= width * height; - tex->data = linearMemAlign(tex->size, 0x80); + tex->data = linearMemAlign(size, 0x80); if (!tex->data) return false; tex->width = width; tex->height = height; tex->param = GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST); tex->fmt = format; + tex->size = size; return true; }