fix lighttable batching for new batching and palshader code

This commit was merged in pull request #90.
This commit is contained in:
Alug committed 2024-01-18 16:56:59 +01:00
1 parent 8c1febd1b9
commit 5cec34e8d9
2 files changed
+12 -14

No files matched your search

-6
View File
@@ -195,12 +195,6 @@ static int compareDrawCalls(const void *p1, const void *p2)
downloaded2 = poly2->texture->downloaded;
diff64 = downloaded1 - downloaded2;
if (diff64 != 0) return diff64;
if (HWR_ShouldUsePaletteRendering())
{
diff = poly1->surf.LightTableId - poly2->surf.LightTableId;
if (diff != 0) return diff;
}
diff = poly1->polyFlags - poly2->polyFlags;
if (diff != 0) return diff;
+12 -8
View File
@@ -79,10 +79,7 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
// **************************************************************************
static GLuint tex_downloaded = 0;
// these didnt work with karts batching system, hope this is not an issue
//static GLuint lt_downloaded = 0; // currently bound lighttable texture - currentSurfaceInfo
//static GLuint lt_downloaded2 = 0; // currently bound lighttable texture - nextSurfaceInfo
//static GLuint lt_downloaded3 = 0; // currently bound lighttable texture - pSurf
static GLuint lt_downloaded = 0; // currently bound lighttable texture
static GLfloat fov = 90.0f;
static FBITFIELD CurrentPolyFlags;
@@ -2211,11 +2208,12 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD
fade.blue = byte2float[pSurf->FadeColor.s.blue];
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
if (HWR_ShouldUsePaletteRendering() && gl_allowshaders)
if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded)
{
pglActiveTexture(GL_TEXTURE2);
pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId);
pglActiveTexture(GL_TEXTURE0);
lt_downloaded = pSurf->LightTableId;
}
}
@@ -2990,6 +2988,14 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float
fade.green = byte2float[Surface->FadeColor.s.green];
fade.blue = byte2float[Surface->FadeColor.s.blue];
fade.alpha = byte2float[Surface->FadeColor.s.alpha];
if (Surface->LightTableId && Surface->LightTableId != lt_downloaded)
{
pglActiveTexture(GL_TEXTURE2);
pglBindTexture(GL_TEXTURE_2D, Surface->LightTableId);
pglActiveTexture(GL_TEXTURE0);
lt_downloaded = Surface->LightTableId;
}
Shader_SetUniforms(Surface, &poly, &tint, &fade);
@@ -3856,9 +3862,7 @@ EXPORT void HWRAPI(ClearLightTables)(void)
LightTablesTail = NULL;
// we no longer have a bound light table (if we had one), we just deleted it!
//lt_downloaded = 0;
//lt_downloaded2 = 0;
//lt_downloaded3 = 0;
lt_downloaded = 0;
}
// This palette is used for the palette rendering postprocessing step.