On 3/27/07, Gerard Krol <[EMAIL PROTECTED]> wrote:
Author: gerard_
Date: Tue Mar 27 15:56:36 2007
New Revision: 928
URL: http://svn.gna.org/viewcvs/warzone?rev=928&view=rev
Log:
Tweaks and optimisations for CPU usage. Tiles are no longer added to the
bucket sort, and the size of the bucket array is made smaller. The maximum
number of simultaneous effects is down from 2500 to 500 (a big fight has
about 200 effects). The effect processing and drawing is now done from one
loop instead of from 2 (saves on the iterations). The pie_DrawTexTriangle
function defaults to non transparent tiles and sets an alpha drawing mode
only when needed.
Modified:
trunk/lib/ivis_opengl/piedraw.c
trunk/src/bucket3d.c
trunk/src/display3d.c
trunk/src/effects.c
trunk/src/effects.h
trunk/src/mapgrid.c
_______________________________________________
Warzone-commits mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-commits
I think wz is also doing alot redundant state changes,because it doesnt keep
tracks of the current opengl states and group state changes into weird
'local state names',a global uint32 flag might help reducing the redundant
state changes:(this is just part of the patch,since I could never resolve
the conflicts in full patch gracefully...)
Index: ivis_common/piestate.h
===================================================================
--- ivis_common/piestate.h (revision 901)
+++ ivis_common/piestate.h (working copy)
@@ -138,6 +138,19 @@
}
RENDER_STATE;
+enum {
+ WZ_GL_DEPTH_TEST = 0x0001,
+ WZ_GL_DEPTH_LEQUAL = 0x0002,
+ WZ_GL_DEPTH_MASK_TRUE = 0x0004,
+ WZ_GL_ALPHA_TEST = 0x0008,
+ WZ_GL_ALPHA_GREATER = 0x0010,
+ WZ_GL_BLEND = 0x0020,
+ WZ_GL_BLEND_SRC_ALPHA_GL_ONE = 0x0040,
+ WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS = 0x0080,
+ WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR = 0x0100,
+ WZ_GL_CULL_FACE = 0x0200,
+};
+
#define NO_TEXPAGE -1
/***************************************************************************/
@@ -147,6 +160,7 @@
/***************************************************************************/
extern SDWORD pieStateCount;
+extern UDWORD currentStatesFlags;
/***************************************************************************/
/*
===================================================================
--- ivis_opengl/piestate.c (revision 901)
+++ ivis_opengl/piestate.c (working copy)
@@ -45,34 +45,87 @@
/***************************************************************************/
extern RENDER_STATE rendStates;
+UDWORD currentStatesFlags = 0;
/***************************************************************************/
/*
* Source
*/
/***************************************************************************/
+static SDWORD currentDepthMode = -1;
+
void pie_SetDepthBufferStatus(DEPTH_MODE depthMode) {
+ if (depthMode == currentDepthMode && currentDepthMode >= 0)
+ {
+ return;
+ }
switch(depthMode) {
case DEPTH_CMP_LEQ_WRT_ON:
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glDepthMask(GL_TRUE);
+ if ((!currentStatesFlags & WZ_GL_DEPTH_TEST))
+ {
+ glEnable(GL_DEPTH_TEST);
+ currentStatesFlags |= WZ_GL_DEPTH_TEST;
+ }
+ if ((!currentStatesFlags & WZ_GL_DEPTH_LEQUAL))
+ {
+ glDepthFunc(GL_LEQUAL);
+ currentStatesFlags |= WZ_GL_DEPTH_LEQUAL;
+ }
+ if ((!currentStatesFlags & WZ_GL_DEPTH_MASK_TRUE))
+ {
+ glDepthMask(GL_TRUE);
+ currentStatesFlags |= WZ_GL_DEPTH_MASK_TRUE;
+ }
break;
case DEPTH_CMP_ALWAYS_WRT_ON:
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_TRUE);
+ if (currentStatesFlags & WZ_GL_DEPTH_TEST)
+ {
+ glDisable(GL_DEPTH_TEST);
+ currentStatesFlags &= ~WZ_GL_DEPTH_TEST;
+ }
+ if (!(currentStatesFlags & WZ_GL_DEPTH_MASK_TRUE))
+ {
+ glDepthMask(GL_TRUE);
+ currentStatesFlags |= WZ_GL_DEPTH_MASK_TRUE;
+ }
+ //assume we dont have lequal func too with depthtest disabled
+ currentStatesFlags &= ~WZ_GL_DEPTH_LEQUAL;
break;
case DEPTH_CMP_LEQ_WRT_OFF:
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glDepthMask(GL_FALSE);
+ if ((!currentStatesFlags & WZ_GL_DEPTH_TEST))
+ {
+ glEnable(GL_DEPTH_TEST);
+ currentStatesFlags |= WZ_GL_DEPTH_TEST;
+ }
+ if ((!currentStatesFlags & WZ_GL_DEPTH_LEQUAL))
+ {
+ glDepthFunc(GL_LEQUAL);
+ currentStatesFlags |= WZ_GL_DEPTH_LEQUAL;
+ }
+ if (currentStatesFlags & WZ_GL_DEPTH_MASK_TRUE)
+ {
+ glDepthMask(GL_FALSE);
+ currentStatesFlags &= ~WZ_GL_DEPTH_MASK_TRUE;
+ }
break;
case DEPTH_CMP_ALWAYS_WRT_OFF:
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_FALSE);
+ if (currentStatesFlags & WZ_GL_DEPTH_TEST)
+ {
+ glDisable(GL_DEPTH_TEST);
+ currentStatesFlags &= ~WZ_GL_DEPTH_TEST;
+ }
+ if (currentStatesFlags & WZ_GL_DEPTH_MASK_TRUE)
+ {
+ glDepthMask(GL_FALSE);
+ currentStatesFlags &= ~WZ_GL_DEPTH_MASK_TRUE;
+ }
break;
+ //assume we dont have lequal func too with depthtest disabled
+ currentStatesFlags &= ~WZ_GL_DEPTH_LEQUAL;
+ break;
}
+ currentDepthMode = depthMode;
}
//***************************************************************************
@@ -150,10 +203,22 @@
pieStateCount++;
if (keyingOn == TRUE) {
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.1f);
+ if (!(currentStatesFlags & WZ_GL_ALPHA_TEST))
+ {
+ glEnable(GL_ALPHA_TEST);
+ currentStatesFlags |= WZ_GL_ALPHA_TEST;
+ }
+ if (!(currentStatesFlags & WZ_GL_ALPHA_GREATER))
+ {
+ glAlphaFunc(GL_GREATER, 0.1f);
+ currentStatesFlags |= WZ_GL_ALPHA_GREATER;
+ }
} else {
- glDisable(GL_ALPHA_TEST);
+ if (currentStatesFlags & WZ_GL_ALPHA_TEST)
+ {
+ glDisable(GL_ALPHA_TEST);
+ currentStatesFlags &= ~WZ_GL_ALPHA_TEST;
+ }
}
}
#endif
@@ -189,20 +254,72 @@
rendStates.transMode = transMode;
switch (transMode) {
case TRANS_ALPHA:
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ if (!(currentStatesFlags & WZ_GL_BLEND))
+ {
+ glEnable(GL_BLEND);
+ currentStatesFlags |= WZ_GL_BLEND;
+ }
+ if (!(currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS))
+ {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ currentStatesFlags |= WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS;
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_GL_ONE)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_GL_ONE;
+ }
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR;
+ }
+ }
break;
case TRANS_ADDITIVE:
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ if (!(currentStatesFlags & WZ_GL_BLEND))
+ {
+ glEnable(GL_BLEND);
+ currentStatesFlags |= WZ_GL_BLEND;
+ }
+ if (!(currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_GL_ONE))
+ {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ currentStatesFlags |= WZ_GL_BLEND_SRC_ALPHA_GL_ONE;
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS;
+ }
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR;
+ }
+ }
break;
case TRANS_FILTER:
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
+ if (!(currentStatesFlags & WZ_GL_BLEND))
+ {
+ glEnable(GL_BLEND);
+ currentStatesFlags |= WZ_GL_BLEND;
+ }
+ if (!(currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR))
+ {
+ glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
+ currentStatesFlags |= WZ_GL_BLEND_SRC_ALPHA_SRC_COLOR;
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_ONE_MINUS;
+ }
+ if (currentStatesFlags & WZ_GL_BLEND_SRC_ALPHA_GL_ONE)
+ {
+ currentStatesFlags &= ~WZ_GL_BLEND_SRC_ALPHA_GL_ONE;
+ }
+ }
break;
default:
rendStates.transMode = TRANS_DECAL;
- glDisable(GL_BLEND);
+ if (currentStatesFlags & WZ_GL_BLEND)
+ {
+ glDisable(GL_BLEND);
+ currentStatesFlags &= ~WZ_GL_BLEND;
+ }
break;
}
}
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev