125 return (31-__builtin_clz(width < height ? width : height)) - 3;
136 return size >> (2*level);
177 (C3D_TexInitParams){ width, height, 0, format,
GPU_TEX_2D,
false });
221 (C3D_TexInitParams){ width, height, 0, format,
GPU_TEX_2D,
true });
271 if (!level)
return data;
329 tex->param &= ~GPU_TEXTURE_MIP_FILTER(
GPU_LINEAR);
352 int iLodBias = (int)(lodBias*0x100);
353 if (iLodBias > 0xFFF)
355 else if (iLodBias < -0x1000)
357 tex->lodBias = iLodBias & 0x1FFF;
#define GPU_TEXTURE_MAG_FILTER(v)
#define GPU_TEXTURE_MIP_FILTER(v)
#define GPU_TEXTURE_WRAP_S(v)
#define GPU_TEXTURE_WRAP_T(v)
#define GPU_TEXTURE_MIN_FILTER(v)
Cubemap texture data.
Definition texture.h:10
Texture data.
Definition texture.h:16
static bool C3D_TexInit(C3D_Tex *tex, u16 width, u16 height, GPU_TEXCOLOR format)
Initializes standard 2D texture.
Definition texture.h:174
static bool C3D_TexInitShadow(C3D_Tex *tex, u16 width, u16 height)
Initializes 2D shadowmap texture.
Definition texture.h:231
static void * C3D_TexGetImagePtr(C3D_Tex *tex, void *data, int level, u32 *size)
Gets pointer to texture image.
Definition texture.h:268
static bool C3D_TexInitMipmap(C3D_Tex *tex, u16 width, u16 height, GPU_TEXCOLOR format)
Initializes standard 2D texture with mipmap Maximum miplevel is calculated using C3D_TexCalcMaxLevel(...
Definition texture.h:189
struct CTR_ALIGN(8)
Parameters for C3D_TexInitWithParams()
Definition texture.h:51
void C3D_TexFlush(C3D_Tex *tex)
Flushes texture data from cache into memory.
void C3D_TexBind(int unitId, C3D_Tex *tex)
Binds C3D_Tex to texture unit.
static void * C3D_Tex2DGetImagePtr(C3D_Tex *tex, int level, u32 *size)
Gets pointer to 2D texture image.
Definition texture.h:282
static int C3D_TexCalcMaxLevel(u32 width, u32 height)
Calculates maximum mipmap level for given texture size.
Definition texture.h:123
static void C3D_TexUpload(C3D_Tex *tex, const void *data)
Copies raw texture data into standard 2D texture.
Definition texture.h:305
static bool C3D_TexInitVRAM(C3D_Tex *tex, u16 width, u16 height, GPU_TEXCOLOR format)
Initializes 2D texture in VRAM.
Definition texture.h:218
static GPU_TEXTURE_MODE_PARAM C3D_TexGetType(C3D_Tex *tex)
Gets type of texture.
Definition texture.h:255
static bool C3D_TexInitCube(C3D_Tex *tex, C3D_TexCube *cube, u16 width, u16 height, GPU_TEXCOLOR format)
Initializes cubemap texture.
Definition texture.h:204
static void C3D_TexSetFilter(C3D_Tex *tex, GPU_TEXTURE_FILTER_PARAM magFilter, GPU_TEXTURE_FILTER_PARAM minFilter)
Configures texture magnification and minification filters.
Definition texture.h:316
static void C3D_TexSetLodBias(C3D_Tex *tex, float lodBias)
Configures texture level of detail bias used to select the correct mipmap during sampling.
Definition texture.h:350
void C3D_TexGenerateMipmap(C3D_Tex *tex, GPU_TEXFACE face)
Generates mipmaps for C3D_Tex using previously specified max level The max level should have been spe...
void C3D_TexLoadImage(C3D_Tex *tex, const void *data, GPU_TEXFACE face, int level)
Copies raw texture data into C3D_Tex.
static void C3D_TexSetFilterMipmap(C3D_Tex *tex, GPU_TEXTURE_FILTER_PARAM filter)
Configures texture mipmap minification filters.
Definition texture.h:327
void C3D_TexShadowParams(bool perspective, float bias)
Configues texunit0 shadow depth texture properties.
static u32 C3D_TexCalcTotalSize(u32 size, int maxLevel)
Calculates total size of mipmap texture data.
Definition texture.h:145
void C3D_TexDelete(C3D_Tex *tex)
Deletes texture data.
static bool C3D_TexInitShadowCube(C3D_Tex *tex, C3D_TexCube *cube, u16 width, u16 height)
Initializes shadowmap cubemap texture.
Definition texture.h:245
static void C3D_TexSetWrap(C3D_Tex *tex, GPU_TEXTURE_WRAP_PARAM wrapS, GPU_TEXTURE_WRAP_PARAM wrapT)
Configures texture wrapping options.
Definition texture.h:339
static u32 C3D_TexCalcLevelSize(u32 size, int level)
Calculates size of mipmap level.
Definition texture.h:134
static void * C3D_TexCubeGetImagePtr(C3D_Tex *tex, GPU_TEXFACE face, int level, u32 *size)
Gets pointer to cubemap texture image.
Definition texture.h:295
bool C3D_TexInitWithParams(C3D_Tex *tex, C3D_TexCube *cube, C3D_TexInitParams p)
Initializes texture with specified parameters.