diff options
author | Eric Anholt <eric@anholt.net> | 2010-05-13 11:31:56 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-05-13 13:02:09 -0700 |
commit | c67d9d84f501f145f841c0b981caff6f4dfd936f (patch) | |
tree | 671f7799cac79205f98bf277437a3e488db45084 /src/mesa/drivers | |
parent | 61aa9c86c20b1bc9957aa9fe9976703a93cc4d3c (diff) |
i965: Reduce a single GL_QUADS to GL_TRIANGLE_FAN.
This is similar to the GL_QUAD_STRIP -> TRIANGLE_STRIP optimization --
the GS usage to split the quads into tris is a huge bottleneck, so a
quick check improves glean blendFunc time massively (width * height of
the window of single-pixel GL_QUADS, many many times). This may also
end up helping with cairo performance, which sometimes ends up drawing
a single quad.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_draw.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index e348d4686b..fe633d3e25 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -77,32 +77,41 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { * programs be immune to the active primitive (ie. cope with all * possibilities). That may not be realistic however. */ -static GLuint brw_set_prim(struct brw_context *brw, GLenum prim) +static GLuint brw_set_prim(struct brw_context *brw, + const struct _mesa_prim *prim) { GLcontext *ctx = &brw->intel.ctx; + GLenum mode = prim->mode; if (INTEL_DEBUG & DEBUG_PRIMS) - printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim)); - + printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim->mode)); + /* Slight optimization to avoid the GS program when not needed: */ - if (prim == GL_QUAD_STRIP && + if (mode == GL_QUAD_STRIP && ctx->Light.ShadeModel != GL_FLAT && ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) - prim = GL_TRIANGLE_STRIP; + mode = GL_TRIANGLE_STRIP; + + if (prim->mode == GL_QUADS && prim->count == 4 && + ctx->Light.ShadeModel != GL_FLAT && + ctx->Polygon.FrontMode == GL_FILL && + ctx->Polygon.BackMode == GL_FILL) { + mode = GL_TRIANGLE_FAN; + } - if (prim != brw->primitive) { - brw->primitive = prim; + if (mode != brw->primitive) { + brw->primitive = mode; brw->state.dirty.brw |= BRW_NEW_PRIMITIVE; - if (reduced_prim[prim] != brw->intel.reduced_primitive) { - brw->intel.reduced_primitive = reduced_prim[prim]; + if (reduced_prim[mode] != brw->intel.reduced_primitive) { + brw->intel.reduced_primitive = reduced_prim[mode]; brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE; } } - return prim_to_hw_prim[prim]; + return prim_to_hw_prim[mode]; } @@ -351,7 +360,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, */ intel_batchbuffer_require_space(intel->batch, intel->batch->size / 4); - hw_prim = brw_set_prim(brw, prim[i].mode); + hw_prim = brw_set_prim(brw, &prim[i]); if (first_time || (brw->state.dirty.brw & BRW_NEW_PRIMITIVE)) { first_time = GL_FALSE; |