mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-20 08:20:52 +00:00
Avoid batching skybox and horizon lines
This commit is contained in:
parent
d5fe5586a0
commit
71f326a152
2 changed files with 19 additions and 35 deletions
|
@ -78,7 +78,9 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
|
|||
// render the polygon immediately.
|
||||
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial)
|
||||
{
|
||||
if (currently_batching)
|
||||
// draw skybox and horizon lines immediately so they don't bloat the polygon buffer.
|
||||
// this is important for performance since horizon lines are order-sensitive and can't easily be batched.
|
||||
if (currently_batching && !(PolyFlags & PF_NoTexture) && !horizonSpecial)
|
||||
{
|
||||
if (!pSurf)
|
||||
I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to
|
||||
|
@ -115,21 +117,12 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
|||
polygonArray[polygonArraySize].polyFlags = PolyFlags;
|
||||
polygonArray[polygonArraySize].texture = current_texture;
|
||||
polygonArray[polygonArraySize].shader = shader;
|
||||
polygonArray[polygonArraySize].horizonSpecial = horizonSpecial;
|
||||
// default to polygonArraySize so we don't lose order on horizon lines
|
||||
// (yes, it's supposed to be negative, since we're sorting in that direction)
|
||||
polygonArray[polygonArraySize].hash = -polygonArraySize;
|
||||
polygonArraySize++;
|
||||
|
||||
if (!(PolyFlags & PF_NoTexture) && !horizonSpecial)
|
||||
{
|
||||
// use FNV-1a to hash polygons for later sorting.
|
||||
INT32 hash = 0x811c9dc5;
|
||||
#define DIGEST(h, x) h ^= (x); h *= 0x01000193
|
||||
if (current_texture)
|
||||
{
|
||||
DIGEST(hash, current_texture->downloaded);
|
||||
}
|
||||
DIGEST(hash, PolyFlags);
|
||||
DIGEST(hash, pSurf->PolyColor.rgba);
|
||||
if (cv_glshaders.value && gl_shadersavailable)
|
||||
|
@ -142,9 +135,7 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
|||
DIGEST(hash, pSurf->LightInfo.fade_end);
|
||||
}
|
||||
#undef DIGEST
|
||||
// remove the sign bit to ensure that skybox and horizon line comes first.
|
||||
polygonArray[polygonArraySize-1].hash = (hash & INT32_MAX);
|
||||
}
|
||||
polygonArray[polygonArraySize-1].hash = hash;
|
||||
|
||||
memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector));
|
||||
unsortedVertexArraySize += iNumPts;
|
||||
|
@ -239,9 +230,6 @@ void HWR_RenderBatches(void)
|
|||
HWD.pfnSetShader(currentShader);
|
||||
}
|
||||
|
||||
if (currentPolyFlags & PF_NoTexture)
|
||||
currentTexture = NULL;
|
||||
else
|
||||
HWD.pfnSetTexture(currentTexture);
|
||||
|
||||
while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons)
|
||||
|
@ -314,8 +302,6 @@ void HWR_RenderBatches(void)
|
|||
nextTexture = polygonArray[nextIndex].texture;
|
||||
nextPolyFlags = polygonArray[nextIndex].polyFlags;
|
||||
nextSurfaceInfo = polygonArray[nextIndex].surf;
|
||||
if (nextPolyFlags & PF_NoTexture)
|
||||
nextTexture = 0;
|
||||
if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
|
||||
{
|
||||
changeState = true;
|
||||
|
|
|
@ -24,8 +24,6 @@ typedef struct
|
|||
FBITFIELD polyFlags;
|
||||
GLMipmap_t *texture;
|
||||
int shader;
|
||||
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
|
||||
boolean horizonSpecial;
|
||||
INT32 hash;
|
||||
} PolygonArrayEntry;
|
||||
|
||||
|
|
Loading…
Reference in a new issue