diff options
author | Pauli Nieminen <[email protected]> | 2009-08-27 14:21:13 +0300 |
---|---|---|
committer | Pauli Nieminen <[email protected]> | 2009-08-27 18:57:13 +0300 |
commit | 570d4e375a327787441c2c7c4ae698e8993a5d6b (patch) | |
tree | de0cd753e1196925aa5aa6b1bc0e558b2000a078 /src/mesa/drivers/dri/r200 | |
parent | 44e86dde6dfe934acc0d50aad10e0f2cb390e47b (diff) |
radeon/r200/r300: Fix swtcl prediction to work after primitie change.
Swtcl calls flush everytime primitive changes so prediction has to made again
after flushing.
Diffstat (limited to 'src/mesa/drivers/dri/r200')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_swtcl.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index 6b7279e8db5..3d4e7011557 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -201,27 +201,35 @@ static void r200SetVertexFormat( GLcontext *ctx ) } } - -static void r200RenderStart( GLcontext *ctx ) +static void r200_predict_emit_size( GLcontext *ctx ) { + r200ContextPtr rmesa = R200_CONTEXT( ctx ); const int vertex_array_size = 7; const int prim_size = 3; - r200ContextPtr rmesa = R200_CONTEXT( ctx ); - r200SetVertexFormat( ctx ); - if (RADEON_DEBUG & DEBUG_VERTS) - fprintf(stderr, "%s\n", __func__); - if (!rmesa->radeon.swtcl.primitive_counter) { + if (!rmesa->radeon.swtcl.emit_prediction) { + const int state_size = radeonCountStateEmitSize(&rmesa->radeon); if (rcommonEnsureCmdBufSpace(&rmesa->radeon, - radeonCountStateEmitSize(&rmesa->radeon) + + state_size + vertex_array_size + prim_size, __FUNCTION__)) - rmesa->radeon.swtcl.primitive_counter = 0; + rmesa->radeon.swtcl.emit_prediction = radeonCountStateEmitSize(&rmesa->radeon); else - rmesa->radeon.swtcl.primitive_counter = 1; + rmesa->radeon.swtcl.emit_prediction = state_size; + rmesa->radeon.swtcl.emit_prediction += vertex_array_size + prim_size + + rmesa->radeon.cmdbuf.cs->cdw; } } +static void r200RenderStart( GLcontext *ctx ) +{ + r200SetVertexFormat( ctx ); + if (RADEON_DEBUG & DEBUG_VERTS) + fprintf(stderr, "%s\n", __func__); + r200_predict_emit_size( ctx ); +} + + /** * Set vertex state for SW TCL. The primary purpose of this function is to * determine in advance whether or not the hardware can / should do the @@ -296,8 +304,13 @@ void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset) r200EmitVbufPrim( rmesa, rmesa->radeon.swtcl.hw_primitive, rmesa->radeon.swtcl.numverts); + if ( rmesa->radeon.swtcl.emit_prediction < rmesa->radeon.cmdbuf.cs->cdw ) + WARN_ONCE("Rendering was %d commands larger than predicted size." + " We might overflow command buffer.\n", + rmesa->radeon.cmdbuf.cs->cdw - rmesa->radeon.swtcl.emit_prediction ); - rmesa->radeon.swtcl.primitive_counter = 0; + rmesa->radeon.swtcl.emit_prediction = 0; + r200_predict_emit_size( ctx ); } @@ -905,7 +918,7 @@ void r200InitSwtcl( GLcontext *ctx ) init_rast_tab(); firsttime = 0; } - rmesa->radeon.swtcl.primitive_counter = 0; + rmesa->radeon.swtcl.emit_prediction = 0; tnl->Driver.Render.Start = r200RenderStart; tnl->Driver.Render.Finish = r200RenderFinish; |