aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorPauli Nieminen <[email protected]>2009-08-26 22:24:25 +0300
committerPauli Nieminen <[email protected]>2009-08-27 00:01:56 +0300
commit97029c1860e8a99448ac157408e71bea3aa2559f (patch)
treebaa7b07538918a1777dba13d87ea1fe82e3dcadf /src/mesa/drivers
parent72052210516b4cb0e082e0c56822cd33b1562630 (diff)
radeon/r200/r300: Fix swtcl flushing not to invalidate dma region.
We were check command buffer sizes too alte so allocated dma regions were freed before relocations so space checking failed.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/r200/r200_swtcl.c22
-rw-r--r--src/mesa/drivers/dri/r300/r300_swtcl.c37
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_common_context.h1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_dma.c7
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_swtcl.c31
5 files changed, 75 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c
index 13bd6ac4e2c..6b7279e8db5 100644
--- a/src/mesa/drivers/dri/r200/r200_swtcl.c
+++ b/src/mesa/drivers/dri/r200/r200_swtcl.c
@@ -204,7 +204,21 @@ static void r200SetVertexFormat( GLcontext *ctx )
static void r200RenderStart( GLcontext *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 (rcommonEnsureCmdBufSpace(&rmesa->radeon,
+ radeonCountStateEmitSize(&rmesa->radeon) +
+ vertex_array_size + prim_size,
+ __FUNCTION__))
+ rmesa->radeon.swtcl.primitive_counter = 0;
+ else
+ rmesa->radeon.swtcl.primitive_counter = 1;
+ }
}
@@ -268,9 +282,8 @@ void r200ChooseVertexState( GLcontext *ctx )
void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- rcommonEnsureCmdBufSpace(&rmesa->radeon,
- radeonCountStateEmitSize(&rmesa->radeon) + (12*sizeof(int)),
- __FUNCTION__);
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
radeonEmitState(&rmesa->radeon);
@@ -284,6 +297,8 @@ void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
rmesa->radeon.swtcl.hw_primitive,
rmesa->radeon.swtcl.numverts);
+ rmesa->radeon.swtcl.primitive_counter = 0;
+
}
/**************************************************************************/
@@ -890,6 +905,7 @@ void r200InitSwtcl( GLcontext *ctx )
init_rast_tab();
firsttime = 0;
}
+ rmesa->radeon.swtcl.primitive_counter = 0;
tnl->Driver.Render.Start = r200RenderStart;
tnl->Driver.Render.Finish = r200RenderFinish;
diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c
index 9d6f7568799..18af51e666a 100644
--- a/src/mesa/drivers/dri/r300/r300_swtcl.c
+++ b/src/mesa/drivers/dri/r300/r300_swtcl.c
@@ -83,6 +83,9 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead, GLuint *_
rmesa->swtcl.coloroffset = rmesa->swtcl.specoffset = 0;
rmesa->radeon.swtcl.vertex_attr_count = 0;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
+
/* We always want non Ndc coords format */
VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
@@ -462,6 +465,8 @@ static void r300ChooseRenderState( GLcontext *ctx )
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLuint index = 0;
GLuint flags = ctx->_TriangleCaps;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT;
@@ -489,6 +494,8 @@ static void r300ChooseRenderState( GLcontext *ctx )
void r300RenderStart(GLcontext *ctx)
{
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
r300ContextPtr rmesa = R300_CONTEXT( ctx );
r300ChooseRenderState(ctx);
@@ -501,6 +508,19 @@ void r300RenderStart(GLcontext *ctx)
r300UpdateShaderStates(rmesa);
+ const int vertex_size = 7;
+ const int prim_size = 3;
+
+ if (!rmesa->radeon.swtcl.primitive_counter) {
+ if (rcommonEnsureCmdBufSpace(&rmesa->radeon,
+ radeonCountStateEmitSize(&rmesa->radeon) +
+ + vertex_size + prim_size,
+ __FUNCTION__))
+ rmesa->radeon.swtcl.primitive_counter = 0;
+ else
+ rmesa->radeon.swtcl.primitive_counter = 1;
+ }
+
r300EmitCacheFlush(rmesa);
/* investigate if we can put back flush optimisation if needed */
@@ -516,6 +536,8 @@ void r300RenderFinish(GLcontext *ctx)
static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
R300_NEWPRIM( rmesa );
@@ -528,6 +550,8 @@ void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
r300ContextPtr rmesa = R300_CONTEXT(ctx);
rmesa->radeon.swtcl.render_primitive = prim;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
return;
@@ -537,6 +561,8 @@ void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
void r300ResetLineStipple(GLcontext *ctx)
{
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
}
void r300InitSwtcl(GLcontext *ctx)
@@ -544,11 +570,14 @@ void r300InitSwtcl(GLcontext *ctx)
TNLcontext *tnl = TNL_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
static int firsttime = 1;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
if (firsttime) {
init_rast_tab();
firsttime = 0;
}
+ rmesa->radeon.swtcl.primitive_counter = 0;
tnl->Driver.Render.Start = r300RenderStart;
tnl->Driver.Render.Finish = r300RenderFinish;
@@ -597,6 +626,8 @@ static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vert
{
BATCH_LOCALS(&rmesa->radeon);
int type, num_verts;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
type = r300PrimitiveType(rmesa, primitive);
num_verts = r300NumVerts(rmesa, vertex_nr, primitive);
@@ -609,11 +640,10 @@ static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vert
void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
{
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __func__);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
- rcommonEnsureCmdBufSpace(&rmesa->radeon,
- rmesa->radeon.hw.max_state_size + (12*sizeof(int)),
- __FUNCTION__);
radeonEmitState(&rmesa->radeon);
r300_emit_scissor(ctx);
r300EmitVertexAOS(rmesa,
@@ -625,5 +655,6 @@ void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
rmesa->radeon.swtcl.hw_primitive,
rmesa->radeon.swtcl.numverts);
r300EmitCacheFlush(rmesa);
+ rmesa->radeon.swtcl.primitive_counter = 0;
COMMIT_BATCH();
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index cb47484de1a..5c4b4abaca4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -342,6 +342,7 @@ struct radeon_swtcl_info {
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
+ GLuint primitive_counter;
};
#define RADEON_MAX_AOS_ARRAYS 16
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
index 51f764cf473..7aa59675b7a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.c
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.c
@@ -428,7 +428,6 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
{
GLuint bytes = vsize * nverts;
void *head;
-restart:
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s\n", __FUNCTION__);
if (is_empty_list(&rmesa->dma.reserved)
@@ -437,13 +436,7 @@ restart:
}
if (!rmesa->dma.flush) {
- /* make sure we have enough space to use this in cmdbuf */
- rcommonEnsureCmdBufSpace(rmesa,
- radeonCountStateEmitSize( rmesa ) + (20*sizeof(int)),
- __FUNCTION__);
/* if cmdbuf flushed DMA restart */
- if (is_empty_list(&rmesa->dma.reserved))
- goto restart;
rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
rmesa->dma.flush = rcommon_flush_last_swtcl_prim;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
index 14d5b5a2af1..c9e399f9b61 100644
--- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
@@ -223,13 +223,23 @@ static void radeonSetVertexFormat( GLcontext *ctx )
static void radeonRenderStart( GLcontext *ctx )
{
- r100ContextPtr rmesa = R100_CONTEXT( ctx );
-
- radeonSetVertexFormat( ctx );
-
- if (rmesa->radeon.dma.flush != 0 &&
- rmesa->radeon.dma.flush != rcommon_flush_last_swtcl_prim)
- rmesa->radeon.dma.flush( ctx );
+ r100ContextPtr rmesa = R100_CONTEXT( ctx );
+
+ radeonSetVertexFormat( ctx );
+
+ if (rmesa->radeon.dma.flush != 0 &&
+ rmesa->radeon.dma.flush != rcommon_flush_last_swtcl_prim)
+ rmesa->radeon.dma.flush( ctx );
+
+ if (!rmesa->radeon.swtcl.primitive_counter) {
+ if (rcommonEnsureCmdBufSpace(&rmesa->radeon,
+ radeonCountStateEmitSize( &rmesa->radeon ) +
+ (8 + 8 + 7), /* scissor + primis + VertexAOS */
+ __FUNCTION__))
+ rmesa->radeon.swtcl.primitive_counter = 0;
+ else
+ rmesa->radeon.swtcl.primitive_counter = 1;
+ }
}
@@ -284,9 +294,6 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
- rcommonEnsureCmdBufSpace(&rmesa->radeon,
- radeonCountStateEmitSize( &rmesa->radeon ) + (12*sizeof(int)),
- __FUNCTION__);
radeonEmitState(&rmesa->radeon);
@@ -301,6 +308,9 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
rmesa->radeon.swtcl.hw_primitive,
rmesa->radeon.swtcl.numverts);
+
+ rmesa->radeon.swtcl.primitive_counter = 0;
+
}
/*
@@ -804,6 +814,7 @@ void radeonInitSwtcl( GLcontext *ctx )
if (firsttime) {
init_rast_tab();
firsttime = 0;
+ rmesa->radeon.swtcl.primitive_counter = 0;
}
tnl->Driver.Render.Start = radeonRenderStart;