Textures: micro-optimization
This commit is contained in:
parent
21452fe6ee
commit
6243cc830d
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user