radeon: Improve state emit code.

Trying to make understanding code easier with small refactoring and renaming.
This commit is contained in:
Pauli Nieminen
2009-08-21 20:44:54 +03:00
parent 0bf4308580
commit b7ec2ebe33
8 changed files with 78 additions and 60 deletions
+1 -1
View File
@@ -269,7 +269,7 @@ void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
rcommonEnsureCmdBufSpace(&rmesa->radeon,
radeonCountEmitSize(&rmesa->radeon) + (12*sizeof(int)),
radeonCountStateEmitSize(&rmesa->radeon) + (12*sizeof(int)),
__FUNCTION__);
+1 -1
View File
@@ -387,7 +387,7 @@ static void r200EnsureEmitSize( GLcontext * ctx , GLubyte* vimap_rev )
{
/* count the prediction for state size */
space_required = radeonCountEmitSize( &rmesa->radeon );
space_required = radeonCountStateEmitSize( &rmesa->radeon );
/* vtx may be changed in r200EmitArrays so account for it if not dirty */
if (!rmesa->hw.vtx.dirty)
space_required += rmesa->hw.vtx.check(rmesa->radeon.glCtx, &rmesa->hw.vtx);
+2 -2
View File
@@ -582,12 +582,12 @@ static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx, GLuint nr_prims)
+ SCISSORS_BUFSZ
+ FIREAOS_BUFSZ )*nr_prims;
state_size= radeonCountEmitSize(&r300->radeon);
state_size = radeonCountStateEmitSize(&r300->radeon);
flushed = rcommonEnsureCmdBufSpace(&r300->radeon,
dwords + state_size,
__FUNCTION__);
if (flushed)
dwords += radeonCountEmitSize(&r300->radeon);
dwords += radeonCountStateEmitSize(&r300->radeon);
else
dwords += state_size;
+70 -52
View File
@@ -895,7 +895,7 @@ void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei he
ctx->Driver.Viewport = old_viewport;
}
static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state_atom *state)
static void radeon_print_state_atom_prekmm(radeonContextPtr radeon, struct radeon_state_atom *state)
{
int i, j, reg;
int dwords = (*state->check) (radeon->glCtx, state);
@@ -920,13 +920,22 @@ static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state
}
}
static void radeon_print_state_atom_kmm(radeonContextPtr radeon, struct radeon_state_atom *state)
static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state_atom *state)
{
int i, j, reg, count;
int dwords = (*state->check) (radeon->glCtx, state);
int dwords;
uint32_t packet0;
if (! (DEBUG_CMDBUF || RADEON_DEBUG & DEBUG_STATE))
return;
fprintf(stderr, " emit %s %d/%d\n", state->name, state->cmd_size, dwords);
if (!radeon->radeonScreen->kernel_mm) {
radeon_print_state_atom_prekmm(radeon, state);
return;
}
dwords = (*state->check) (radeon->glCtx, state);
fprintf(stderr, " emit %s %d/%d\n", state->name, dwords, state->cmd_size);
if (RADEON_DEBUG & DEBUG_VERBOSE) {
for (i = 0; i < state->cmd_size;) {
@@ -949,60 +958,68 @@ static void radeon_print_state_atom_kmm(radeonContextPtr radeon, struct radeon_s
/**
* Count total size for next state emit.
**/
GLuint radeonCountEmitSize(radeonContextPtr radeon)
GLuint radeonCountStateEmitSize(radeonContextPtr radeon)
{
struct radeon_state_atom *atom;
int dwords = 0;
/* check if we are going to emit full state */
if (radeon->cmdbuf.cs->cdw && !radeon->hw.all_dirty) {
if (!radeon->hw.is_dirty)
return dwords;
foreach(atom, &radeon->hw.atomlist) {
if (atom->dirty)
dwords += atom->check(radeon->glCtx, atom);
}
} else {
foreach(atom, &radeon->hw.atomlist) {
dwords += atom->check(radeon->glCtx, atom);
}
}
return dwords;
struct radeon_state_atom *atom;
int dwords = 0;
/* check if we are going to emit full state */
if (radeon->cmdbuf.cs->cdw && !radeon->hw.all_dirty) {
if (!radeon->hw.is_dirty)
return dwords;
foreach(atom, &radeon->hw.atomlist) {
if (atom->dirty)
dwords += atom->check(radeon->glCtx, atom);
}
} else {
foreach(atom, &radeon->hw.atomlist) {
dwords += atom->check(radeon->glCtx, atom);
}
}
return dwords;
}
static INLINE void radeonEmitAtoms(radeonContextPtr radeon, GLboolean dirty)
static INLINE void radeon_emit_atom(radeonContextPtr radeon, struct radeon_state_atom *atom)
{
BATCH_LOCALS(radeon);
struct radeon_state_atom *atom;
int dwords;
dwords = (*atom->check) (radeon->glCtx, atom);
if (dwords) {
radeon_print_state_atom(radeon, atom);
if (atom->emit) {
(*atom->emit)(radeon->glCtx, atom);
} else {
BEGIN_BATCH_NO_AUTOSTATE(dwords);
OUT_BATCH_TABLE(atom->cmd, dwords);
END_BATCH();
}
} else {
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, " skip state %s\n",
atom->name);
}
}
atom->dirty = GL_FALSE;
}
static INLINE void radeonEmitAtoms(radeonContextPtr radeon, GLboolean emitAll)
{
struct radeon_state_atom *atom;
if (radeon->vtbl.pre_emit_atoms)
radeon->vtbl.pre_emit_atoms(radeon);
/* Emit actual atoms */
foreach(atom, &radeon->hw.atomlist) {
if ((atom->dirty || radeon->hw.all_dirty) == dirty) {
dwords = (*atom->check) (radeon->glCtx, atom);
if (dwords) {
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
if (radeon->radeonScreen->kernel_mm)
radeon_print_state_atom_kmm(radeon, atom);
else
radeon_print_state_atom(radeon, atom);
}
if (atom->emit) {
(*atom->emit)(radeon->glCtx, atom);
} else {
BEGIN_BATCH_NO_AUTOSTATE(dwords);
OUT_BATCH_TABLE(atom->cmd, dwords);
END_BATCH();
}
atom->dirty = GL_FALSE;
} else {
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, " skip state %s\n",
atom->name);
}
}
if (radeon->hw.all_dirty || emitAll) {
foreach(atom, &radeon->hw.atomlist)
radeon_emit_atom( radeon, atom );
} else {
foreach(atom, &radeon->hw.atomlist) {
if ( atom->dirty )
radeon_emit_atom( radeon, atom );
}
}
@@ -1036,16 +1053,17 @@ void radeonEmitState(radeonContextPtr radeon)
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin reemit state\n");
radeonEmitAtoms(radeon, GL_TRUE);
} else {
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin dirty state\n");
radeonEmitAtoms(radeon, GL_FALSE);
}
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin dirty state\n");
radeonEmitAtoms(radeon, GL_TRUE);
radeon->hw.is_dirty = GL_FALSE;
radeon->hw.all_dirty = GL_FALSE;
}
+1 -1
View File
@@ -24,7 +24,7 @@ void radeonUpdatePageFlipping(radeonContextPtr rmesa);
void radeonFlush(GLcontext *ctx);
void radeonFinish(GLcontext * ctx);
void radeonEmitState(radeonContextPtr radeon);
GLuint radeonCountEmitSize(radeonContextPtr radeon);
GLuint radeonCountStateEmitSize(radeonContextPtr radeon);
void radeon_clear_tris(GLcontext *ctx, GLbitfield mask);
+1 -1
View File
@@ -431,7 +431,7 @@ restart:
if (!rmesa->dma.flush) {
/* make sure we have enough space to use this in cmdbuf */
rcommonEnsureCmdBufSpace(rmesa,
radeonCountEmitSize( rmesa ) + (20*sizeof(int)),
radeonCountStateEmitSize( rmesa ) + (20*sizeof(int)),
__FUNCTION__);
/* if cmdbuf flushed DMA restart */
if (is_empty_list(&rmesa->dma.reserved))
+1 -1
View File
@@ -285,7 +285,7 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
r100ContextPtr rmesa = R100_CONTEXT(ctx);
rcommonEnsureCmdBufSpace(&rmesa->radeon,
radeonCountEmitSize( &rmesa->radeon ) + (12*sizeof(int)),
radeonCountStateEmitSize( &rmesa->radeon ) + (12*sizeof(int)),
__FUNCTION__);
+1 -1
View File
@@ -388,7 +388,7 @@ static void radeonEnsureEmitSize( GLcontext * ctx , GLuint inputs )
{
/* count the prediction for state size */
space_required = radeonCountEmitSize( &rmesa->radeon );
space_required = radeonCountStateEmitSize( &rmesa->radeon );
/* tcl may be changed in radeonEmitArrays so account for it if not dirty */
if (!rmesa->hw.tcl.dirty)
space_required += rmesa->hw.tcl.check( rmesa->radeon.glCtx, &rmesa->hw.tcl );