summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorPauli Nieminen <[email protected]>2009-08-27 00:08:30 +0300
committerPauli Nieminen <[email protected]>2009-08-27 00:08:30 +0300
commit74b55970dc25d6b2a65f385fd298f141176cd4d3 (patch)
tree646306624c8db0053f0abdb2579b52db123780e8 /src/mesa
parent38f56411067d51ad0de0ea73498964baaacea90b (diff)
parent47d4b9ff70c82956a77e8ea7a6abccaa0a9f9083 (diff)
Merge branch 'fix_r300_swtcl' into push_master
Diffstat (limited to 'src/mesa')
-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.c12
-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
6 files changed, 84 insertions, 26 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.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index e0be15fdef3..0894372fad1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -85,6 +85,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_mipmap_tree.h"
#include "radeon_queryobj.h"
+/**
+ * Enable verbose debug output for emit code.
+ * 0 no output
+ * 1 most output
+ * 2 also print state alues
+ */
#define DEBUG_CMDBUF 0
/* =============================================================
@@ -906,7 +912,7 @@ static void radeon_print_state_atom_prekmm(radeonContextPtr radeon, struct radeo
fprintf(stderr, " emit %s %d/%d\n", state->name, dwords, state->cmd_size);
- if (RADEON_DEBUG & DEBUG_VERBOSE) {
+ if (DEBUG_CMDBUF > 1 && RADEON_DEBUG & DEBUG_VERBOSE) {
if (dwords > state->cmd_size)
dwords = state->cmd_size;
@@ -943,10 +949,10 @@ static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state
fprintf(stderr, " emit %s %d/%d\n", state->name, dwords, state->cmd_size);
- if (RADEON_DEBUG & DEBUG_VERBOSE) {
+ if (DEBUG_CMDBUF > 1 && RADEON_DEBUG & DEBUG_VERBOSE) {
if (dwords > state->cmd_size)
dwords = state->cmd_size;
- for (i = 0; i < state->cmd_size;) {
+ for (i = 0; i < dwords;) {
packet0 = state->cmd[i];
reg = (packet0 & 0x1FFF) << 2;
count = ((packet0 & 0x3FFF0000) >> 16) + 1;
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;