[Video[ remove voodoo.num_tmu

This commit is contained in:
zilmar 2017-05-17 18:01:54 +10:00
parent f6915aa608
commit 9e0a875290
17 changed files with 802 additions and 957 deletions

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include <string.h> #include <string.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "Util.h" #include "Util.h"
@ -122,7 +123,7 @@ COMBINE cmb;
cmb.tex |= 1, \ cmb.tex |= 1, \
cmb.tmu0_func = GR_COMBINE_FUNCTION_LOCAL cmb.tmu0_func = GR_COMBINE_FUNCTION_LOCAL
#define USE_T1() \ #define USE_T1() \
if (voodoo.num_tmu > 1) { \ if ((nbTextureUnits > 2 ? 2 : 1) > 1) { \
rdp.best_tex = 1; \ rdp.best_tex = 1; \
cmb.tex |= 2, \ cmb.tex |= 2, \
cmb.tmu1_func = GR_COMBINE_FUNCTION_LOCAL, \ cmb.tmu1_func = GR_COMBINE_FUNCTION_LOCAL, \
@ -467,7 +468,7 @@ COMBINE cmb;
cmb.tex |= 1, \ cmb.tex |= 1, \
cmb.tmu0_a_func = GR_COMBINE_FUNCTION_LOCAL cmb.tmu0_a_func = GR_COMBINE_FUNCTION_LOCAL
#define A_USE_T1() \ #define A_USE_T1() \
if (voodoo.num_tmu > 1) { \ if ((nbTextureUnits > 2 ? 2 : 1) > 1) { \
cmb.tex |= 2, \ cmb.tex |= 2, \
cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL, \ cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_a_func = GR_COMBINE_FUNCTION_SCALE_OTHER, \ cmb.tmu0_a_func = GR_COMBINE_FUNCTION_SCALE_OTHER, \

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include <string.h> #include <string.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
@ -268,7 +269,7 @@ void guLoadTextures()
rdp.texbufs[0].count = 0; rdp.texbufs[0].count = 0;
rdp.texbufs[0].clear_allowed = TRUE; rdp.texbufs[0].clear_allowed = TRUE;
offset_font = tbuf_size; offset_font = tbuf_size;
if (voodoo.num_tmu > 1) if ((nbTextureUnits > 2 ? 2 : 1) > 1)
{ {
rdp.texbufs[1].tmu = GR_TMU1; rdp.texbufs[1].tmu = GR_TMU1;
rdp.texbufs[1].begin = voodoo.tex_UMA ? rdp.texbufs[0].end : voodoo.tex_min_addr[GR_TMU1]; rdp.texbufs[1].begin = voodoo.tex_UMA ? rdp.texbufs[0].end : voodoo.tex_min_addr[GR_TMU1];
@ -534,13 +535,10 @@ int InitGfx()
GfxInitDone = TRUE; GfxInitDone = TRUE;
to_fullscreen = FALSE; to_fullscreen = FALSE;
// get the # of TMUs available
grGet(GR_NUM_TMU, 4, (FxI32*)&voodoo.num_tmu);
// get maximal texture size // get maximal texture size
grGet(GR_MAX_TEXTURE_SIZE, 4, (FxI32*)&voodoo.max_tex_size); grGet(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.sup_large_tex = (voodoo.max_tex_size > 256 && !g_settings->hacks(CSettings::hack_PPL));
//num_tmu = 1;
if (voodoo.tex_UMA) if (voodoo.tex_UMA)
{ {
GetTexAddr = GetTexAddrUMA; GetTexAddr = GetTexAddrUMA;
@ -576,12 +574,10 @@ int InitGfx()
InitCombine(); InitCombine();
#ifdef SIMULATE_VOODOO1 #ifdef SIMULATE_VOODOO1
voodoo.num_tmu = 1;
voodoo.sup_mirroring = 0; voodoo.sup_mirroring = 0;
#endif #endif
#ifdef SIMULATE_BANSHEE #ifdef SIMULATE_BANSHEE
voodoo.num_tmu = 1;
voodoo.sup_mirroring = 1; voodoo.sup_mirroring = 1;
#endif #endif
@ -986,7 +982,6 @@ that there is a waiting interrupt.
int CALL InitiateGFX(GFX_INFO Gfx_Info) int CALL InitiateGFX(GFX_INFO Gfx_Info)
{ {
WriteTrace(TraceInterface, TraceDebug, "Start"); WriteTrace(TraceInterface, TraceDebug, "Start");
voodoo.num_tmu = 2;
// Assume scale of 1 for debug purposes // Assume scale of 1 for debug purposes
rdp.scale_x = 1.0f; rdp.scale_x = 1.0f;

View File

@ -48,6 +48,8 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Gfx_1.3.h" /> <ClInclude Include="Gfx_1.3.h" />
<ClInclude Include="Renderer\Renderer.h" />
<ClInclude Include="Renderer\types.h" />
<ClInclude Include="ScreenResolution.h" /> <ClInclude Include="ScreenResolution.h" />
<ClInclude Include="Settings.h" /> <ClInclude Include="Settings.h" />
<ClInclude Include="SettingsID.h" /> <ClInclude Include="SettingsID.h" />
@ -137,6 +139,7 @@
<ClCompile Include="Renderer\OGLgeometry.cpp" /> <ClCompile Include="Renderer\OGLgeometry.cpp" />
<ClCompile Include="Renderer\OGLglitchmain.cpp" /> <ClCompile Include="Renderer\OGLglitchmain.cpp" />
<ClCompile Include="Renderer\OGLtextures.cpp" /> <ClCompile Include="Renderer\OGLtextures.cpp" />
<ClCompile Include="Renderer\Renderer.cpp" />
<ClCompile Include="ScreenResolution.cpp" /> <ClCompile Include="ScreenResolution.cpp" />
<ClCompile Include="Settings.cpp" /> <ClCompile Include="Settings.cpp" />
<ClCompile Include="TexCache.cpp" /> <ClCompile Include="TexCache.cpp" />

View File

@ -154,6 +154,12 @@
<ClInclude Include="TextureEnhancer\TxReSample.h" /> <ClInclude Include="TextureEnhancer\TxReSample.h" />
<ClInclude Include="TextureEnhancer\TxTexCache.h" /> <ClInclude Include="TextureEnhancer\TxTexCache.h" />
<ClInclude Include="TextureEnhancer\TxUtil.h" /> <ClInclude Include="TextureEnhancer\TxUtil.h" />
<ClInclude Include="Renderer\Renderer.h">
<Filter>Renderer</Filter>
</ClInclude>
<ClInclude Include="Renderer\types.h">
<Filter>Renderer</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CRC.cpp"> <ClCompile Include="CRC.cpp">
@ -266,6 +272,9 @@
<ClCompile Include="ucodeFB.cpp"> <ClCompile Include="ucodeFB.cpp">
<Filter>ucode</Filter> <Filter>ucode</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Renderer\Renderer.cpp">
<Filter>Renderer</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Text Include="gpl.txt"> <Text Include="gpl.txt">

View File

@ -11,7 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/types.h> #include <Project64-video/Renderer/Renderer.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>

View File

@ -368,154 +368,11 @@ grDrawTriangle(const void *a, const void *b, const void *c)
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDrawPoint(const void *pt) grDrawPoint(const void *pt)
{ {
/*
float *x = (float*)pt + xy_off/sizeof(float);
float *y = (float*)pt + xy_off/sizeof(float) + 1;
float *z = (float*)pt + z_off/sizeof(float);
float *q = (float*)pt + q_off/sizeof(float);
unsigned char *pargb = (unsigned char*)pt + pargb_off;
float *s0 = (float*)pt + st0_off/sizeof(float);
float *t0 = (float*)pt + st0_off/sizeof(float) + 1;
float *s1 = (float*)pt + st1_off/sizeof(float);
float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
float *fog = (float*)pt + fog_ext_off/sizeof(float);
WriteTrace(TraceGlitch, TraceDebug,"grDrawPoint()\r\n");
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, g_viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
glBegin(GL_POINTS);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
ytex(0, *t0 / *q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
ytex(1, *t1 / *q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*s0 / *q / (float)tex0_width,
ytex(0, *t0 / *q / (float)tex0_height));
}
if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z ,*q), 1.0f / *q);
glEnd();
*/
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDrawLine(const void *a, const void *b) grDrawLine(const void *a, const void *b)
{ {
/*
float *a_x = (float*)a + xy_off/sizeof(float);
float *a_y = (float*)a + xy_off/sizeof(float) + 1;
float *a_z = (float*)a + z_off/sizeof(float);
float *a_q = (float*)a + q_off/sizeof(float);
unsigned char *a_pargb = (unsigned char*)a + pargb_off;
float *a_s0 = (float*)a + st0_off/sizeof(float);
float *a_t0 = (float*)a + st0_off/sizeof(float) + 1;
float *a_s1 = (float*)a + st1_off/sizeof(float);
float *a_t1 = (float*)a + st1_off/sizeof(float) + 1;
float *a_fog = (float*)a + fog_ext_off/sizeof(float);
float *b_x = (float*)b + xy_off/sizeof(float);
float *b_y = (float*)b + xy_off/sizeof(float) + 1;
float *b_z = (float*)b + z_off/sizeof(float);
float *b_q = (float*)b + q_off/sizeof(float);
unsigned char *b_pargb = (unsigned char*)b + pargb_off;
float *b_s0 = (float*)b + st0_off/sizeof(float);
float *b_t0 = (float*)b + st0_off/sizeof(float) + 1;
float *b_s1 = (float*)b + st1_off/sizeof(float);
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off/sizeof(float);
WriteTrace(TraceGlitch, TraceDebug,"grDrawLine()\r\n");
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, g_viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
glBegin(GL_LINES);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *a_s0 / *a_q / (float)tex1_width, ytex(0, *a_t0 / *a_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *a_s1 / *a_q / (float)tex0_width, ytex(1, *a_t1 / *a_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*a_s0 / *a_q / (float)tex0_width, ytex(0, *a_t0 / *a_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q,
-(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *b_s0 / *b_q / (float)tex1_width,
ytex(0, *b_t0 / *b_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *b_s1 / *b_q / (float)tex0_width,
ytex(1, *b_t1 / *b_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*b_s0 / *b_q / (float)tex0_width,
ytex(0, *b_t0 / *b_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q,
-(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);
glEnd();
*/
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL

View File

@ -11,7 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/types.h> #include <Project64-video/Renderer/Renderer.h>
#define SAVE_CBUFFER #define SAVE_CBUFFER
@ -138,7 +138,6 @@ typedef struct
int buff_clear; int buff_clear;
} fb; } fb;
int nbTextureUnits;
int nbAuxBuffers, current_buffer; int nbAuxBuffers, current_buffer;
int g_scr_res_x, g_width, widtho, heighto, g_scr_res_y, g_height; int g_scr_res_x, g_width, widtho, heighto, g_scr_res_y, g_height;
int g_res_x, g_res_y; int g_res_x, g_res_y;
@ -393,32 +392,13 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen(GrColorFormat_t color_format, GrOrigin
#endif // _WIN32 #endif // _WIN32
nbTextureUnits = 4; nbTextureUnits = 4;
//glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &nbTextureUnits);
if (nbTextureUnits == 1) WriteTrace(TraceGlitch, TraceWarning, "You need a video card that has at least 2 texture units");
nbAuxBuffers = 4; nbAuxBuffers = 4;
//glGetIntegerv(GL_AUX_BUFFERS, &nbAuxBuffers); //glGetIntegerv(GL_AUX_BUFFERS, &nbAuxBuffers);
if (nbAuxBuffers > 0) if (nbAuxBuffers > 0)
printf("Congratulations, you have %d auxilliary buffers, we'll use them wisely !\n", nbAuxBuffers); printf("Congratulations, you have %d auxilliary buffers, we'll use them wisely !\n", nbAuxBuffers);
#ifdef VOODOO1
nbTextureUnits = 2;
#endif
blend_func_separate_support = 1; blend_func_separate_support = 1;
packed_pixels_support = 0; packed_pixels_support = 0;
/*
if (isExtensionSupported("GL_EXT_blend_func_separate") == 0)
blend_func_separate_support = 0;
else
blend_func_separate_support = 1;
if (isExtensionSupported("GL_EXT_packed_pixels") == 0)
packed_pixels_support = 0;
else {
printf("packed pixels extension used\n");
packed_pixels_support = 1;
}
*/
if (isExtensionSupported("GL_ARB_texture_non_power_of_two") == 0) if (isExtensionSupported("GL_ARB_texture_non_power_of_two") == 0)
npot_support = 0; npot_support = 0;
@ -984,19 +964,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params)
break; break;
case GR_NUM_TMU: case GR_NUM_TMU:
if (plength < 4 || params == NULL) return 0; if (plength < 4 || params == NULL) return 0;
if (!nbTextureUnits)
{
grSstWinOpen(GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1);
grSstWinClose(0);
}
#ifdef VOODOO1
params[0] = 1;
#else
if (nbTextureUnits > 2)
params[0] = 2; params[0] = 2;
else
params[0] = 1;
#endif
return 4; return 4;
break; break;
case GR_NUM_BOARDS: case GR_NUM_BOARDS:
@ -1019,7 +987,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params)
break; break;
case GR_MEMORY_UMA: case GR_MEMORY_UMA:
if (plength < 4 || params == NULL) return 0; if (plength < 4 || params == NULL) return 0;
params[0] = 16 * 1024 * 1024 * nbTextureUnits; params[0] = 16 * 1024 * 1024 * 4;
return 4; return 4;
break; break;
case GR_BITS_RGBA: case GR_BITS_RGBA:

View File

@ -104,7 +104,6 @@ void remove_tex(unsigned int idmin, unsigned int idmax)
//printf("RMVTEX nbtex is now %d (%06x - %06x)\n", nbTex, idmin, idmax); //printf("RMVTEX nbtex is now %d (%06x - %06x)\n", nbTex, idmin, idmax);
} }
void add_tex(unsigned int id) void add_tex(unsigned int id)
{ {
texlist *aux = list; texlist *aux = list;
@ -431,7 +430,6 @@ grTexDownloadMipMap( GrChipID_t tmu,
factor = grTexFormat2GLPackedFmt(info->format, &gltexfmt, &glpixfmt, &glpackfmt); factor = grTexFormat2GLPackedFmt(info->format, &gltexfmt, &glpixfmt, &glpackfmt);
if (factor < 0) { if (factor < 0) {
// VP fixed the texture conversions to be more accurate, also swapped // VP fixed the texture conversions to be more accurate, also swapped
// the for i/j loops so that is is less likely to break the memory cache // the for i/j loops so that is is less likely to break the memory cache
register int n = 0, m = 0; register int n = 0, m = 0;
@ -621,9 +619,6 @@ grTexDownloadMipMap( GrChipID_t tmu,
} }
} }
if (nbTextureUnits <= 2)
glActiveTexture(GL_TEXTURE1);
else
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
switch (info->format) switch (info->format)
@ -675,9 +670,8 @@ grTexSource( GrChipID_t tmu,
{ {
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd); WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd);
if (tmu == GR_TMU1 || nbTextureUnits <= 2) if (tmu == GR_TMU1)
{ {
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
if (info->aspectRatioLog2 < 0) if (info->aspectRatioLog2 < 0)
@ -787,9 +781,8 @@ grTexFilterMode(
) )
{ {
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %d magfilter_mode: %d", tmu, minfilter_mode, 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 == GR_TMU1)
{ {
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter0 = GL_NEAREST; if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter0 = GL_NEAREST;
else min_filter0 = GL_LINEAR; else min_filter0 = GL_LINEAR;
@ -822,9 +815,8 @@ grTexClampMode(
) )
{ {
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, s_clampmode: %d t_clampmode: %d", tmu, s_clampmode, 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 == GR_TMU1)
{ {
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
switch (s_clampmode) switch (s_clampmode)
{ {
case GR_TEXTURECLAMP_WRAP: case GR_TEXTURECLAMP_WRAP:

View File

@ -11,7 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/types.h> #include <Project64-video/Renderer/Renderer.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>

View File

@ -11,7 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/types.h> #include <Project64-video/Renderer/Renderer.h>
#define SAVE_CBUFFER #define SAVE_CBUFFER
@ -281,7 +281,6 @@ typedef struct
int buff_clear; int buff_clear;
} fb; } fb;
int nbTextureUnits;
int nbAuxBuffers, current_buffer; int nbAuxBuffers, current_buffer;
int g_scr_res_x, g_width, widtho, heighto, g_scr_res_y, g_height; int g_scr_res_x, g_width, widtho, heighto, g_scr_res_y, g_height;
int g_res_x, g_res_y; int g_res_x, g_res_y;

View File

@ -0,0 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
int32_t nbTextureUnits = 0;

View File

@ -0,0 +1,17 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#pragma once
#include <Project64-video/Renderer/types.h>
extern int32_t nbTextureUnits;

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include <string.h> #include <string.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "TexBuffer.h" #include "TexBuffer.h"
@ -130,7 +131,7 @@ static TBUFF_COLOR_IMAGE * AllocateTextureBuffer(COLOR_IMAGE & cimage)
uint32_t required = grTexCalcMemRequired(texbuf.info.smallLodLog2, texbuf.info.largeLodLog2, uint32_t required = grTexCalcMemRequired(texbuf.info.smallLodLog2, texbuf.info.largeLodLog2,
texbuf.info.aspectRatioLog2, texbuf.info.format); texbuf.info.aspectRatioLog2, texbuf.info.format);
//find free space //find free space
for (int i = 0; i < voodoo.num_tmu; i++) for (int i = 0; i < (nbTextureUnits > 2 ? 2 : 1); i++)
{ {
uint32_t available = 0; uint32_t available = 0;
uint32_t top = 0; uint32_t top = 0;
@ -230,7 +231,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage)
} }
if (search) if (search)
{ {
for (int i = 0; (i < voodoo.num_tmu) && !found; i++) for (int i = 0; (i < (nbTextureUnits > 2 ? 2 : 1)) && !found; i++)
{ {
for (int j = 0; (j < rdp.texbufs[i].count) && !found; j++) for (int j = 0; (j < rdp.texbufs[i].count) && !found; j++)
{ {
@ -662,7 +663,7 @@ int FindTextureBuffer(uint32_t addr, uint16_t width)
WriteTrace(TraceRDP, TraceDebug, "FindTextureBuffer. addr: %08lx, width: %d, scale_x: %f", addr, width, rdp.scale_x); WriteTrace(TraceRDP, TraceDebug, "FindTextureBuffer. addr: %08lx, width: %d, scale_x: %f", addr, width, rdp.scale_x);
int found = FALSE; int found = FALSE;
uint32_t shift = 0; uint32_t shift = 0;
for (int i = 0; i < voodoo.num_tmu && !found; i++) for (int i = 0; i < (nbTextureUnits > 2 ? 2 : 1) && !found; i++)
{ {
uint8_t index = rdp.cur_tex_buf^i; uint8_t index = rdp.cur_tex_buf^i;
for (int j = 0; j < rdp.texbufs[index].count && !found; j++) for (int j = 0; j < rdp.texbufs[index].count && !found; j++)

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "TexCache.h" #include "TexCache.h"
@ -474,8 +475,8 @@ int ChooseBestTmu(int tmu1, int tmu2)
if (!GfxInitDone) return tmu1; if (!GfxInitDone) return tmu1;
if (voodoo.tex_UMA) return 0; if (voodoo.tex_UMA) return 0;
if (tmu1 >= voodoo.num_tmu) return tmu2; if (tmu1 >= (nbTextureUnits > 2 ? 2 : 1)) return tmu2;
if (tmu2 >= voodoo.num_tmu) return tmu1; if (tmu2 >= (nbTextureUnits > 2 ? 2 : 1)) return tmu1;
if (voodoo.tex_max_addr[tmu1] - voodoo.tmem_ptr[tmu1] > if (voodoo.tex_max_addr[tmu1] - voodoo.tmem_ptr[tmu1] >
voodoo.tex_max_addr[tmu2] - voodoo.tmem_ptr[tmu2]) voodoo.tex_max_addr[tmu2] - voodoo.tmem_ptr[tmu2])
@ -655,7 +656,7 @@ void TexCache()
// little change to make single-tmu cards look better, use first texture no matter what // little change to make single-tmu cards look better, use first texture no matter what
if (voodoo.num_tmu == 1) if ((nbTextureUnits > 2 ? 2 : 1) == 1)
{ {
if (rdp.best_tex == 0) if (rdp.best_tex == 0)
{ {
@ -709,7 +710,7 @@ void TexCache()
return; return;
} }
if (tmu_1 < voodoo.num_tmu) if (tmu_1 < (nbTextureUnits > 2 ? 2 : 1))
{ {
if (cmb.tex_cmb_ext_use) if (cmb.tex_cmb_ext_use)
{ {
@ -737,7 +738,7 @@ void TexCache()
grTexDetailControl(tmu_1, cmb.dc1_lodbias, cmb.dc1_detailscale, cmb.dc1_detailmax); grTexDetailControl(tmu_1, cmb.dc1_lodbias, cmb.dc1_detailscale, cmb.dc1_detailmax);
grTexLodBiasValue(tmu_1, cmb.lodbias1); grTexLodBiasValue(tmu_1, cmb.lodbias1);
} }
if (tmu_0 < voodoo.num_tmu) if (tmu_0 < (nbTextureUnits > 2 ? 2 : 1))
{ {
if (cmb.tex_cmb_ext_use) if (cmb.tex_cmb_ext_use)
{ {
@ -767,7 +768,7 @@ void TexCache()
} }
} }
if ((rdp.tex & 1) && tmu_0 < voodoo.num_tmu) if ((rdp.tex & 1) && tmu_0 < (nbTextureUnits > 2 ? 2 : 1))
{ {
if (aTBuff[0] && aTBuff[0]->cache) if (aTBuff[0] && aTBuff[0]->cache)
{ {
@ -798,7 +799,7 @@ void TexCache()
else else
LoadTex(0, tmu_0); LoadTex(0, tmu_0);
} }
if ((rdp.tex & 2) && tmu_1 < voodoo.num_tmu) if ((rdp.tex & 2) && tmu_1 < (nbTextureUnits > 2 ? 2 : 1))
{ {
if (aTBuff[1] && aTBuff[1]->cache) if (aTBuff[1] && aTBuff[1]->cache)
{ {
@ -840,7 +841,7 @@ void TexCache()
{ {
const int tmu = tmu_v[i]; const int tmu = tmu_v[i];
if (tmu >= voodoo.num_tmu) continue; if (tmu >= (nbTextureUnits > 2 ? 2 : 1)) continue;
int tile = rdp.cur_tile + i; int tile = rdp.cur_tile + i;

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -926,21 +927,6 @@ static void InterpolateColors3(VERTEX &v1, VERTEX &v2, VERTEX &v3, VERTEX &out)
static void CalculateLOD(VERTEX *v, int n) static void CalculateLOD(VERTEX *v, int n)
{ {
//rdp.update |= UPDATE_TEXTURE;
/*
if (rdp.lod_calculated)
{
float detailmax;
if (dc0_detailmax < 0.5)
detailmax = rdp.lod_fraction;
else
detailmax = 1.0f - rdp.lod_fraction;
grTexDetailControl (GR_TMU0, dc0_lodbias, dc0_detailscale, detailmax);
if (num_tmu == 2)
grTexDetailControl (GR_TMU1, dc1_lodbias, dc1_detailscale, detailmax);
return;
}
*/
float deltaS, deltaT; float deltaS, deltaT;
float deltaX, deltaY; float deltaX, deltaY;
double deltaTexels, deltaPixels, lodFactor = 0; double deltaTexels, deltaPixels, lodFactor = 0;
@ -994,7 +980,7 @@ static void CalculateLOD(VERTEX *v, int n)
else else
detailmax = 1.0f - lod_fraction; detailmax = 1.0f - lod_fraction;
grTexDetailControl(GR_TMU0, cmb.dc0_lodbias, cmb.dc0_detailscale, detailmax); grTexDetailControl(GR_TMU0, cmb.dc0_lodbias, cmb.dc0_detailscale, detailmax);
if (voodoo.num_tmu == 2) if ((nbTextureUnits > 2 ? 2 : 1) == 2)
grTexDetailControl(GR_TMU1, cmb.dc1_lodbias, cmb.dc1_detailscale, detailmax); grTexDetailControl(GR_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); WriteTrace(TraceRDP, TraceDebug, "CalculateLOD factor: %f, tile: %d, lod_fraction: %f", (float)lodFactor, lod_tile, lod_fraction);
} }

View File

@ -11,6 +11,7 @@
* version 2 of the License, or (at your option) any later version. * * version 2 of the License, or (at your option) any later version. *
* * * *
****************************************************************************/ ****************************************************************************/
#include <Project64-video/Renderer/Renderer.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -1521,7 +1522,7 @@ void rdp_loadtlut()
{ {
//the buffer is definitely wrong, as there must be no CI frame buffers //the buffer is definitely wrong, as there must be no CI frame buffers
//find and remove it //find and remove it
for (int i = 0; i < voodoo.num_tmu; i++) for (int i = 0; i < (nbTextureUnits > 2 ? 2 : 1); i++)
{ {
for (int j = 0; j < rdp.texbufs[i].count; j++) for (int j = 0; j < rdp.texbufs[i].count; j++)
{ {
@ -3328,7 +3329,7 @@ void DetectFrameBufferUsage()
if (g_settings->fb_hwfbe_enabled()) if (g_settings->fb_hwfbe_enabled())
{ {
for (i = 0; i < voodoo.num_tmu; i++) for (i = 0; i < (nbTextureUnits > 2 ? 2 : 1); i++)
{ {
rdp.texbufs[i].clear_allowed = TRUE; rdp.texbufs[i].clear_allowed = TRUE;
for (int j = 0; j < 256; j++) for (int j = 0; j < 256; j++)

View File

@ -153,7 +153,6 @@ typedef struct {
typedef struct typedef struct
{ {
int num_tmu;
int max_tex_size; int max_tex_size;
int sup_large_tex; int sup_large_tex;
int sup_mirroring; int sup_mirroring;