svga: Use _debug_printf, so that output may be dumped in release builds too.

The dump calls should be wrapped in #ifdef DEBUG .. #endif.
This commit is contained in:
José Fonseca 2009-12-05 06:05:56 +00:00
parent 501989bbcd
commit 781d8fccba
3 changed files with 687 additions and 687 deletions

File diff suppressed because it is too large Load diff

View file

@ -71,14 +71,14 @@ class decl_dumper_t(decl_visitor.decl_visitor_t):
print ' switch(%s) {' % ("(*cmd)" + self._instance,)
for name, value in self.decl.values:
print ' case %s:' % (name,)
print ' debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)
print ' _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)
print ' break;'
print ' default:'
print ' debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
print ' break;'
print ' }'
else:
print ' debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
def dump_decl(instance, decl):
@ -154,7 +154,7 @@ class type_dumper_t(type_visitor.type_visitor_t):
dump_decl(self.instance, decl)
def print_instance(self, format):
print ' debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)
print ' _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)
def dump_type(instance, type_):
@ -230,7 +230,7 @@ svga_dump_commands(const void *commands, uint32_t size)
indexes = 'ijklmn'
for id, header, body, footer in cmds:
print ' case %s:' % id
print ' debug_printf("\\t%s\\n");' % id
print ' _debug_printf("\\t%s\\n");' % id
print ' {'
print ' const %s *cmd = (const %s *)body;' % (header, header)
if len(body):
@ -255,25 +255,25 @@ svga_dump_commands(const void *commands, uint32_t size)
print ' }'
print ' break;'
print ' default:'
print ' debug_printf("\\t0x%08x\\n", cmd_id);'
print ' _debug_printf("\\t0x%08x\\n", cmd_id);'
print ' break;'
print ' }'
print r'''
while(body + sizeof(uint32_t) <= next) {
debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
_debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
body += sizeof(uint32_t);
}
while(body + sizeof(uint32_t) <= next)
debug_printf("\t\t0x%02x\n", *body++);
_debug_printf("\t\t0x%02x\n", *body++);
}
else if(cmd_id == SVGA_CMD_FENCE) {
debug_printf("\tSVGA_CMD_FENCE\n");
debug_printf("\t\t0x%08x\n", ((const uint32_t *)next)[1]);
_debug_printf("\tSVGA_CMD_FENCE\n");
_debug_printf("\t\t0x%08x\n", ((const uint32_t *)next)[1]);
next += 2*sizeof(uint32_t);
}
else {
debug_printf("\t0x%08x\n", cmd_id);
_debug_printf("\t0x%08x\n", cmd_id);
next += sizeof(uint32_t);
}
}

View file

@ -50,16 +50,16 @@ static void dump_op( struct sh_op op, const char *mnemonic )
assert( op.is_reg == 0 );
if (op.coissue)
debug_printf( "+" );
debug_printf( "%s", mnemonic );
_debug_printf( "+" );
_debug_printf( "%s", mnemonic );
switch (op.control) {
case 0:
break;
case SVGA3DOPCONT_PROJECT:
debug_printf( "p" );
_debug_printf( "p" );
break;
case SVGA3DOPCONT_BIAS:
debug_printf( "b" );
_debug_printf( "b" );
break;
default:
assert( 0 );
@ -72,28 +72,28 @@ static void dump_comp_op( struct sh_op op, const char *mnemonic )
assert( op.is_reg == 0 );
if (op.coissue)
debug_printf( "+" );
debug_printf( "%s", mnemonic );
_debug_printf( "+" );
_debug_printf( "%s", mnemonic );
switch (op.control) {
case SVGA3DOPCOMP_RESERVED0:
break;
case SVGA3DOPCOMP_GT:
debug_printf("_gt");
_debug_printf("_gt");
break;
case SVGA3DOPCOMP_EQ:
debug_printf("_eq");
_debug_printf("_eq");
break;
case SVGA3DOPCOMP_GE:
debug_printf("_ge");
_debug_printf("_ge");
break;
case SVGA3DOPCOMP_LT:
debug_printf("_lt");
_debug_printf("_lt");
break;
case SVGA3DOPCOMPC_NE:
debug_printf("_ne");
_debug_printf("_ne");
break;
case SVGA3DOPCOMP_LE:
debug_printf("_le");
_debug_printf("_le");
break;
case SVGA3DOPCOMP_RESERVED1:
default:
@ -109,93 +109,93 @@ static void dump_reg( struct sh_reg reg, struct sh_srcreg *indreg, const struct
switch (sh_reg_type( reg )) {
case SVGA3DREG_TEMP:
debug_printf( "r%u", reg.number );
_debug_printf( "r%u", reg.number );
break;
case SVGA3DREG_INPUT:
debug_printf( "v%u", reg.number );
_debug_printf( "v%u", reg.number );
break;
case SVGA3DREG_CONST:
if (reg.relative) {
if (sh_srcreg_type( *indreg ) == SVGA3DREG_LOOP)
debug_printf( "c[aL+%u]", reg.number );
_debug_printf( "c[aL+%u]", reg.number );
else
debug_printf( "c[a%u.x+%u]", indreg->number, reg.number );
_debug_printf( "c[a%u.x+%u]", indreg->number, reg.number );
}
else
debug_printf( "c%u", reg.number );
_debug_printf( "c%u", reg.number );
break;
case SVGA3DREG_ADDR: /* VS */
/* SVGA3DREG_TEXTURE */ /* PS */
if (di->is_ps)
debug_printf( "t%u", reg.number );
_debug_printf( "t%u", reg.number );
else
debug_printf( "a%u", reg.number );
_debug_printf( "a%u", reg.number );
break;
case SVGA3DREG_RASTOUT:
switch (reg.number) {
case 0 /*POSITION*/:
debug_printf( "oPos" );
_debug_printf( "oPos" );
break;
case 1 /*FOG*/:
debug_printf( "oFog" );
_debug_printf( "oFog" );
break;
case 2 /*POINT_SIZE*/:
debug_printf( "oPts" );
_debug_printf( "oPts" );
break;
default:
assert( 0 );
debug_printf( "???" );
_debug_printf( "???" );
}
break;
case SVGA3DREG_ATTROUT:
assert( reg.number < 2 );
debug_printf( "oD%u", reg.number );
_debug_printf( "oD%u", reg.number );
break;
case SVGA3DREG_TEXCRDOUT:
/* SVGA3DREG_OUTPUT */
debug_printf( "oT%u", reg.number );
_debug_printf( "oT%u", reg.number );
break;
case SVGA3DREG_COLOROUT:
debug_printf( "oC%u", reg.number );
_debug_printf( "oC%u", reg.number );
break;
case SVGA3DREG_DEPTHOUT:
debug_printf( "oD%u", reg.number );
_debug_printf( "oD%u", reg.number );
break;
case SVGA3DREG_SAMPLER:
debug_printf( "s%u", reg.number );
_debug_printf( "s%u", reg.number );
break;
case SVGA3DREG_CONSTBOOL:
assert( !reg.relative );
debug_printf( "b%u", reg.number );
_debug_printf( "b%u", reg.number );
break;
case SVGA3DREG_CONSTINT:
assert( !reg.relative );
debug_printf( "i%u", reg.number );
_debug_printf( "i%u", reg.number );
break;
case SVGA3DREG_LOOP:
assert( reg.number == 0 );
debug_printf( "aL" );
_debug_printf( "aL" );
break;
case SVGA3DREG_MISCTYPE:
switch (reg.number) {
case SVGA3DMISCREG_POSITION:
debug_printf( "vPos" );
_debug_printf( "vPos" );
break;
case SVGA3DMISCREG_FACE:
debug_printf( "vFace" );
_debug_printf( "vFace" );
break;
default:
assert(0);
@ -204,46 +204,46 @@ static void dump_reg( struct sh_reg reg, struct sh_srcreg *indreg, const struct
break;
case SVGA3DREG_LABEL:
debug_printf( "l%u", reg.number );
_debug_printf( "l%u", reg.number );
break;
case SVGA3DREG_PREDICATE:
debug_printf( "p%u", reg.number );
_debug_printf( "p%u", reg.number );
break;
default:
assert( 0 );
debug_printf( "???" );
_debug_printf( "???" );
}
}
static void dump_cdata( struct sh_cdata cdata )
{
debug_printf( "%f, %f, %f, %f", cdata.xyzw[0], cdata.xyzw[1], cdata.xyzw[2], cdata.xyzw[3] );
_debug_printf( "%f, %f, %f, %f", cdata.xyzw[0], cdata.xyzw[1], cdata.xyzw[2], cdata.xyzw[3] );
}
static void dump_idata( struct sh_idata idata )
{
debug_printf( "%d, %d, %d, %d", idata.xyzw[0], idata.xyzw[1], idata.xyzw[2], idata.xyzw[3] );
_debug_printf( "%d, %d, %d, %d", idata.xyzw[0], idata.xyzw[1], idata.xyzw[2], idata.xyzw[3] );
}
static void dump_bdata( boolean bdata )
{
debug_printf( bdata ? "TRUE" : "FALSE" );
_debug_printf( bdata ? "TRUE" : "FALSE" );
}
static void dump_sampleinfo( struct ps_sampleinfo sampleinfo )
{
switch (sampleinfo.texture_type) {
case SVGA3DSAMP_2D:
debug_printf( "_2d" );
_debug_printf( "_2d" );
break;
case SVGA3DSAMP_CUBE:
debug_printf( "_cube" );
_debug_printf( "_cube" );
break;
case SVGA3DSAMP_VOLUME:
debug_printf( "_volume" );
_debug_printf( "_volume" );
break;
default:
assert( 0 );
@ -255,46 +255,46 @@ static void dump_usageinfo( struct vs_semantic semantic )
{
switch (semantic.usage) {
case SVGA3D_DECLUSAGE_POSITION:
debug_printf("_position" );
_debug_printf("_position" );
break;
case SVGA3D_DECLUSAGE_BLENDWEIGHT:
debug_printf("_blendweight" );
_debug_printf("_blendweight" );
break;
case SVGA3D_DECLUSAGE_BLENDINDICES:
debug_printf("_blendindices" );
_debug_printf("_blendindices" );
break;
case SVGA3D_DECLUSAGE_NORMAL:
debug_printf("_normal" );
_debug_printf("_normal" );
break;
case SVGA3D_DECLUSAGE_PSIZE:
debug_printf("_psize" );
_debug_printf("_psize" );
break;
case SVGA3D_DECLUSAGE_TEXCOORD:
debug_printf("_texcoord");
_debug_printf("_texcoord");
break;
case SVGA3D_DECLUSAGE_TANGENT:
debug_printf("_tangent" );
_debug_printf("_tangent" );
break;
case SVGA3D_DECLUSAGE_BINORMAL:
debug_printf("_binormal" );
_debug_printf("_binormal" );
break;
case SVGA3D_DECLUSAGE_TESSFACTOR:
debug_printf("_tessfactor" );
_debug_printf("_tessfactor" );
break;
case SVGA3D_DECLUSAGE_POSITIONT:
debug_printf("_positiont" );
_debug_printf("_positiont" );
break;
case SVGA3D_DECLUSAGE_COLOR:
debug_printf("_color" );
_debug_printf("_color" );
break;
case SVGA3D_DECLUSAGE_FOG:
debug_printf("_fog" );
_debug_printf("_fog" );
break;
case SVGA3D_DECLUSAGE_DEPTH:
debug_printf("_depth" );
_debug_printf("_depth" );
break;
case SVGA3D_DECLUSAGE_SAMPLE:
debug_printf("_sample");
_debug_printf("_sample");
break;
default:
assert( 0 );
@ -302,7 +302,7 @@ static void dump_usageinfo( struct vs_semantic semantic )
}
if (semantic.usage_index != 0) {
debug_printf("%d", semantic.usage_index );
_debug_printf("%d", semantic.usage_index );
}
}
@ -316,47 +316,47 @@ static void dump_dstreg( struct sh_dstreg dstreg, const struct dump_info *di )
assert( (dstreg.modifier & (SVGA3DDSTMOD_SATURATE | SVGA3DDSTMOD_PARTIALPRECISION)) == dstreg.modifier );
if (dstreg.modifier & SVGA3DDSTMOD_SATURATE)
debug_printf( "_sat" );
_debug_printf( "_sat" );
if (dstreg.modifier & SVGA3DDSTMOD_PARTIALPRECISION)
debug_printf( "_pp" );
_debug_printf( "_pp" );
switch (dstreg.shift_scale) {
case 0:
break;
case 1:
debug_printf( "_x2" );
_debug_printf( "_x2" );
break;
case 2:
debug_printf( "_x4" );
_debug_printf( "_x4" );
break;
case 3:
debug_printf( "_x8" );
_debug_printf( "_x8" );
break;
case 13:
debug_printf( "_d8" );
_debug_printf( "_d8" );
break;
case 14:
debug_printf( "_d4" );
_debug_printf( "_d4" );
break;
case 15:
debug_printf( "_d2" );
_debug_printf( "_d2" );
break;
default:
assert( 0 );
}
debug_printf( " " );
_debug_printf( " " );
u.dstreg = dstreg;
dump_reg( u.reg, NULL, di );
if (dstreg.write_mask != SVGA3DWRITEMASK_ALL) {
debug_printf( "." );
_debug_printf( "." );
if (dstreg.write_mask & SVGA3DWRITEMASK_0)
debug_printf( "x" );
_debug_printf( "x" );
if (dstreg.write_mask & SVGA3DWRITEMASK_1)
debug_printf( "y" );
_debug_printf( "y" );
if (dstreg.write_mask & SVGA3DWRITEMASK_2)
debug_printf( "z" );
_debug_printf( "z" );
if (dstreg.write_mask & SVGA3DWRITEMASK_3)
debug_printf( "w" );
_debug_printf( "w" );
}
}
@ -372,19 +372,19 @@ static void dump_srcreg( struct sh_srcreg srcreg, struct sh_srcreg *indreg, cons
case SVGA3DSRCMOD_BIASNEG:
case SVGA3DSRCMOD_SIGNNEG:
case SVGA3DSRCMOD_X2NEG:
debug_printf( "-" );
_debug_printf( "-" );
break;
case SVGA3DSRCMOD_ABS:
debug_printf( "|" );
_debug_printf( "|" );
break;
case SVGA3DSRCMOD_ABSNEG:
debug_printf( "-|" );
_debug_printf( "-|" );
break;
case SVGA3DSRCMOD_COMP:
debug_printf( "1-" );
_debug_printf( "1-" );
break;
case SVGA3DSRCMOD_NOT:
debug_printf( "!" );
_debug_printf( "!" );
}
u.srcreg = srcreg;
@ -397,39 +397,39 @@ static void dump_srcreg( struct sh_srcreg srcreg, struct sh_srcreg *indreg, cons
break;
case SVGA3DSRCMOD_ABS:
case SVGA3DSRCMOD_ABSNEG:
debug_printf( "|" );
_debug_printf( "|" );
break;
case SVGA3DSRCMOD_BIAS:
case SVGA3DSRCMOD_BIASNEG:
debug_printf( "_bias" );
_debug_printf( "_bias" );
break;
case SVGA3DSRCMOD_SIGN:
case SVGA3DSRCMOD_SIGNNEG:
debug_printf( "_bx2" );
_debug_printf( "_bx2" );
break;
case SVGA3DSRCMOD_X2:
case SVGA3DSRCMOD_X2NEG:
debug_printf( "_x2" );
_debug_printf( "_x2" );
break;
case SVGA3DSRCMOD_DZ:
debug_printf( "_dz" );
_debug_printf( "_dz" );
break;
case SVGA3DSRCMOD_DW:
debug_printf( "_dw" );
_debug_printf( "_dw" );
break;
default:
assert( 0 );
}
if (srcreg.swizzle_x != 0 || srcreg.swizzle_y != 1 || srcreg.swizzle_z != 2 || srcreg.swizzle_w != 3) {
debug_printf( "." );
_debug_printf( "." );
if (srcreg.swizzle_x == srcreg.swizzle_y && srcreg.swizzle_y == srcreg.swizzle_z && srcreg.swizzle_z == srcreg.swizzle_w) {
debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
_debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
}
else {
debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
debug_printf( "%c", "xyzw"[srcreg.swizzle_y] );
debug_printf( "%c", "xyzw"[srcreg.swizzle_z] );
debug_printf( "%c", "xyzw"[srcreg.swizzle_w] );
_debug_printf( "%c", "xyzw"[srcreg.swizzle_x] );
_debug_printf( "%c", "xyzw"[srcreg.swizzle_y] );
_debug_printf( "%c", "xyzw"[srcreg.swizzle_z] );
_debug_printf( "%c", "xyzw"[srcreg.swizzle_w] );
}
}
}
@ -447,15 +447,15 @@ svga_shader_dump(
if (do_binary) {
for (i = 0; i < dwords; i++)
debug_printf(" 0x%08x,\n", assem[i]);
_debug_printf(" 0x%08x,\n", assem[i]);
debug_printf("\n\n");
_debug_printf("\n\n");
}
di.version.value = *assem++;
di.is_ps = (di.version.type == SVGA3D_PS_TYPE);
debug_printf(
_debug_printf(
"%s_%u_%u\n",
di.is_ps ? "ps" : "vs",
di.version.major,
@ -465,7 +465,7 @@ svga_shader_dump(
struct sh_op op = *(struct sh_op *) assem;
if (assem - start >= dwords) {
debug_printf("... ran off end of buffer\n");
_debug_printf("... ran off end of buffer\n");
assert(0);
return;
}
@ -475,7 +475,7 @@ svga_shader_dump(
{
struct sh_dcl dcl = *(struct sh_dcl *) assem;
debug_printf( "dcl" );
_debug_printf( "dcl" );
if (sh_dstreg_type( dcl.reg ) == SVGA3DREG_SAMPLER)
dump_sampleinfo( dcl.u.ps.sampleinfo );
else if (di.is_ps) {
@ -486,7 +486,7 @@ svga_shader_dump(
else
dump_usageinfo( dcl.u.vs.semantic );
dump_dstreg( dcl.reg, &di );
debug_printf( "\n" );
_debug_printf( "\n" );
assem += sizeof( struct sh_dcl ) / sizeof( unsigned );
}
break;
@ -495,11 +495,11 @@ svga_shader_dump(
{
struct sh_defb defb = *(struct sh_defb *) assem;
debug_printf( "defb " );
_debug_printf( "defb " );
dump_reg( defb.reg, NULL, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_bdata( defb.data );
debug_printf( "\n" );
_debug_printf( "\n" );
assem += sizeof( struct sh_defb ) / sizeof( unsigned );
}
break;
@ -508,11 +508,11 @@ svga_shader_dump(
{
struct sh_defi defi = *(struct sh_defi *) assem;
debug_printf( "defi " );
_debug_printf( "defi " );
dump_reg( defi.reg, NULL, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_idata( defi.idata );
debug_printf( "\n" );
_debug_printf( "\n" );
assem += sizeof( struct sh_defi ) / sizeof( unsigned );
}
break;
@ -528,11 +528,11 @@ svga_shader_dump(
else {
struct sh_unaryop unaryop = *(struct sh_unaryop *) assem;
dump_dstreg( unaryop.dst, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_srcreg( unaryop.src, NULL, &di );
assem += sizeof( struct sh_unaryop ) / sizeof( unsigned );
}
debug_printf( "\n" );
_debug_printf( "\n" );
break;
case SVGA3DOP_TEX:
@ -549,7 +549,7 @@ svga_shader_dump(
struct sh_unaryop unaryop = *(struct sh_unaryop *) assem;
dump_dstreg( unaryop.dst, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_srcreg( unaryop.src, NULL, &di );
assem += sizeof( struct sh_unaryop ) / sizeof( unsigned );
}
@ -559,30 +559,30 @@ svga_shader_dump(
dump_op( op, "texld" );
dump_dstreg( binaryop.dst, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_srcreg( binaryop.src0, NULL, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_srcreg( binaryop.src1, NULL, &di );
assem += sizeof( struct sh_binaryop ) / sizeof( unsigned );
}
debug_printf( "\n" );
_debug_printf( "\n" );
break;
case SVGA3DOP_DEF:
{
struct sh_def def = *(struct sh_def *) assem;
debug_printf( "def " );
_debug_printf( "def " );
dump_reg( def.reg, NULL, &di );
debug_printf( ", " );
_debug_printf( ", " );
dump_cdata( def.cdata );
debug_printf( "\n" );
_debug_printf( "\n" );
assem += sizeof( struct sh_def ) / sizeof( unsigned );
}
break;
case SVGA3DOP_PHASE:
debug_printf( "phase\n" );
_debug_printf( "phase\n" );
assem += sizeof( struct sh_op ) / sizeof( unsigned );
break;
@ -596,12 +596,12 @@ svga_shader_dump(
break;
case SVGA3DOP_RET:
debug_printf( "ret\n" );
_debug_printf( "ret\n" );
assem += sizeof( struct sh_op ) / sizeof( unsigned );
break;
case SVGA3DOP_END:
debug_printf( "end\n" );
_debug_printf( "end\n" );
finished = TRUE;
break;
@ -640,14 +640,14 @@ svga_shader_dump(
}
if (not_first_arg)
debug_printf( ", " );
_debug_printf( ", " );
else
debug_printf( " " );
_debug_printf( " " );
dump_srcreg( srcreg, &indreg, &di );
not_first_arg = TRUE;
}
debug_printf( "\n" );
_debug_printf( "\n" );
}
}
}