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

Check hash instead of each field when batching

parent ef4f2e71
Branches
Tags
2 merge requests!2355fix newer versions of mixerx,!2253Optimize polygon sorting on batch renderer
...@@ -310,46 +310,45 @@ void HWR_RenderBatches(void) ...@@ -310,46 +310,45 @@ void HWR_RenderBatches(void)
{ {
// check if a state change is required, set the change bools and next vars // check if a state change is required, set the change bools and next vars
int nextIndex = polygonIndexArray[polygonReadPos]; int nextIndex = polygonIndexArray[polygonReadPos];
nextShader = polygonArray[nextIndex].shader; if (polygonArray[index].hash != polygonArray[nextIndex].hash)
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; changeState = true;
changeShader = true; nextShader = polygonArray[nextIndex].shader;
} nextTexture = polygonArray[nextIndex].texture;
if (currentTexture != nextTexture) nextPolyFlags = polygonArray[nextIndex].polyFlags;
{ nextSurfaceInfo = polygonArray[nextIndex].surf;
changeState = true; if (nextPolyFlags & PF_NoTexture)
changeTexture = true; nextTexture = 0;
} if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
if (currentPolyFlags != nextPolyFlags)
{
changeState = true;
changePolyFlags = true;
}
if (cv_glshaders.value && gl_shadersavailable)
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end)
{ {
changeState = true; changeShader = true;
changeSurfaceInfo = true;
} }
} if (currentTexture != nextTexture)
else {
{ changeTexture = true;
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba) }
if (currentPolyFlags != nextPolyFlags)
{
changePolyFlags = true;
}
if (cv_glshaders.value && gl_shadersavailable)
{ {
changeState = true; if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
changeSurfaceInfo = true; currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end)
{
changeSurfaceInfo = true;
}
}
else
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba)
{
changeSurfaceInfo = true;
}
} }
} }
} }
...@@ -371,36 +370,39 @@ void HWR_RenderBatches(void) ...@@ -371,36 +370,39 @@ void HWR_RenderBatches(void)
if (stopFlag) break; if (stopFlag) break;
// change state according to change bools and next vars, update current vars and reset bools // change state according to change bools and next vars, update current vars and reset bools
if (changeShader) if (changeState)
{ {
HWD.pfnSetShader(nextShader); if (changeShader)
currentShader = nextShader; {
changeShader = false; HWD.pfnSetShader(nextShader);
currentShader = nextShader;
changeShader = false;
ps_hw_numshaders.value.i++; ps_hw_numshaders.value.i++;
} }
if (changeTexture) if (changeTexture)
{ {
// texture should be already ready for use from calls to SetTexture during batch collection // texture should be already ready for use from calls to SetTexture during batch collection
HWD.pfnSetTexture(nextTexture); HWD.pfnSetTexture(nextTexture);
currentTexture = nextTexture; currentTexture = nextTexture;
changeTexture = false; changeTexture = false;
ps_hw_numtextures.value.i++; ps_hw_numtextures.value.i++;
} }
if (changePolyFlags) if (changePolyFlags)
{ {
currentPolyFlags = nextPolyFlags; currentPolyFlags = nextPolyFlags;
changePolyFlags = false; changePolyFlags = false;
ps_hw_numpolyflags.value.i++; ps_hw_numpolyflags.value.i++;
} }
if (changeSurfaceInfo) if (changeSurfaceInfo)
{ {
currentSurfaceInfo = nextSurfaceInfo; currentSurfaceInfo = nextSurfaceInfo;
changeSurfaceInfo = false; changeSurfaceInfo = false;
ps_hw_numcolors.value.i++; ps_hw_numcolors.value.i++;
}
} }
// and that should be it? // and that should be it?
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment