N64: WIP texture filtering

This commit is contained in:
UnknownShadow200 2025-07-17 19:53:11 +10:00
parent a52fdf90e7
commit 19a4cb61ea
2 changed files with 25 additions and 2 deletions

View File

@ -110,6 +110,11 @@ static void gpuSetTexSize(uint16_t width, uint16_t height)
gpu_set_word(offsetof(gpu_state, tex_size[0]), (width << 16) | height); gpu_set_word(offsetof(gpu_state, tex_size[0]), (width << 16) | height);
} }
static void gpuSetTexOffset(uint16_t width, uint16_t height)
{
gpu_set_word(offsetof(gpu_state, tex_offset[0]), (width << 16) | height);
}
static inline void write_shorts(rspq_write_t *w, const uint16_t *s, uint32_t count) static inline void write_shorts(rspq_write_t *w, const uint16_t *s, uint32_t count)
{ {

View File

@ -225,8 +225,26 @@ void Gfx_DeleteTexture(GfxResourceID* texId) {
*texId = NULL; *texId = NULL;
} }
void Gfx_EnableMipmaps(void) { } static cc_bool bilinear_mode;
void Gfx_DisableMipmaps(void) { } static void SetFilterMode(cc_bool bilinear) {
if (bilinear_mode == bilinear) return;
bilinear_mode = bilinear;
uint64_t mode = bilinear ? FILTER_BILINEAR : FILTER_POINT;
__rdpq_mode_change_som(SOM_SAMPLE_MASK, mode << SOM_SAMPLE_SHIFT);
int offset = bilinear ? -((1 << TEX_SHIFT) / 2) : 0;
gpuSetTexOffset(offset, offset);
}
void Gfx_EnableMipmaps(void) {
// TODO move back to texture instead?
SetFilterMode(Gfx.Mipmaps);
}
void Gfx_DisableMipmaps(void) {
SetFilterMode(FILTER_POINT);
}
/*########################################################################################################################* /*########################################################################################################################*