Mesa (mesa_7_5_branch): mesa/dlist: fixes and improvements for material caching
Keith Whitwell
keithw at kemper.freedesktop.org
Thu Jul 2 12:31:54 UTC 2009
Module: Mesa
Branch: mesa_7_5_branch
Commit: 70ae7ba818e9d8a5485653b258e76f06c988654c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70ae7ba818e9d8a5485653b258e76f06c988654c
Author: Keith Whitwell <keithw at vmware.com>
Date: Tue Jun 30 18:40:20 2009 +0100
mesa/dlist: fixes and improvements for material caching
Only short-circuit material call if *all* statechanges from this call
are cached. Some material calls (eg with FRONT_AND_BACK) change more
than one piece of state -- need to check all of them before returning.
Also, Material calls are legal inside begin/end pairs, so don't need
to be as careful about begin/end state as with regular statechanges
(like ShadeModel) when caching. Take advantage of this and do better
caching.
---
src/mesa/main/dlist.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 2af0dd3..c5a1c1f 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -5225,20 +5225,28 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
- /* Try to eliminate redundant statechanges
+ /* Try to eliminate redundant statechanges. Because it is legal to
+ * call glMaterial even inside begin/end calls, don't need to worry
+ * about ctx->Driver.CurrentSavePrimitive here.
*/
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
if (bitmask & (1 << i)) {
- if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END &&
- ctx->ListState.ActiveMaterialSize[i] == args &&
- compare4fv(ctx->ListState.CurrentMaterial[i], param, args))
- return;
-
- ctx->ListState.ActiveMaterialSize[i] = args;
- COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
+ if (ctx->ListState.ActiveMaterialSize[i] == args &&
+ compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) {
+ bitmask &= ~(1 << i);
+ }
+ else {
+ ctx->ListState.ActiveMaterialSize[i] = args;
+ COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
+ }
}
}
+ /* If this call has effect, return early:
+ */
+ if (bitmask == 0)
+ return;
+
SAVE_FLUSH_VERTICES(ctx);
n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
More information about the mesa-commit
mailing list