Textures: micro-optimization

This commit is contained in:
fincs 2015-07-23 22:22:28 +02:00
parent 21452fe6ee
commit 6243cc830d
2 changed files with 8 additions and 6 deletions

View File

@ -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);

View File

@ -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;
}