Skip to content
Snippets Groups Projects
Commit ef4f2e71 authored by Hanicef's avatar Hanicef
Browse files

Revert "Avoid batching skybox and horizon lines"

This reverts commit fc1e8fb5.
parent 71f326a1
2 merge requests!2355fix newer versions of mixerx,!2253Optimize polygon sorting on batch renderer
...@@ -78,9 +78,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture) ...@@ -78,9 +78,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
// render the polygon immediately. // render the polygon immediately.
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial) void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial)
{ {
// draw skybox and horizon lines immediately so they don't bloat the polygon buffer. if (currently_batching)
// 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) if (!pSurf)
I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to
...@@ -117,25 +115,36 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt ...@@ -117,25 +115,36 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
polygonArray[polygonArraySize].polyFlags = PolyFlags; polygonArray[polygonArraySize].polyFlags = PolyFlags;
polygonArray[polygonArraySize].texture = current_texture; polygonArray[polygonArraySize].texture = current_texture;
polygonArray[polygonArraySize].shader = shader; 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++; polygonArraySize++;
// use FNV-1a to hash polygons for later sorting. if (!(PolyFlags & PF_NoTexture) && !horizonSpecial)
INT32 hash = 0x811c9dc5;
#define DIGEST(h, x) h ^= (x); h *= 0x01000193
DIGEST(hash, current_texture->downloaded);
DIGEST(hash, PolyFlags);
DIGEST(hash, pSurf->PolyColor.rgba);
if (cv_glshaders.value && gl_shadersavailable)
{ {
DIGEST(hash, shader); // use FNV-1a to hash polygons for later sorting.
DIGEST(hash, pSurf->TintColor.rgba); INT32 hash = 0x811c9dc5;
DIGEST(hash, pSurf->FadeColor.rgba); #define DIGEST(h, x) h ^= (x); h *= 0x01000193
DIGEST(hash, pSurf->LightInfo.light_level); if (current_texture)
DIGEST(hash, pSurf->LightInfo.fade_start); {
DIGEST(hash, pSurf->LightInfo.fade_end); DIGEST(hash, current_texture->downloaded);
} }
DIGEST(hash, PolyFlags);
DIGEST(hash, pSurf->PolyColor.rgba);
if (cv_glshaders.value && gl_shadersavailable)
{
DIGEST(hash, shader);
DIGEST(hash, pSurf->TintColor.rgba);
DIGEST(hash, pSurf->FadeColor.rgba);
DIGEST(hash, pSurf->LightInfo.light_level);
DIGEST(hash, pSurf->LightInfo.fade_start);
DIGEST(hash, pSurf->LightInfo.fade_end);
}
#undef DIGEST #undef DIGEST
polygonArray[polygonArraySize-1].hash = hash; // remove the sign bit to ensure that skybox and horizon line comes first.
polygonArray[polygonArraySize-1].hash = (hash & INT32_MAX);
}
memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector)); memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector));
unsortedVertexArraySize += iNumPts; unsortedVertexArraySize += iNumPts;
...@@ -230,7 +239,10 @@ void HWR_RenderBatches(void) ...@@ -230,7 +239,10 @@ void HWR_RenderBatches(void)
HWD.pfnSetShader(currentShader); HWD.pfnSetShader(currentShader);
} }
HWD.pfnSetTexture(currentTexture); 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) while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons)
{ {
...@@ -302,6 +314,8 @@ void HWR_RenderBatches(void) ...@@ -302,6 +314,8 @@ void HWR_RenderBatches(void)
nextTexture = polygonArray[nextIndex].texture; nextTexture = polygonArray[nextIndex].texture;
nextPolyFlags = polygonArray[nextIndex].polyFlags; nextPolyFlags = polygonArray[nextIndex].polyFlags;
nextSurfaceInfo = polygonArray[nextIndex].surf; nextSurfaceInfo = polygonArray[nextIndex].surf;
if (nextPolyFlags & PF_NoTexture)
nextTexture = 0;
if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable) if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
{ {
changeState = true; changeState = true;
......
...@@ -24,6 +24,8 @@ typedef struct ...@@ -24,6 +24,8 @@ typedef struct
FBITFIELD polyFlags; FBITFIELD polyFlags;
GLMipmap_t *texture; GLMipmap_t *texture;
int shader; 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; INT32 hash;
} PolygonArrayEntry; } PolygonArrayEntry;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment