rasterizer: remove toon table caching. i thought of conditions where it could fail and not recover. left it for ogl though since updating toon table costs a texture update.
This commit is contained in:
parent
f9353eab01
commit
cfb5940ea8
|
@ -821,13 +821,21 @@ static void OGLRender()
|
||||||
|
|
||||||
if(hasShaders)
|
if(hasShaders)
|
||||||
{
|
{
|
||||||
|
//NOTE: this toon invalidation logic is hopelessly buggy.
|
||||||
|
//it may sometimes fail. it would be better to always recreate this data.
|
||||||
|
//but, that may be slow. since the cost of uploading that texture is huge in opengl (relative to rasterizer).
|
||||||
|
//someone please study it.
|
||||||
|
//here is a suggestion: it may make sense to memcmp the toon tables and upload only when it actually changes
|
||||||
if (gfx3d.renderState.invalidateToon)
|
if (gfx3d.renderState.invalidateToon)
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID);
|
glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID);
|
||||||
|
|
||||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, &gfx3d.renderState.rgbToonTable[0]);
|
u32 rgbToonTable[32];
|
||||||
gfx3d.renderState.invalidateToon = false;
|
for(int i=0;i<32;i++)
|
||||||
|
rgbToonTable[i] = RGB15TO32_NOALPHA(gfx3d.renderState.u16ToonTable[i]);
|
||||||
|
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, &rgbToonTable[0]);
|
||||||
|
gfx3d.state.invalidateToon = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -578,8 +578,6 @@ void gfx3d_reset()
|
||||||
|
|
||||||
GFX_PIPEclear();
|
GFX_PIPEclear();
|
||||||
GFX_FIFOclear();
|
GFX_FIFOclear();
|
||||||
|
|
||||||
gfx3d.state.invalidateToon = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1611,16 +1609,16 @@ int gfx3d_GetNumVertex()
|
||||||
|
|
||||||
void gfx3d_UpdateToonTable(u8 offset, u16 val)
|
void gfx3d_UpdateToonTable(u8 offset, u16 val)
|
||||||
{
|
{
|
||||||
gfx3d.state.rgbToonTable[offset] = RGB15TO32(val, 255);
|
|
||||||
gfx3d.state.invalidateToon = true;
|
gfx3d.state.invalidateToon = true;
|
||||||
|
gfx3d.state.u16ToonTable[offset] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx3d_UpdateToonTable(u8 offset, u32 val)
|
void gfx3d_UpdateToonTable(u8 offset, u32 val)
|
||||||
{
|
{
|
||||||
//C.O.P. sets toon table via this method
|
//C.O.P. sets toon table via this method
|
||||||
gfx3d.state.rgbToonTable[offset] = RGB15TO32(val & 0xFFFF, 255);
|
|
||||||
gfx3d.state.rgbToonTable[offset+1] = RGB15TO32(val >> 16, 255);
|
|
||||||
gfx3d.state.invalidateToon = true;
|
gfx3d.state.invalidateToon = true;
|
||||||
|
gfx3d.state.u16ToonTable[offset] = val & 0xFFFF;
|
||||||
|
gfx3d.state.u16ToonTable[offset+1] = val >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 gfx3d_GetClipMatrix (unsigned int index)
|
s32 gfx3d_GetClipMatrix (unsigned int index)
|
||||||
|
@ -2329,7 +2327,7 @@ SFORMAT SF_GFX3D[]={
|
||||||
{ "GSCD", 4, 1, &gfx3d.state.clearDepth},
|
{ "GSCD", 4, 1, &gfx3d.state.clearDepth},
|
||||||
{ "GSFC", 4, 4, &gfx3d.state.fogColor},
|
{ "GSFC", 4, 4, &gfx3d.state.fogColor},
|
||||||
{ "GSFO", 4, 1, &gfx3d.state.fogOffset},
|
{ "GSFO", 4, 1, &gfx3d.state.fogOffset},
|
||||||
{ "GST3", 4, 32, gfx3d.state.rgbToonTable},
|
{ "GST4", 2, 32, gfx3d.state.u16ToonTable},
|
||||||
{ "GSST", 4, 128, &gfx3d.state.shininessTable[0]},
|
{ "GSST", 4, 128, &gfx3d.state.shininessTable[0]},
|
||||||
{ "GSSI", 4, 1, &shininessInd},
|
{ "GSSI", 4, 1, &shininessInd},
|
||||||
{ "GSAF", 4, 1, &gfx3d.state.activeFlushCommand},
|
{ "GSAF", 4, 1, &gfx3d.state.activeFlushCommand},
|
||||||
|
|
|
@ -103,6 +103,7 @@ inline u32 RGB15TO6665(u16 col, u8 alpha5)
|
||||||
|
|
||||||
//produce a 15bpp color from individual 5bit components
|
//produce a 15bpp color from individual 5bit components
|
||||||
#define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10))
|
#define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10))
|
||||||
|
#define RGB15TO32_NOALPHA(col) ( color_15bit_to_24bit[col&0x7FFF] )
|
||||||
|
|
||||||
//produce a 16bpp color from individual 5bit components
|
//produce a 16bpp color from individual 5bit components
|
||||||
#define R6G6B6TORGB15(r,g,b) ((r>>1)|((g&0x3E)<<4)|((b&0x3E)<<9))
|
#define R6G6B6TORGB15(r,g,b) ((r>>1)|((g&0x3E)<<4)|((b&0x3E)<<9))
|
||||||
|
@ -317,8 +318,8 @@ struct GFX3D_State
|
||||||
for(u32 i=0;i<ARRAY_SIZE(shininessTable);i++)
|
for(u32 i=0;i<ARRAY_SIZE(shininessTable);i++)
|
||||||
shininessTable[i] = 0;
|
shininessTable[i] = 0;
|
||||||
|
|
||||||
for(u32 i=0;i<ARRAY_SIZE(rgbToonTable);i++)
|
for(u32 i=0;i<ARRAY_SIZE(u16ToonTable);i++)
|
||||||
rgbToonTable[i] = 0;
|
u16ToonTable[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending,
|
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending,
|
||||||
|
@ -345,7 +346,7 @@ struct GFX3D_State
|
||||||
u32 fogShift;
|
u32 fogShift;
|
||||||
|
|
||||||
bool invalidateToon;
|
bool invalidateToon;
|
||||||
u32 rgbToonTable[32];
|
u16 u16ToonTable[32];
|
||||||
float shininessTable[128];
|
float shininessTable[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1154,14 +1154,17 @@ void SoftRasterizerEngine::initFramebuffer(const int width, const int height, co
|
||||||
|
|
||||||
void SoftRasterizerEngine::updateToonTable()
|
void SoftRasterizerEngine::updateToonTable()
|
||||||
{
|
{
|
||||||
if (!gfx3d.renderState.invalidateToon) return;
|
|
||||||
//convert the toon colors
|
//convert the toon colors
|
||||||
for(int i=0;i<32;i++) {
|
for(int i=0;i<32;i++) {
|
||||||
toonTable[i].r = (gfx3d.renderState.rgbToonTable[i] >> 2) & 0x3F;
|
#ifdef WORDS_BIGENDIAN
|
||||||
toonTable[i].g = (gfx3d.renderState.rgbToonTable[i] >> 10) & 0x3F;
|
u32 u32temp = RGB15TO32(gfx3d.renderState.u16ToonTable[i]);
|
||||||
toonTable[i].b = (gfx3d.renderState.rgbToonTable[i] >> 18) & 0x3F;
|
toonTable[i].r = (u32temp >> 2) & 0x3F;
|
||||||
|
toonTable[i].g = (u32temp >> 10) & 0x3F;
|
||||||
|
toonTable[i].b = (u32temp >> 18) & 0x3F;
|
||||||
|
#else
|
||||||
|
toonTable[i].color = (RGB15TO32_NOALPHA(gfx3d.renderState.u16ToonTable[i])>>2)&0x3F3F3F3F;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
gfx3d.renderState.invalidateToon = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftRasterizerEngine::updateFogTable()
|
void SoftRasterizerEngine::updateFogTable()
|
||||||
|
|
Loading…
Reference in New Issue