diff --git a/gx/gx_video.c b/gx/gx_video.c index c2d1426d49..73c8c46fec 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -318,27 +318,27 @@ static void setup_video_mode(void *data) static void init_texture(void *data, unsigned width, unsigned height) { + unsigned g_filter, rgui_w, rgui_h; struct __gx_regdef *__gx = (struct __gx_regdef*)__gxregs; + gx_video_t *gx = (gx_video_t*)data; + width &= ~3; height &= ~3; - gx_video_t *gx = (gx_video_t*)data; - unsigned g_filter = g_settings.video.smooth ? GX_LINEAR : GX_NEAR; - unsigned rgui_w, rgui_h; + g_filter = g_settings.video.smooth ? GX_LINEAR : GX_NEAR; + rgui_w = 320; + rgui_h = 240; if (rgui) { rgui_w = rgui->width; rgui_h = rgui->height; } - else - { - rgui_w = 320; - rgui_h = 240; - } - GX_InitTexObj(&g_tex.obj, g_tex.data, width, height, (gx->rgb32) ? GX_TF_RGBA8 : gx->rgui_texture_enable ? GX_TF_RGB5A3 : GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + struct __gx_texobj *fb_ptr = (struct __gx_texobj*)&g_tex.obj; + struct __gx_texobj *menu_ptr = (struct __gx_texobj*)&menu_tex.obj; + __GX_InitTexObj(fb_ptr, g_tex.data, width, height, (gx->rgb32) ? GX_TF_RGBA8 : gx->rgui_texture_enable ? GX_TF_RGB5A3 : GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjFilterMode(&g_tex.obj, g_filter, g_filter); - GX_InitTexObj(&menu_tex.obj, menu_tex.data, rgui_w, rgui_h, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE); + __GX_InitTexObj(menu_ptr, menu_tex.data, rgui_w, rgui_h, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjFilterMode(&menu_tex.obj, g_filter, g_filter); __GX_InvalidateTexAll(__gx); } @@ -375,6 +375,9 @@ static void init_vtx(void *data) g_tex.data = memalign(32, 4 * 4 * 4); memset(g_tex.data, 0, 4 * 4 * 4); + memset(&g_tex.obj, 0, sizeof(GXTexObj)); + memset(&menu_tex.obj, 0, sizeof(GXTexObj)); + DCFlushRange(g_tex.data, 4 * 4 * 4); init_texture(data, 4, 4); // for menu texture GX_Flush(); diff --git a/gx/gx_video_inl.h b/gx/gx_video_inl.h index 388a70a907..6fdc79e284 100644 --- a/gx/gx_video_inl.h +++ b/gx/gx_video_inl.h @@ -195,6 +195,24 @@ static inline void __GX_CopyDisp(struct __gx_regdef *__gx, void *dest,u8 clear) } } +#define XSHIFT 2 +#define YSHIFT 2 + +#define __GX_InitTexObj(ptr, img_ptr, wd, ht, fmt, wrap_s, wrap_t, mipmap) \ + ptr->tex_filt = (ptr->tex_filt&~0x03)|(wrap_s&3); \ + ptr->tex_filt = (ptr->tex_filt&~0x0c)|(_SHIFTL(wrap_t,2,2)); \ + ptr->tex_filt = (ptr->tex_filt&~0x10)|0x10; \ + /* no mip-mapping */ \ + ptr->tex_filt= (ptr->tex_filt&~0xE0)|0x0080; \ + ptr->tex_fmt = fmt; \ + ptr->tex_size = (ptr->tex_size&~0x3ff)|((wd-1)&0x3ff); \ + ptr->tex_size = (ptr->tex_size&~0xFFC00)|(_SHIFTL((ht-1),10,10)); \ + ptr->tex_size = (ptr->tex_size&~0xF00000)|(_SHIFTL(fmt,20,4)); \ + ptr->tex_maddr = (ptr->tex_maddr&~0x01ffffff)|(_SHIFTR(MEM_VIRTUAL_TO_PHYSICAL(img_ptr),5,24)); \ + ptr->tex_tile_type = 2; \ + ptr->tex_tile_cnt = ((((wd+(1 << XSHIFT))-1) >> XSHIFT) * (((ht+(1 << YSHIFT))-1) >> YSHIFT)) & 0x7fff; \ + ptr->tex_flag |= 0x0002 + #define __GX_InvalidateTexAll(__gx) \ GX_LOAD_BP_REG(__gx->tevIndMask); \