From 87efd0c25910ecad3d06882046c6a9abb2554b9e Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 23 Jul 2017 10:04:04 +1000 Subject: [PATCH] [Video] Change GrChipID_t to gfxChipID_t --- Source/Project64-video/Combine.cpp | 12 +-- Source/Project64-video/Combine.h | 4 +- Source/Project64-video/FBtoScreen.cpp | 66 +++++----------- Source/Project64-video/Main.cpp | 32 ++++---- .../Renderer/OGLEScombiner.cpp | 16 ++-- .../Renderer/OGLESglitchmain.cpp | 8 +- .../Renderer/OGLEStextures.cpp | 22 +++--- .../Project64-video/Renderer/OGLcombiner.cpp | 16 ++-- .../Renderer/OGLglitchmain.cpp | 8 +- .../Project64-video/Renderer/OGLtextures.cpp | 28 +++---- Source/Project64-video/Renderer/Renderer.h | 24 +++--- Source/Project64-video/Renderer/types.h | 7 ++ Source/Project64-video/TexBuffer.cpp | 10 +-- Source/Project64-video/TexCache.cpp | 79 +++++++++---------- Source/Project64-video/Util.cpp | 14 ++-- Source/Project64-video/rdp.cpp | 12 +-- Source/Project64-video/rdp.h | 8 +- Source/Project64-video/ucode06.cpp | 4 +- 18 files changed, 173 insertions(+), 197 deletions(-) diff --git a/Source/Project64-video/Combine.cpp b/Source/Project64-video/Combine.cpp index 73a0f43fb..4913748f1 100644 --- a/Source/Project64-video/Combine.cpp +++ b/Source/Project64-video/Combine.cpp @@ -16236,14 +16236,14 @@ void AlphaCombinerToExtension() } } -void TexColorCombinerToExtension(GrChipID_t tmu) +void TexColorCombinerToExtension(gfxChipID_t tmu) { uint32_t tc_ext_a, tc_ext_b, tc_ext_c, tc_ext_d; gfxCombineMode_t tc_ext_a_mode, tc_ext_b_mode; int tc_ext_c_invert, tc_ext_d_invert; uint32_t tmu_func, tmu_fac; - if (tmu == GR_TMU0) + if (tmu == GFX_TMU0) { tmu_func = cmb.tmu0_func; tmu_fac = cmb.tmu0_fac; @@ -16412,7 +16412,7 @@ void TexColorCombinerToExtension(GrChipID_t tmu) break; } - if (tmu == GR_TMU0) + if (tmu == GFX_TMU0) { cmb.t0c_ext_a = tc_ext_a; cmb.t0c_ext_a_mode = tc_ext_a_mode; @@ -16436,14 +16436,14 @@ void TexColorCombinerToExtension(GrChipID_t tmu) } } -void TexAlphaCombinerToExtension(GrChipID_t tmu) +void TexAlphaCombinerToExtension(gfxChipID_t tmu) { uint32_t ta_ext_a, ta_ext_b, ta_ext_c, ta_ext_d; gfxCombineMode_t ta_ext_a_mode, ta_ext_b_mode; int ta_ext_c_invert, ta_ext_d_invert; uint32_t tmu_a_func, tmu_a_fac; - if (tmu == GR_TMU0) + if (tmu == GFX_TMU0) { tmu_a_func = cmb.tmu0_a_func; tmu_a_fac = cmb.tmu0_a_fac; @@ -16576,7 +16576,7 @@ void TexAlphaCombinerToExtension(GrChipID_t tmu) break; } - if (tmu == GR_TMU0) + if (tmu == GFX_TMU0) { cmb.t0a_ext_a = ta_ext_a; cmb.t0a_ext_a_mode = ta_ext_a_mode; diff --git a/Source/Project64-video/Combine.h b/Source/Project64-video/Combine.h index 3fd0e5006..385dc20c6 100644 --- a/Source/Project64-video/Combine.h +++ b/Source/Project64-video/Combine.h @@ -96,7 +96,7 @@ void CountCombine(); void InitCombine(); void ColorCombinerToExtension(); void AlphaCombinerToExtension(); -void TexColorCombinerToExtension(GrChipID_t tmu); -void TexAlphaCombinerToExtension(GrChipID_t tmu); +void TexColorCombinerToExtension(gfxChipID_t tmu); +void TexAlphaCombinerToExtension(gfxChipID_t tmu); #endif //COMBINE _H diff --git a/Source/Project64-video/FBtoScreen.cpp b/Source/Project64-video/FBtoScreen.cpp index 659e41a66..80c6aaa6d 100644 --- a/Source/Project64-video/FBtoScreen.cpp +++ b/Source/Project64-video/FBtoScreen.cpp @@ -17,40 +17,28 @@ #include "TexCache.h" #include -static int SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaque) +static gfxChipID_t SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaque) { - int tmu; - if (voodoo.tmem_ptr[GR_TMU0] + texture_size < voodoo.tex_max_addr[0]) + gfxChipID_t tmu; + if (voodoo.tmem_ptr[GFX_TMU0] + texture_size < voodoo.tex_max_addr[0]) { - tmu = GR_TMU0; - gfxTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, - FXFALSE, - FXFALSE); - gfxTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, - FXFALSE); + tmu = GFX_TMU0; + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); } else { - if (voodoo.tmem_ptr[GR_TMU1] + texture_size >= voodoo.tex_max_addr[1]) + if (voodoo.tmem_ptr[GFX_TMU1] + texture_size >= voodoo.tex_max_addr[1]) ClearCache(); - tmu = GR_TMU1; - gfxTexCombine(GR_TMU1, + tmu = GFX_TMU1; + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_FUNCTION_SCALE_OTHER, @@ -147,7 +135,7 @@ static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info) } t_info.format = GFX_TEXFMT_RGB_565; t_info.data = tex; - int tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); + gfxChipID_t tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); gfxTexDownloadMipMap(tmu, voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, @@ -179,7 +167,7 @@ static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) uint16_t * tex = (uint16_t*)texture_buffer; t_info.data = tex; uint32_t tex_size = gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info); - int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); + gfxChipID_t tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); uint16_t * src = (uint16_t*)image; src += fb_info.ul_x + fb_info.ul_y * fb_info.width; uint32_t * src32 = (uint32_t*)image; @@ -364,15 +352,9 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info) t_info.data = tex; } - int tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); - gfxTexDownloadMipMap(tmu, - voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], - GR_MIPMAPLEVELMASK_BOTH, - &t_info); - gfxTexSource(tmu, - voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], - GR_MIPMAPLEVELMASK_BOTH, - &t_info); + gfxChipID_t tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); + gfxTexDownloadMipMap(tmu, voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); + gfxTexSource(tmu, voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); if (g_settings->hacks(CSettings::hack_RE2)) { DrawRE2Video(fb_info, scale); @@ -413,7 +395,7 @@ static void DrawDepthBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) uint16_t * tex = (uint16_t*)texture_buffer; t_info.data = tex; uint32_t tex_size = gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info); - int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); + gfxChipID_t tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); gfxConstantColorValue(rdp.fog_color); gfxColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, @@ -502,14 +484,14 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) gfxDepthBufferFunction(GR_CMP_ALWAYS); gfxDepthMask(FXFALSE); gfxCullMode(GR_CULL_DISABLE); - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, @@ -595,21 +577,15 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) t_info.format = GFX_TEXFMT_ALPHA_INTENSITY_88; t_info.data = tex; - int tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); + gfxChipID_t tmu = SetupFBtoScreenCombiner(gfxTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); gfxConstantColorValue(rdp.fog_color); gfxColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_LOCAL_NONE, GR_COMBINE_OTHER_CONSTANT, FXFALSE); - gfxTexDownloadMipMap(tmu, - voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], - GR_MIPMAPLEVELMASK_BOTH, - &t_info); - gfxTexSource(tmu, - voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], - GR_MIPMAPLEVELMASK_BOTH, - &t_info); + gfxTexDownloadMipMap(tmu, voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); + gfxTexSource(tmu, voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); float ul_x = fb_info.ul_x * rdp.scale_x + rdp.offset_x; float ul_y = fb_info.ul_y * rdp.scale_y + rdp.offset_y; float lr_x = fb_info.lr_x * rdp.scale_x + rdp.offset_x; diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index 91b3a4c8a..73f29033e 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -224,14 +224,14 @@ void guLoadTextures() int tbuf_size = 0; if (voodoo.max_tex_size <= 256) { - gfxTextureBufferExt(GR_TMU1, voodoo.tex_min_addr[GR_TMU1], GFX_LOD_LOG2_256, GFX_LOD_LOG2_256, + gfxTextureBufferExt(GFX_TMU1, voodoo.tex_min_addr[GFX_TMU1], GFX_LOD_LOG2_256, GFX_LOD_LOG2_256, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); tbuf_size = 8 * gfxTexCalcMemRequired(GFX_LOD_LOG2_256, GFX_LOD_LOG2_256, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565); } else if (g_scr_res_x <= 1024) { - gfxTextureBufferExt(GR_TMU0, voodoo.tex_min_addr[GR_TMU0], GFX_LOD_LOG2_1024, GFX_LOD_LOG2_1024, + gfxTextureBufferExt(GFX_TMU0, voodoo.tex_min_addr[GFX_TMU0], GFX_LOD_LOG2_1024, GFX_LOD_LOG2_1024, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); tbuf_size = gfxTexCalcMemRequired(GFX_LOD_LOG2_1024, GFX_LOD_LOG2_1024, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565); @@ -241,7 +241,7 @@ void guLoadTextures() } else { - gfxTextureBufferExt(GR_TMU0, voodoo.tex_min_addr[GR_TMU0], GFX_LOD_LOG2_2048, GFX_LOD_LOG2_2048, + gfxTextureBufferExt(GFX_TMU0, voodoo.tex_min_addr[GFX_TMU0], GFX_LOD_LOG2_2048, GFX_LOD_LOG2_2048, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); tbuf_size = gfxTexCalcMemRequired(GFX_LOD_LOG2_2048, GFX_LOD_LOG2_2048, GR_ASPECT_LOG2_1x1, GFX_TEXFMT_RGB_565); @@ -250,15 +250,15 @@ void guLoadTextures() gfxRenderBuffer(GFX_BUFFER_BACKBUFFER); } - rdp.texbufs[0].tmu = GR_TMU0; - rdp.texbufs[0].begin = voodoo.tex_min_addr[GR_TMU0]; + rdp.texbufs[0].tmu = GFX_TMU0; + rdp.texbufs[0].begin = voodoo.tex_min_addr[GFX_TMU0]; rdp.texbufs[0].end = rdp.texbufs[0].begin + tbuf_size; rdp.texbufs[0].count = 0; rdp.texbufs[0].clear_allowed = TRUE; offset_font = tbuf_size; if ((nbTextureUnits > 2 ? 2 : 1) > 1) { - rdp.texbufs[1].tmu = GR_TMU1; + rdp.texbufs[1].tmu = GFX_TMU1; rdp.texbufs[1].begin = rdp.texbufs[0].end; rdp.texbufs[1].end = rdp.texbufs[1].begin + tbuf_size; rdp.texbufs[1].count = 0; @@ -298,8 +298,8 @@ void guLoadTextures() } } - gfxTexDownloadMipMap(GR_TMU0, - voodoo.tex_min_addr[GR_TMU0] + offset_font, + gfxTexDownloadMipMap(GFX_TMU0, + voodoo.tex_min_addr[GFX_TMU0] + offset_font, GR_MIPMAPLEVELMASK_BOTH, &fontTex); @@ -326,8 +326,8 @@ void guLoadTextures() *(tex16++) = (uint16_t)(((cur & 0x00FF0000) >> 8) | ((cur & 0xFF000000) >> 24)); } - gfxTexDownloadMipMap(GR_TMU0, - voodoo.tex_min_addr[GR_TMU0] + offset_cursor, + gfxTexDownloadMipMap(GFX_TMU0, + voodoo.tex_min_addr[GFX_TMU0] + offset_cursor, GR_MIPMAPLEVELMASK_BOTH, &cursorTex); @@ -490,8 +490,8 @@ int InitGfx() gfxGet(GR_MAX_TEXTURE_SIZE, 4, (FxI32*)&voodoo.max_tex_size); voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !g_settings->hacks(CSettings::hack_PPL)); - voodoo.tex_min_addr[0] = voodoo.tex_min_addr[1] = gfxTexMinAddress(GR_TMU0); - voodoo.tex_max_addr[0] = voodoo.tex_max_addr[1] = gfxTexMaxAddress(GR_TMU0); + voodoo.tex_min_addr[0] = voodoo.tex_min_addr[1] = gfxTexMinAddress(GFX_TMU0); + voodoo.tex_max_addr[0] = voodoo.tex_max_addr[1] = gfxTexMaxAddress(GFX_TMU0); // Is mirroring allowed? if (!g_settings->hacks(CSettings::hack_Zelda)) //zelda's trees suffer from hardware mirroring @@ -550,10 +550,10 @@ int InitGfx() gfxBufferSwap(0); gfxBufferClear(0, 0, 0xFFFF); gfxDepthMask(FXFALSE); - gfxTexFilterMode(0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); - gfxTexFilterMode(1, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); - gfxTexClampMode(0, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); - gfxTexClampMode(1, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); + gfxTexFilterMode(GFX_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); + gfxTexFilterMode(GFX_TMU1, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); + gfxTexClampMode(GFX_TMU0, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); + gfxTexClampMode(GFX_TMU1, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); gfxClipWindow(0, 0, g_scr_res_x, g_scr_res_y); rdp.update |= UPDATE_SCISSOR | UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; diff --git a/Source/Project64-video/Renderer/OGLEScombiner.cpp b/Source/Project64-video/Renderer/OGLEScombiner.cpp index f046f5a05..3f2eca41e 100644 --- a/Source/Project64-video/Renderer/OGLEScombiner.cpp +++ b/Source/Project64-video/Renderer/OGLEScombiner.cpp @@ -1218,12 +1218,12 @@ void writeGLSLTextureAlphaFactor(int num_tex, int factor) } } -void gfxTexCombine(GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert) +void gfxTexCombine(gfxChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert) { WriteTrace(TraceGlitch, TraceDebug, "tmu: %d rgb_function: %d rgb_factor: %d alpha_function: %d alpha_factor: %d rgb_invert: %d alpha_invert: %d", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert); int num_tex; - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2051,7 +2051,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t need_to_compile = 1; } -void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert) +void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); @@ -2059,7 +2059,7 @@ void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_ if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : inverted result"); if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : shift = %d", shift); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2410,7 +2410,7 @@ void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_ need_to_compile = 1; } -void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert) +void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); @@ -2418,7 +2418,7 @@ void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_ if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : inverted result"); if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : shift = %d", shift); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2688,12 +2688,12 @@ void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_ need_to_compile = 1; } -void gfxConstantColorValueExt(GrChipID_t tmu, GrColor_t value) +void gfxConstantColorValueExt(gfxChipID_t tmu, GrColor_t value) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d value: %d", tmu, value); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; switch (lfb_color_fmt) diff --git a/Source/Project64-video/Renderer/OGLESglitchmain.cpp b/Source/Project64-video/Renderer/OGLESglitchmain.cpp index fea814536..13b3a8e21 100644 --- a/Source/Project64-video/Renderer/OGLESglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLESglitchmain.cpp @@ -563,7 +563,7 @@ bool gfxSstWinClose(GrContext_t context) return FXTRUE; } -void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd) +void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd) { int i; static int fbs_init = 0; @@ -648,7 +648,7 @@ void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, curBufferAddr = pBufferAddress = startAddress + 1; pBufferFmt = fmt; - int rtmu = startAddress < gfxTexMinAddress(GR_TMU1) ? 0 : 1; + int rtmu = startAddress < gfxTexMinAddress(GFX_TMU1) ? 0 : 1; int size = pBufferWidth*pBufferHeight * 2; //grTexFormatSize(fmt); if ((unsigned int)tmu_usage[rtmu].min > pBufferAddress) tmu_usage[rtmu].min = pBufferAddress; @@ -789,7 +789,7 @@ void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, } } -int CheckTextureBufferFormat(GrChipID_t tmu, uint32_t startAddress, GrTexInfo *info) +int CheckTextureBufferFormat(gfxChipID_t tmu, uint32_t startAddress, GrTexInfo *info) { int found, i; if (!use_fbo) { @@ -1296,7 +1296,7 @@ void gfxAuxBufferExt(GrBuffer_t buffer) glDisable(GL_CULL_FACE); //glDisable(GL_ALPHA_TEST); glDepthMask(GL_TRUE); - gfxTexFilterMode(GR_TMU1, GR_TEXTUREFILTER_POINT_SAMPLED, GR_TEXTUREFILTER_POINT_SAMPLED); + gfxTexFilterMode(GFX_TMU1, GR_TEXTUREFILTER_POINT_SAMPLED, GR_TEXTUREFILTER_POINT_SAMPLED); } else { glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/Source/Project64-video/Renderer/OGLEStextures.cpp b/Source/Project64-video/Renderer/OGLEStextures.cpp index 1ea4e6cd2..d797191a7 100644 --- a/Source/Project64-video/Renderer/OGLEStextures.cpp +++ b/Source/Project64-video/Renderer/OGLEStextures.cpp @@ -138,13 +138,13 @@ void free_textures() } } -uint32_t gfxTexMinAddress(GrChipID_t tmu) +uint32_t gfxTexMinAddress(gfxChipID_t tmu) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu); return 0; } -uint32_t gfxTexMaxAddress(GrChipID_t tmu) +uint32_t gfxTexMaxAddress(gfxChipID_t tmu) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu); return TMU_SIZE * 2 - 1; @@ -375,7 +375,7 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac */ } -void gfxTexDownloadMipMap(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) +void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd); int width, height, i, j; @@ -631,13 +631,13 @@ void gfxTexDownloadMipMap(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOd glBindTexture(GL_TEXTURE_2D, default_texture); } -int CheckTextureBufferFormat(GrChipID_t tmu, uint32_t startAddress, GrTexInfo *info); +int CheckTextureBufferFormat(gfxChipID_t tmu, uint32_t startAddress, GrTexInfo *info); -void gfxTexSource(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) +void gfxTexSource(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd); - if (tmu == GR_TMU1) + if (tmu == GFX_TMU1) { glActiveTexture(GL_TEXTURE0); @@ -694,7 +694,7 @@ void gfxTexSource(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTex } } -void gfxTexDetailControl(GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max) +void gfxTexDetailControl(gfxChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, lod_bias: %d detail_scale: %d detail_max: %d", tmu, lod_bias, detail_scale, detail_max); if (lod_bias != 31 && detail_scale != 7) @@ -713,10 +713,10 @@ void gfxTexDetailControl(GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float set_lambda(); } -void gfxTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode) +void gfxTexFilterMode(gfxChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %d magfilter_mode: %d", tmu, minfilter_mode, magfilter_mode); - if (tmu == GR_TMU1) + if (tmu == GFX_TMU1) { if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter0 = GL_NEAREST; else min_filter0 = GL_LINEAR; @@ -742,10 +742,10 @@ void gfxTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTe } } -void gfxTexClampMode(GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode) +void gfxTexClampMode(gfxChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, s_clampmode: %d t_clampmode: %d", tmu, s_clampmode, t_clampmode); - if (tmu == GR_TMU1) + if (tmu == GFX_TMU1) { switch (s_clampmode) { diff --git a/Source/Project64-video/Renderer/OGLcombiner.cpp b/Source/Project64-video/Renderer/OGLcombiner.cpp index 893c13f2a..36e28f9dc 100644 --- a/Source/Project64-video/Renderer/OGLcombiner.cpp +++ b/Source/Project64-video/Renderer/OGLcombiner.cpp @@ -1155,12 +1155,12 @@ void writeGLSLTextureAlphaFactor(int num_tex, int factor) } } -void gfxTexCombine(GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert) +void gfxTexCombine(gfxChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert) { WriteTrace(TraceGlitch, TraceDebug, "tmu: %d rgb_function: %d rgb_factor: %d alpha_function: %d alpha_factor: %d rgb_invert: %d alpha_invert: %d", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert); int num_tex; - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2014,7 +2014,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t need_to_compile = 1; } -void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert) +void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); @@ -2022,7 +2022,7 @@ void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_ if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : inverted result"); if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : shift = %d", shift); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2373,7 +2373,7 @@ void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_ need_to_compile = 1; } -void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert) +void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); @@ -2381,7 +2381,7 @@ void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_ if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : inverted result"); if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : shift = %d", shift); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; if (num_tex == 0) @@ -2651,12 +2651,12 @@ void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_ need_to_compile = 1; } -void gfxConstantColorValueExt(GrChipID_t tmu, GrColor_t value) +void gfxConstantColorValueExt(gfxChipID_t tmu, GrColor_t value) { int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d value: %d", tmu, value); - if (tmu == GR_TMU0) num_tex = 1; + if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; switch (lfb_color_fmt) diff --git a/Source/Project64-video/Renderer/OGLglitchmain.cpp b/Source/Project64-video/Renderer/OGLglitchmain.cpp index aa2b72141..c42dd166a 100644 --- a/Source/Project64-video/Renderer/OGLglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLglitchmain.cpp @@ -863,7 +863,7 @@ bool gfxSstWinClose(GrContext_t context) return FXTRUE; } -void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd) +void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd) { int i; static int fbs_init = 0; @@ -948,7 +948,7 @@ void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, curBufferAddr = pBufferAddress = startAddress + 1; pBufferFmt = fmt; - int rtmu = startAddress < gfxTexMinAddress(GR_TMU1) ? 0 : 1; + int rtmu = startAddress < gfxTexMinAddress(GFX_TMU1) ? 0 : 1; int size = pBufferWidth*pBufferHeight * 2; //grTexFormatSize(fmt); if (tmu_usage[rtmu].min > pBufferAddress + 0) tmu_usage[rtmu].min = pBufferAddress + 0; @@ -1093,7 +1093,7 @@ void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, } } -int CheckTextureBufferFormat(GrChipID_t tmu, uint32_t startAddress, GrTexInfo *info) +int CheckTextureBufferFormat(gfxChipID_t tmu, uint32_t startAddress, GrTexInfo *info) { int found, i; if (!use_fbo) { @@ -1589,7 +1589,7 @@ void gfxAuxBufferExt(GrBuffer_t buffer) glDisable(GL_CULL_FACE); glDisable(GL_ALPHA_TEST); glDepthMask(GL_TRUE); - gfxTexFilterMode(GR_TMU1, GR_TEXTUREFILTER_POINT_SAMPLED, GR_TEXTUREFILTER_POINT_SAMPLED); + gfxTexFilterMode(GFX_TMU1, GR_TEXTUREFILTER_POINT_SAMPLED, GR_TEXTUREFILTER_POINT_SAMPLED); } else { glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/Source/Project64-video/Renderer/OGLtextures.cpp b/Source/Project64-video/Renderer/OGLtextures.cpp index 25f9087e1..4c950048e 100644 --- a/Source/Project64-video/Renderer/OGLtextures.cpp +++ b/Source/Project64-video/Renderer/OGLtextures.cpp @@ -139,13 +139,13 @@ void free_textures() } } -uint32_t gfxTexMinAddress(GrChipID_t tmu) +uint32_t gfxTexMinAddress(gfxChipID_t tmu) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu); return 0; } -uint32_t gfxTexMaxAddress(GrChipID_t tmu) +uint32_t gfxTexMaxAddress(gfxChipID_t tmu) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu); return TMU_SIZE * 2 - 1; @@ -370,7 +370,7 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac return factor; } -void gfxTexDownloadMipMap(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) +void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd); @@ -627,15 +627,15 @@ void gfxTexDownloadMipMap(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOd grDisplayGLError("gfxTexDownloadMipMap"); } -int CheckTextureBufferFormat(GrChipID_t tmu, uint32_t startAddress, GrTexInfo *info); +int CheckTextureBufferFormat(gfxChipID_t tmu, uint32_t startAddress, GrTexInfo *info); -void gfxTexSource(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) +void gfxTexSource(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd); - if (tmu == GR_TMU1 || nbTextureUnits <= 2) + if (tmu == GFX_TMU1 || nbTextureUnits <= 2) { - if (tmu == GR_TMU1 && nbTextureUnits <= 2) return; + if (tmu == GFX_TMU1 && nbTextureUnits <= 2) return; glActiveTextureARB(GL_TEXTURE0_ARB); if (info->aspectRatioLog2 < 0) @@ -692,7 +692,7 @@ void gfxTexSource(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTex grDisplayGLError("gfxTexSource"); } -void gfxTexDetailControl(GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max) +void gfxTexDetailControl(gfxChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, lod_bias: %d detail_scale: %d detail_max: %d", tmu, lod_bias, detail_scale, detail_max); if (lod_bias != 31 && detail_scale != 7) @@ -711,12 +711,12 @@ void gfxTexDetailControl(GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float set_lambda(); } -void gfxTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode) +void gfxTexFilterMode(gfxChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %d magfilter_mode: %d", tmu, minfilter_mode, magfilter_mode); - if (tmu == GR_TMU1 || nbTextureUnits <= 2) + if (tmu == GFX_TMU1 || nbTextureUnits <= 2) { - if (tmu == GR_TMU1 && nbTextureUnits <= 2) return; + if (tmu == GFX_TMU1 && nbTextureUnits <= 2) return; if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter0 = GL_NEAREST; else min_filter0 = GL_LINEAR; @@ -742,12 +742,12 @@ void gfxTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTe grDisplayGLError("gfxTexFilterMode"); } -void gfxTexClampMode(GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode) +void gfxTexClampMode(gfxChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode) { WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, s_clampmode: %d t_clampmode: %d", tmu, s_clampmode, t_clampmode); - if (tmu == GR_TMU1 || nbTextureUnits <= 2) + if (tmu == GFX_TMU1 || nbTextureUnits <= 2) { - if (tmu == GR_TMU1 && nbTextureUnits <= 2) return; + if (tmu == GFX_TMU1 && nbTextureUnits <= 2) return; switch (s_clampmode) { case GR_TEXTURECLAMP_WRAP: diff --git a/Source/Project64-video/Renderer/Renderer.h b/Source/Project64-video/Renderer/Renderer.h index cdac10a91..c4931c48a 100644 --- a/Source/Project64-video/Renderer/Renderer.h +++ b/Source/Project64-video/Renderer/Renderer.h @@ -17,15 +17,15 @@ void gfxClipWindow(uint32_t minx, uint32_t miny, uint32_t maxx, uint32_t maxy); void gfxColorMask(bool rgb, bool a); -uint32_t gfxTexMinAddress(GrChipID_t tmu); +uint32_t gfxTexMinAddress(gfxChipID_t tmu); bool gfxSstWinClose(GrContext_t context); -void gfxTextureBufferExt(GrChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd); -uint32_t gfxTexMaxAddress(GrChipID_t tmu); +void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt, uint32_t evenOdd); +uint32_t gfxTexMaxAddress(gfxChipID_t tmu); uint32_t gfxTexTextureMemRequired(uint32_t evenOdd, GrTexInfo *info); void gfxConstantColorValue(GrColor_t value); void gfxColorCombine(GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, bool invert); void gfxAlphaCombine(GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, bool invert); -void gfxTexCombine(GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert); +void gfxTexCombine(gfxChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert); void gfxAlphaBlendFunction(GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df); void gfxAlphaTestReferenceValue(gfxAlpha_t value); void gfxAlphaTestFunction(GrCmpFnc_t function); @@ -37,9 +37,9 @@ void gfxChromakeyValue(GrColor_t value); void gfxStippleMode(GrStippleMode_t mode); void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t b, gfxCombineMode_t b_mode, gfxCCUColor_t c, bool c_invert, gfxCCUColor_t d, bool d_invert, uint32_t shift, bool invert); void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t b, gfxCombineMode_t b_mode, gfxACUColor_t c, bool c_invert, gfxACUColor_t d, bool d_invert, uint32_t shift, bool invert); -void gfxTexColorCombineExt(GrChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert); -void gfxTexAlphaCombineExt(GrChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert); -void gfxConstantColorValueExt(GrChipID_t tmu, GrColor_t value); +void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a_mode, gfxTCCUColor_t b, gfxCombineMode_t b_mode, gfxTCCUColor_t c, bool c_invert, gfxTCCUColor_t d, bool d_invert, uint32_t shift, bool invert); +void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a_mode, gfxTACUColor_t b, gfxCombineMode_t b_mode, gfxTACUColor_t c, bool c_invert, gfxTACUColor_t d, bool d_invert, uint32_t shift, bool invert); +void gfxConstantColorValueExt(gfxChipID_t tmu, GrColor_t value); void gfxVertexLayout(uint32_t param, FxI32 offset, uint32_t mode); void gfxCullMode(GrCullMode_t mode); void gfxDepthBufferMode(GrDepthBufferMode_t mode); @@ -66,11 +66,11 @@ uint32_t gfxTexCalcMemRequired(GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t a void gfxLoadGammaTable(uint32_t nentries, uint32_t *red, uint32_t *green, uint32_t *blue); void gfxGetGammaTableExt(uint32_t /*nentries*/, uint32_t *red, uint32_t *green, uint32_t *blue); void gfxGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB); -void gfxTexDownloadMipMap(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info); -void gfxTexSource(GrChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info); -void gfxTexDetailControl(GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max); -void gfxTexClampMode(GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode); -void gfxTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode); +void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info); +void gfxTexSource(gfxChipID_t tmu, uint32_t startAddress, uint32_t evenOdd, GrTexInfo *info); +void gfxTexDetailControl(gfxChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max); +void gfxTexClampMode(gfxChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode); +void gfxTexFilterMode(gfxChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode); extern uint32_t nbTextureUnits; extern uint32_t g_scr_res_x, g_scr_res_y, g_res_x, g_res_y; diff --git a/Source/Project64-video/Renderer/types.h b/Source/Project64-video/Renderer/types.h index 821848f79..c7d08fd8e 100644 --- a/Source/Project64-video/Renderer/types.h +++ b/Source/Project64-video/Renderer/types.h @@ -117,3 +117,10 @@ enum GFX_CMBX GFX_CMBX_TMU_CCOLOR = 0x11, }; +enum gfxChipID_t +{ + GFX_TMU0 = 0x0, + GFX_TMU1 = 0x1, + GFX_TMU2 = 0x2, +}; + diff --git a/Source/Project64-video/TexBuffer.cpp b/Source/Project64-video/TexBuffer.cpp index aed205859..fa41ffe93 100644 --- a/Source/Project64-video/TexBuffer.cpp +++ b/Source/Project64-video/TexBuffer.cpp @@ -351,16 +351,16 @@ static GrTextureFormat_t TexBufSetupCombiner(int force_rgb = FALSE) color_source = GR_COMBINE_FUNCTION_LOCAL_ALPHA; buf_format = GFX_TEXFMT_ALPHA_INTENSITY_88; } - if (rdp.tbuff_tex->tmu == GR_TMU0) + if (rdp.tbuff_tex->tmu == GFX_TMU0) { - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, color_source, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, @@ -370,14 +370,14 @@ static GrTextureFormat_t TexBufSetupCombiner(int force_rgb = FALSE) } else { - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, color_source, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, FXFALSE, FXTRUE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_FUNCTION_SCALE_OTHER, diff --git a/Source/Project64-video/TexCache.cpp b/Source/Project64-video/TexCache.cpp index d7657450e..fee017ea6 100644 --- a/Source/Project64-video/TexCache.cpp +++ b/Source/Project64-video/TexCache.cpp @@ -20,7 +20,7 @@ #include #include -void LoadTex(int id, int tmu); +void LoadTex(int id, gfxChipID_t tmu); uint8_t tex1[1024 * 1024 * 4]; // temporary texture uint8_t tex2[1024 * 1024 * 4]; @@ -463,21 +463,12 @@ void GetTexInfo(int id, int tile) WriteTrace(TraceRDP, TraceDebug, " | | | +- Done.\n | | +- GetTexInfo end"); } -//**************************************************************** -// ChooseBestTmu - chooses the best TMU to load to (the one with the most memory) - -int ChooseBestTmu(int tmu1, int tmu2) -{ - if (!GfxInitDone) return tmu1; - return 0; -} - //**************************************************************** // SelectTBuffTex - select texture from texture buffer static void SelectTBuffTex(TBUFF_COLOR_IMAGE * pTBuffTex) { WriteTrace(TraceRDP, TraceDebug, "SelectTBuffTex: tex: %d, tmu: %d, tile: %d", rdp.tex, pTBuffTex->tmu, pTBuffTex->tile); - gfxTexSource(pTBuffTex->tile, pTBuffTex->tex_addr, GR_MIPMAPLEVELMASK_BOTH, &(pTBuffTex->info)); + gfxTexSource(pTBuffTex->tmu, pTBuffTex->tex_addr, GR_MIPMAPLEVELMASK_BOTH, &(pTBuffTex->info)); } //**************************************************************** @@ -502,53 +493,52 @@ void TexCache() #define TMUMODE_PASSTHRU 1 #define TMUMODE_NONE 2 - int tmu_0, tmu_1; + gfxChipID_t tmu_0, tmu_1; int tmu_0_mode = 0, tmu_1_mode = 0; // Select the best TMUs to use (removed 3 tmu support, unnecessary) if (rdp.tex == 3) // T0 and T1 { - tmu_0 = 0; - tmu_1 = 1; + tmu_0 = GFX_TMU0; + tmu_1 = GFX_TMU1; } else if (rdp.tex == 2) // T1 { if (tex_found[1][0] != -1) // T1 found in tmu 0 - tmu_1 = 0; + tmu_1 = GFX_TMU0; else if (tex_found[1][1] != -1) // T1 found in tmu 1 - tmu_1 = 1; + tmu_1 = GFX_TMU1; else // T1 not found - tmu_1 = ChooseBestTmu(0, 1); + tmu_1 = GFX_TMU0; - tmu_0 = !tmu_1; + tmu_0 = tmu_1 == GFX_TMU0 ? GFX_TMU0 : GFX_TMU1; tmu_0_mode = (tmu_0 == 1) ? TMUMODE_NONE : TMUMODE_PASSTHRU; } else if (rdp.tex == 1) // T0 { if (tex_found[0][0] != -1) // T0 found in tmu 0 - tmu_0 = 0; + tmu_0 = GFX_TMU0; else if (tex_found[0][1] != -1) // T0 found in tmu 1 - tmu_0 = 1; + tmu_0 = GFX_TMU1; else // T0 not found - tmu_0 = ChooseBestTmu(0, 1); + tmu_0 = GFX_TMU0; - tmu_1 = !tmu_0; + tmu_1 = tmu_0 == GFX_TMU0 ? GFX_TMU1 : GFX_TMU0; tmu_1_mode = (tmu_1 == 1) ? TMUMODE_NONE : TMUMODE_PASSTHRU; } else // no texture { - tmu_0 = 0; + tmu_0 = GFX_TMU0; tmu_0_mode = TMUMODE_NONE; - tmu_1 = 0; + tmu_1 = GFX_TMU0; tmu_1_mode = TMUMODE_NONE; } - WriteTrace(TraceRDP, TraceDebug, " | |-+ Modes set:\n | | |- tmu_0 = %d\n | | |- tmu_1 = %d", - tmu_0, tmu_1); - WriteTrace(TraceRDP, TraceDebug, " | | |- tmu_0_mode = %d\n | | |- tmu_1_mode = %d", - tmu_0_mode, tmu_1_mode); + WriteTrace(TraceRDP, TraceDebug, " | |-+ Modes set:\n | | |- tmu_0 = %d\n | | |- tmu_1 = %d", tmu_0, tmu_1); + WriteTrace(TraceRDP, TraceDebug, " | | |- tmu_0_mode = %d\n | | |- tmu_1_mode = %d", tmu_0_mode, tmu_1_mode); - if (tmu_0_mode == TMUMODE_PASSTHRU) { + if (tmu_0_mode == TMUMODE_PASSTHRU) + { cmb.tmu0_func = cmb.tmu0_a_func = GR_COMBINE_FUNCTION_SCALE_OTHER; cmb.tmu0_fac = cmb.tmu0_a_fac = GR_COMBINE_FACTOR_ONE; if (cmb.tex_cmb_ext_use) @@ -571,7 +561,8 @@ void TexCache() cmb.t0a_ext_d_invert = 0; } } - else if (tmu_0_mode == TMUMODE_NONE) { + else if (tmu_0_mode == TMUMODE_NONE) + { cmb.tmu0_func = cmb.tmu0_a_func = GR_COMBINE_FUNCTION_NONE; cmb.tmu0_fac = cmb.tmu0_a_fac = GR_COMBINE_FACTOR_NONE; if (cmb.tex_cmb_ext_use) @@ -594,7 +585,8 @@ void TexCache() cmb.t0a_ext_d_invert = 0; } } - if (tmu_1_mode == TMUMODE_PASSTHRU) { + if (tmu_1_mode == TMUMODE_PASSTHRU) + { cmb.tmu1_func = cmb.tmu1_a_func = GR_COMBINE_FUNCTION_SCALE_OTHER; cmb.tmu1_fac = cmb.tmu1_a_fac = GR_COMBINE_FACTOR_ONE; if (cmb.tex_cmb_ext_use) @@ -617,7 +609,8 @@ void TexCache() cmb.t1a_ext_d_invert = 0; } } - else if (tmu_1_mode == TMUMODE_NONE) { + else if (tmu_1_mode == TMUMODE_NONE) + { cmb.tmu1_func = cmb.tmu1_a_func = GR_COMBINE_FUNCTION_NONE; cmb.tmu1_fac = cmb.tmu1_a_fac = GR_COMBINE_FACTOR_NONE; if (cmb.tex_cmb_ext_use) @@ -649,15 +642,15 @@ void TexCache() { cmb.tmu0_func = cmb.tmu0_a_func = GR_COMBINE_FUNCTION_LOCAL; cmb.tmu0_fac = cmb.tmu0_a_fac = GR_COMBINE_FACTOR_NONE; - tmu_0 = 0; - tmu_1 = 1; + tmu_0 = GFX_TMU0; + tmu_1 = GFX_TMU1; } else { cmb.tmu1_func = cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL; cmb.tmu1_fac = cmb.tmu1_a_fac = GR_COMBINE_FACTOR_NONE; - tmu_1 = 0; - tmu_0 = 1; + tmu_1 = GFX_TMU0; + tmu_0 = GFX_TMU1; } } @@ -697,9 +690,9 @@ void TexCache() { WriteTrace(TraceRDP, TraceDebug, " | | | |- combiner extension tmu1"); if (!(cmb.tex_cmb_ext_use & TEX_COMBINE_EXT_COLOR)) - TexColorCombinerToExtension(GR_TMU1); + TexColorCombinerToExtension(GFX_TMU1); if (!(cmb.tex_cmb_ext_use & TEX_COMBINE_EXT_ALPHA)) - TexAlphaCombinerToExtension(GR_TMU1); + TexAlphaCombinerToExtension(GFX_TMU1); gfxTexColorCombineExt(tmu_1, cmb.t1c_ext_a, cmb.t1c_ext_a_mode, cmb.t1c_ext_b, cmb.t1c_ext_b_mode, cmb.t1c_ext_c, cmb.t1c_ext_c_invert, cmb.t1c_ext_d, cmb.t1c_ext_d_invert, 0, 0); gfxTexAlphaCombineExt(tmu_1, cmb.t1a_ext_a, cmb.t1a_ext_a_mode, cmb.t1a_ext_b, cmb.t1a_ext_b_mode, cmb.t1a_ext_c, cmb.t1a_ext_c_invert, cmb.t1a_ext_d, cmb.t1a_ext_d_invert, 0, 0); gfxConstantColorValueExt(tmu_1, cmb.tex_ccolor); @@ -721,11 +714,11 @@ void TexCache() WriteTrace(TraceRDP, TraceDebug, " | | | |- combiner extension tmu0"); if (!(cmb.tex_cmb_ext_use & TEX_COMBINE_EXT_COLOR)) { - TexColorCombinerToExtension(GR_TMU0); + TexColorCombinerToExtension(GFX_TMU0); } if (!(cmb.tex_cmb_ext_use & TEX_COMBINE_EXT_ALPHA)) { - TexAlphaCombinerToExtension(GR_TMU0); + TexAlphaCombinerToExtension(GFX_TMU0); } gfxTexColorCombineExt(tmu_0, cmb.t0c_ext_a, cmb.t0c_ext_a_mode, cmb.t0c_ext_b, cmb.t0c_ext_b_mode, cmb.t0c_ext_c, cmb.t0c_ext_c_invert, cmb.t0c_ext_d, cmb.t0c_ext_d_invert, 0, 0); gfxTexAlphaCombineExt(tmu_0, cmb.t0a_ext_a, cmb.t0a_ext_a_mode, cmb.t0a_ext_b, cmb.t0a_ext_b_mode, cmb.t0a_ext_c, cmb.t0a_ext_c_invert, cmb.t0a_ext_d, cmb.t0a_ext_d_invert, 0, 0); @@ -808,13 +801,13 @@ void TexCache() if (GfxInitDone) { - int tmu_v[2]; + gfxChipID_t tmu_v[2]; tmu_v[0] = tmu_0; tmu_v[1] = tmu_1; for (int i = 0; i < 2; i++) { - const int tmu = tmu_v[i]; + const gfxChipID_t tmu = tmu_v[i]; if (tmu >= (nbTextureUnits > 2 ? 2 : 1)) continue; @@ -925,7 +918,7 @@ inline uint32_t ReverseDXT(uint32_t val, uint32_t /*lrs*/, uint32_t width, uint3 //**************************************************************** // LoadTex - does the actual texture loading after everything is prepared -void LoadTex(int id, int tmu) +void LoadTex(int id, gfxChipID_t tmu) { WriteTrace(TraceRDP, TraceDebug, " | |-+ LoadTex (id: %d, tmu: %d)", id, tmu); diff --git a/Source/Project64-video/Util.cpp b/Source/Project64-video/Util.cpp index 344cbce88..944af6272 100644 --- a/Source/Project64-video/Util.cpp +++ b/Source/Project64-video/Util.cpp @@ -977,9 +977,9 @@ static void CalculateLOD(VERTEX *v, int n) detailmax = lod_fraction; else detailmax = 1.0f - lod_fraction; - gfxTexDetailControl(GR_TMU0, cmb.dc0_lodbias, cmb.dc0_detailscale, detailmax); + gfxTexDetailControl(GFX_TMU0, cmb.dc0_lodbias, cmb.dc0_detailscale, detailmax); if ((nbTextureUnits > 2 ? 2 : 1) == 2) - gfxTexDetailControl(GR_TMU1, cmb.dc1_lodbias, cmb.dc1_detailscale, detailmax); + gfxTexDetailControl(GFX_TMU1, cmb.dc1_lodbias, cmb.dc1_detailscale, detailmax); WriteTrace(TraceRDP, TraceDebug, "CalculateLOD factor: %f, tile: %d, lod_fraction: %f", (float)lodFactor, lod_tile, lod_fraction); } @@ -1968,21 +1968,21 @@ void set_message_combiner() GR_BLEND_ZERO); gfxAlphaTestFunction(GR_CMP_ALWAYS); gfxStippleMode(GR_STIPPLE_DISABLE); - gfxTexFilterMode(0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); - gfxTexCombine(GR_TMU1, + gfxTexFilterMode(GFX_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexSource(GR_TMU0, - voodoo.tex_min_addr[GR_TMU0] + offset_font, + gfxTexSource(GFX_TMU0, + voodoo.tex_min_addr[GFX_TMU0] + offset_font, GR_MIPMAPLEVELMASK_BOTH, &fontTex); gfxFogMode(GR_FOG_DISABLE); diff --git a/Source/Project64-video/rdp.cpp b/Source/Project64-video/rdp.cpp index 7a51b3e11..7d8b2b417 100644 --- a/Source/Project64-video/rdp.cpp +++ b/Source/Project64-video/rdp.cpp @@ -335,8 +335,8 @@ void CRDP::free() last_tile = 0; last_tile_size = 0; - t0 = GR_TMU0; - t1 = GR_TMU0; + t0 = GFX_TMU0; + t1 = GFX_TMU0; best_tex = 0; tex = 0; filter_mode = 0; @@ -3132,13 +3132,13 @@ void SetWireframeCol() GR_BLEND_ZERO, GR_BLEND_ZERO, GR_BLEND_ZERO); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, @@ -3161,13 +3161,13 @@ void SetWireframeCol() GR_BLEND_ZERO, GR_BLEND_ZERO, GR_BLEND_ZERO); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_ZERO, diff --git a/Source/Project64-video/rdp.h b/Source/Project64-video/rdp.h index 7a811eaad..3ead0a129 100644 --- a/Source/Project64-video/rdp.h +++ b/Source/Project64-video/rdp.h @@ -14,7 +14,7 @@ #pragma once #include -#include "glide.h" +#include extern char out_buf[2048]; @@ -308,7 +308,7 @@ typedef struct typedef struct { - GrChipID_t tmu; + gfxChipID_t tmu; uint32_t addr; //address of color image uint32_t end_addr; uint32_t tex_addr; //address in video memory @@ -339,7 +339,7 @@ typedef struct typedef struct { - GrChipID_t tmu; + gfxChipID_t tmu; uint32_t begin; //start of the block in video memory uint32_t end; //end of the block in video memory uint8_t count; //number of allocated texture buffers @@ -485,7 +485,7 @@ public: int last_tile; // last tile set int last_tile_size; // last tile size set - int t0, t1; + gfxChipID_t t0, t1; int best_tex; // if no 2-tmus, which texture? (0 or 1) int tex; int filter_mode; diff --git a/Source/Project64-video/ucode06.cpp b/Source/Project64-video/ucode06.cpp index f403c48a1..952477de2 100644 --- a/Source/Project64-video/ucode06.cpp +++ b/Source/Project64-video/ucode06.cpp @@ -144,14 +144,14 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) rdp.texbufs[1].begin, GR_MIPMAPLEVELMASK_BOTH, &t_info); - gfxTexCombine(GR_TMU1, + gfxTexCombine(GFX_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - gfxTexCombine(GR_TMU0, + gfxTexCombine(GFX_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_FUNCTION_SCALE_OTHER,