From: Pauli Nieminen Date: Sat, 6 Feb 2010 12:47:27 +0000 (+0200) Subject: r300: Fix emit size prediction to know about primitive splitting. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db3460e31cd4a2ccc9674715e8074f549f953676;p=mesa.git r300: Fix emit size prediction to know about primitive splitting. Fixes ut2004 warnings about overflowing command buffer. --- diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c index 813495a0466..4ae0d6fe48f 100644 --- a/src/mesa/drivers/dri/r300/r300_draw.c +++ b/src/mesa/drivers/dri/r300/r300_draw.c @@ -605,13 +605,23 @@ static void r300FreeData(GLcontext *ctx) } } -static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx, GLuint nr_prims) +static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx, + GLuint nr_prims, const struct _mesa_prim *prim) { struct r300_context *r300 = R300_CONTEXT(ctx); struct r300_vertex_buffer *vbuf = &r300->vbuf; GLboolean flushed; GLuint dwords; GLuint state_size; + int i; + GLuint extra_prims = 0; + + /* Check for primitive splitting. */ + for (i = 0; i < nr_prims; ++i) { + const GLuint num_verts = r300NumVerts(r300, prim[i].count, prim[i].mode); + extra_prims += num_verts/(65535 - 32); + } + nr_prims += extra_prims; dwords = 2*CACHE_FLUSH_BUFSZ; dwords += PRE_EMIT_STATE_BUFSZ; @@ -667,7 +677,7 @@ static GLboolean r300TryDrawPrims(GLcontext *ctx, /* ensure we have the cmd buf space in advance to cover * the state + DMA AOS pointers */ - GLuint emit_end = r300PredictTryDrawPrimsSize(ctx, nr_prims) + GLuint emit_end = r300PredictTryDrawPrimsSize(ctx, nr_prims, prim) + r300->radeon.cmdbuf.cs->cdw; r300SetupIndexBuffer(ctx, ib);