i915_debug.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 #include "i915_reg.h"
00029 #include "i915_context.h"
00030 #include "i915_winsys.h"
00031 #include "i915_debug.h"
00032 #include "pipe/p_winsys.h"
00033 #include "pipe/p_debug.h"
00034 
00035 
00036 static void
00037 PRINTF(
00038    struct debug_stream  *stream,
00039    const char           *fmt,
00040                         ... )
00041 {
00042    va_list  args;
00043 
00044    va_start( args, fmt );
00045    debug_vprintf( fmt, args );
00046    va_end( args );
00047 }
00048 
00049 
00050 static boolean debug( struct debug_stream *stream, const char *name, unsigned len )
00051 {
00052    unsigned i;
00053    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00054    
00055    if (len == 0) {
00056       PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]);
00057       assert(0);
00058       return FALSE;
00059    }
00060 
00061    if (stream->print_addresses)
00062       PRINTF(stream, "%08x:  ", stream->offset);
00063 
00064 
00065    PRINTF(stream, "%s (%d dwords):\n", name, len);
00066    for (i = 0; i < len; i++)
00067       PRINTF(stream, "\t0x%08x\n",  ptr[i]);   
00068    PRINTF(stream, "\n");
00069 
00070    stream->offset += len * sizeof(unsigned);
00071    
00072    return TRUE;
00073 }
00074 
00075 
00076 static const char *get_prim_name( unsigned val )
00077 {
00078    switch (val & PRIM3D_MASK) {
00079    case PRIM3D_TRILIST: return "TRILIST"; break;
00080    case PRIM3D_TRISTRIP: return "TRISTRIP"; break;
00081    case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break;
00082    case PRIM3D_TRIFAN: return "TRIFAN"; break;
00083    case PRIM3D_POLY: return "POLY"; break;
00084    case PRIM3D_LINELIST: return "LINELIST"; break;
00085    case PRIM3D_LINESTRIP: return "LINESTRIP"; break;
00086    case PRIM3D_RECTLIST: return "RECTLIST"; break;
00087    case PRIM3D_POINTLIST: return "POINTLIST"; break;
00088    case PRIM3D_DIB: return "DIB"; break;
00089    case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break;
00090    case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break;
00091    default: return "????"; break;
00092    }
00093 }
00094 
00095 static boolean debug_prim( struct debug_stream *stream, const char *name, 
00096                              boolean dump_floats,
00097                              unsigned len )
00098 {
00099    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00100    const char *prim = get_prim_name( ptr[0] );
00101    unsigned i;
00102    
00103 
00104 
00105    PRINTF(stream, "%s %s (%d dwords):\n", name, prim, len);
00106    PRINTF(stream, "\t0x%08x\n",  ptr[0]);   
00107    for (i = 1; i < len; i++) {
00108       if (dump_floats)
00109          PRINTF(stream, "\t0x%08x // %f\n",  ptr[i], *(float *)&ptr[i]);   
00110       else
00111          PRINTF(stream, "\t0x%08x\n",  ptr[i]);   
00112    }
00113 
00114       
00115    PRINTF(stream, "\n");
00116 
00117    stream->offset += len * sizeof(unsigned);
00118    
00119    return TRUE;
00120 }
00121    
00122 
00123 
00124 
00125 static boolean debug_program( struct debug_stream *stream, const char *name, unsigned len )
00126 {
00127    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00128 
00129    if (len == 0) {
00130       PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]);
00131       assert(0);
00132       return FALSE;
00133    }
00134 
00135    if (stream->print_addresses)
00136       PRINTF(stream, "%08x:  ", stream->offset);
00137 
00138    PRINTF(stream, "%s (%d dwords):\n", name, len);
00139    i915_disassemble_program( stream, ptr, len );
00140 
00141    stream->offset += len * sizeof(unsigned);
00142    return TRUE;
00143 }
00144 
00145 
00146 static boolean debug_chain( struct debug_stream *stream, const char *name, unsigned len )
00147 {
00148    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00149    unsigned old_offset = stream->offset + len * sizeof(unsigned);
00150    unsigned i;
00151 
00152    PRINTF(stream, "%s (%d dwords):\n", name, len);
00153    for (i = 0; i < len; i++)
00154       PRINTF(stream, "\t0x%08x\n",  ptr[i]);
00155 
00156    stream->offset = ptr[1] & ~0x3;
00157    
00158    if (stream->offset < old_offset)
00159       PRINTF(stream, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n", 
00160                    old_offset, stream->offset );
00161    else
00162       PRINTF(stream, "\n... skipping from 0x%x --> 0x%x ...\n\n", 
00163                    old_offset, stream->offset );
00164 
00165 
00166    return TRUE;
00167 }
00168 
00169 
00170 static boolean debug_variable_length_prim( struct debug_stream *stream )
00171 {
00172    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00173    const char *prim = get_prim_name( ptr[0] );
00174    unsigned i, len;
00175 
00176    ushort *idx = (ushort *)(ptr+1);
00177    for (i = 0; idx[i] != 0xffff; i++)
00178       ;
00179 
00180    len = 1+(i+2)/2;
00181 
00182    PRINTF(stream, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len);
00183    for (i = 0; i < len; i++)
00184       PRINTF(stream, "\t0x%08x\n",  ptr[i]);
00185    PRINTF(stream, "\n");
00186 
00187    stream->offset += len * sizeof(unsigned);
00188    return TRUE;
00189 }
00190 
00191 
00192 static void
00193 BITS(
00194    struct debug_stream  *stream,
00195    unsigned             dw,
00196    unsigned             hi,
00197    unsigned             lo,
00198    const char           *fmt,
00199                         ... )
00200 {
00201    va_list  args;
00202    unsigned himask = ~0UL >> (31 - (hi));
00203 
00204    PRINTF(stream, "\t\t ");
00205 
00206    va_start( args, fmt );
00207    debug_vprintf( fmt, args );
00208    va_end( args );
00209 
00210    PRINTF(stream, ": 0x%x\n", ((dw) & himask) >> (lo));
00211 }
00212 
00213 #define MBZ( dw, hi, lo) do {                                                   \
00214    unsigned x = (dw) >> (lo);                           \
00215    unsigned lomask = (1 << (lo)) - 1;                   \
00216    unsigned himask;                                     \
00217    himask = (1UL << (hi)) - 1;                          \
00218    assert ((x & himask & ~lomask) == 0);        \
00219 } while (0)
00220 
00221 static void
00222 FLAG(
00223    struct debug_stream  *stream,
00224    unsigned             dw,
00225    unsigned             bit,
00226    const char           *fmt,
00227                         ... )
00228 {
00229    if (((dw) >> (bit)) & 1) {
00230       va_list  args;
00231 
00232       PRINTF(stream, "\t\t ");
00233 
00234       va_start( args, fmt );
00235       debug_vprintf( fmt, args );
00236       va_end( args );
00237 
00238       PRINTF(stream, "\n");
00239    }
00240 }
00241 
00242 static boolean debug_load_immediate( struct debug_stream *stream,
00243                                        const char *name,
00244                                        unsigned len )
00245 {
00246    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00247    unsigned bits = (ptr[0] >> 4) & 0xff;
00248    unsigned j = 0;
00249    
00250    PRINTF(stream, "%s (%d dwords, flags: %x):\n", name, len, bits);
00251    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00252 
00253    if (bits & (1<<0)) {
00254       PRINTF(stream, "\t  LIS0: 0x%08x\n", ptr[j]);
00255       PRINTF(stream, "\t vb address: 0x%08x\n", (ptr[j] & ~0x3));
00256       BITS(stream, ptr[j], 0, 0, "vb invalidate disable");
00257       j++;
00258    }
00259    if (bits & (1<<1)) {
00260       PRINTF(stream, "\t  LIS1: 0x%08x\n", ptr[j]);
00261       BITS(stream, ptr[j], 29, 24, "vb dword width");
00262       BITS(stream, ptr[j], 21, 16, "vb dword pitch");
00263       BITS(stream, ptr[j], 15, 0, "vb max index");
00264       j++;
00265    }
00266    if (bits & (1<<2)) {
00267       int i;
00268       PRINTF(stream, "\t  LIS2: 0x%08x\n", ptr[j]);
00269       for (i = 0; i < 8; i++) {
00270          unsigned tc = (ptr[j] >> (i * 4)) & 0xf;
00271          if (tc != 0xf)
00272             BITS(stream, tc, 3, 0, "tex coord %d", i);
00273       }
00274       j++;
00275    }
00276    if (bits & (1<<3)) {
00277       PRINTF(stream, "\t  LIS3: 0x%08x\n", ptr[j]);
00278       j++;
00279    }
00280    if (bits & (1<<4)) {
00281       PRINTF(stream, "\t  LIS4: 0x%08x\n", ptr[j]);
00282       BITS(stream, ptr[j], 31, 23, "point width");
00283       BITS(stream, ptr[j], 22, 19, "line width");
00284       FLAG(stream, ptr[j], 18, "alpha flatshade");
00285       FLAG(stream, ptr[j], 17, "fog flatshade");
00286       FLAG(stream, ptr[j], 16, "spec flatshade");
00287       FLAG(stream, ptr[j], 15, "rgb flatshade");
00288       BITS(stream, ptr[j], 14, 13, "cull mode");
00289       FLAG(stream, ptr[j], 12, "vfmt: point width");
00290       FLAG(stream, ptr[j], 11, "vfmt: specular/fog");
00291       FLAG(stream, ptr[j], 10, "vfmt: rgba");
00292       FLAG(stream, ptr[j], 9, "vfmt: depth offset");
00293       BITS(stream, ptr[j], 8, 6, "vfmt: position (2==xyzw)");
00294       FLAG(stream, ptr[j], 5, "force dflt diffuse");
00295       FLAG(stream, ptr[j], 4, "force dflt specular");
00296       FLAG(stream, ptr[j], 3, "local depth offset enable");
00297       FLAG(stream, ptr[j], 2, "vfmt: fp32 fog coord");
00298       FLAG(stream, ptr[j], 1, "sprite point");
00299       FLAG(stream, ptr[j], 0, "antialiasing");
00300       j++;
00301    }
00302    if (bits & (1<<5)) {
00303       PRINTF(stream, "\t  LIS5: 0x%08x\n", ptr[j]);
00304       BITS(stream, ptr[j], 31, 28, "rgba write disables");
00305       FLAG(stream, ptr[j], 27,     "force dflt point width");
00306       FLAG(stream, ptr[j], 26,     "last pixel enable");
00307       FLAG(stream, ptr[j], 25,     "global z offset enable");
00308       FLAG(stream, ptr[j], 24,     "fog enable");
00309       BITS(stream, ptr[j], 23, 16, "stencil ref");
00310       BITS(stream, ptr[j], 15, 13, "stencil test");
00311       BITS(stream, ptr[j], 12, 10, "stencil fail op");
00312       BITS(stream, ptr[j], 9, 7,   "stencil pass z fail op");
00313       BITS(stream, ptr[j], 6, 4,   "stencil pass z pass op");
00314       FLAG(stream, ptr[j], 3,      "stencil write enable");
00315       FLAG(stream, ptr[j], 2,      "stencil test enable");
00316       FLAG(stream, ptr[j], 1,      "color dither enable");
00317       FLAG(stream, ptr[j], 0,      "logiop enable");
00318       j++;
00319    }
00320    if (bits & (1<<6)) {
00321       PRINTF(stream, "\t  LIS6: 0x%08x\n", ptr[j]);
00322       FLAG(stream, ptr[j], 31,      "alpha test enable");
00323       BITS(stream, ptr[j], 30, 28,  "alpha func");
00324       BITS(stream, ptr[j], 27, 20,  "alpha ref");
00325       FLAG(stream, ptr[j], 19,      "depth test enable");
00326       BITS(stream, ptr[j], 18, 16,  "depth func");
00327       FLAG(stream, ptr[j], 15,      "blend enable");
00328       BITS(stream, ptr[j], 14, 12,  "blend func");
00329       BITS(stream, ptr[j], 11, 8,   "blend src factor");
00330       BITS(stream, ptr[j], 7,  4,   "blend dst factor");
00331       FLAG(stream, ptr[j], 3,       "depth write enable");
00332       FLAG(stream, ptr[j], 2,       "color write enable");
00333       BITS(stream, ptr[j], 1,  0,   "provoking vertex"); 
00334       j++;
00335    }
00336 
00337 
00338    PRINTF(stream, "\n");
00339 
00340    assert(j == len);
00341 
00342    stream->offset += len * sizeof(unsigned);
00343    
00344    return TRUE;
00345 }
00346  
00347 
00348 
00349 static boolean debug_load_indirect( struct debug_stream *stream,
00350                                       const char *name,
00351                                       unsigned len )
00352 {
00353    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00354    unsigned bits = (ptr[0] >> 8) & 0x3f;
00355    unsigned i, j = 0;
00356    
00357    PRINTF(stream, "%s (%d dwords):\n", name, len);
00358    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00359 
00360    for (i = 0; i < 6; i++) {
00361       if (bits & (1<<i)) {
00362          switch (1<<(8+i)) {
00363          case LI0_STATE_STATIC_INDIRECT:
00364             PRINTF(stream, "        STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00365             PRINTF(stream, "                0x%08x\n", ptr[j++]);
00366             break;
00367          case LI0_STATE_DYNAMIC_INDIRECT:
00368             PRINTF(stream, "       DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00369             break;
00370          case LI0_STATE_SAMPLER:
00371             PRINTF(stream, "       SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00372             PRINTF(stream, "                0x%08x\n", ptr[j++]);
00373             break;
00374          case LI0_STATE_MAP:
00375             PRINTF(stream, "           MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00376             PRINTF(stream, "                0x%08x\n", ptr[j++]);
00377             break;
00378          case LI0_STATE_PROGRAM:
00379             PRINTF(stream, "       PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00380             PRINTF(stream, "                0x%08x\n", ptr[j++]);
00381             break;
00382          case LI0_STATE_CONSTANTS:
00383             PRINTF(stream, "     CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
00384             PRINTF(stream, "                0x%08x\n", ptr[j++]);
00385             break;
00386          default:
00387             assert(0);
00388             break;
00389          }
00390       }
00391    }
00392 
00393    if (bits == 0) {
00394       PRINTF(stream, "\t  DUMMY: 0x%08x\n", ptr[j++]);
00395    }
00396 
00397    PRINTF(stream, "\n");
00398 
00399 
00400    assert(j == len);
00401 
00402    stream->offset += len * sizeof(unsigned);
00403    
00404    return TRUE;
00405 }
00406         
00407 static void BR13( struct debug_stream *stream,
00408                   unsigned val )
00409 {
00410    PRINTF(stream, "\t0x%08x\n",  val);
00411    FLAG(stream, val, 30, "clipping enable");
00412    BITS(stream, val, 25, 24, "color depth (3==32bpp)");
00413    BITS(stream, val, 23, 16, "raster op");
00414    BITS(stream, val, 15, 0,  "dest pitch");
00415 }
00416 
00417 
00418 static void BR22( struct debug_stream *stream,
00419                   unsigned val )
00420 {
00421    PRINTF(stream, "\t0x%08x\n",  val);
00422    BITS(stream, val, 31, 16, "dest y1");
00423    BITS(stream, val, 15, 0,  "dest x1");
00424 }
00425 
00426 static void BR23( struct debug_stream *stream,
00427                   unsigned val )
00428 {
00429    PRINTF(stream, "\t0x%08x\n",  val);
00430    BITS(stream, val, 31, 16, "dest y2");
00431    BITS(stream, val, 15, 0,  "dest x2");
00432 }
00433 
00434 static void BR09( struct debug_stream *stream,
00435                   unsigned val )
00436 {
00437    PRINTF(stream, "\t0x%08x -- dest address\n",  val);
00438 }
00439 
00440 static void BR26( struct debug_stream *stream,
00441                   unsigned val )
00442 {
00443    PRINTF(stream, "\t0x%08x\n",  val);
00444    BITS(stream, val, 31, 16, "src y1");
00445    BITS(stream, val, 15, 0,  "src x1");
00446 }
00447 
00448 static void BR11( struct debug_stream *stream,
00449                   unsigned val )
00450 {
00451    PRINTF(stream, "\t0x%08x\n",  val);
00452    BITS(stream, val, 15, 0,  "src pitch");
00453 }
00454 
00455 static void BR12( struct debug_stream *stream,
00456                   unsigned val )
00457 {
00458    PRINTF(stream, "\t0x%08x -- src address\n",  val);
00459 }
00460 
00461 static void BR16( struct debug_stream *stream,
00462                   unsigned val )
00463 {
00464    PRINTF(stream, "\t0x%08x -- color\n",  val);
00465 }
00466    
00467 static boolean debug_copy_blit( struct debug_stream *stream,
00468                                   const char *name,
00469                                   unsigned len )
00470 {
00471    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00472    int j = 0;
00473 
00474    PRINTF(stream, "%s (%d dwords):\n", name, len);
00475    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00476    
00477    BR13(stream, ptr[j++]);
00478    BR22(stream, ptr[j++]);
00479    BR23(stream, ptr[j++]);
00480    BR09(stream, ptr[j++]);
00481    BR26(stream, ptr[j++]);
00482    BR11(stream, ptr[j++]);
00483    BR12(stream, ptr[j++]);
00484 
00485    stream->offset += len * sizeof(unsigned);
00486    assert(j == len);
00487    return TRUE;
00488 }
00489 
00490 static boolean debug_color_blit( struct debug_stream *stream,
00491                                   const char *name,
00492                                   unsigned len )
00493 {
00494    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00495    int j = 0;
00496 
00497    PRINTF(stream, "%s (%d dwords):\n", name, len);
00498    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00499 
00500    BR13(stream, ptr[j++]);
00501    BR22(stream, ptr[j++]);
00502    BR23(stream, ptr[j++]);
00503    BR09(stream, ptr[j++]);
00504    BR16(stream, ptr[j++]);
00505 
00506    stream->offset += len * sizeof(unsigned);
00507    assert(j == len);
00508    return TRUE;
00509 }
00510 
00511 static boolean debug_modes4( struct debug_stream *stream,
00512                                   const char *name,
00513                                   unsigned len )
00514 {
00515    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00516    int j = 0;
00517 
00518    PRINTF(stream, "%s (%d dwords):\n", name, len);
00519    PRINTF(stream, "\t0x%08x\n",  ptr[j]);
00520    BITS(stream, ptr[j], 21, 18, "logicop func");
00521    FLAG(stream, ptr[j], 17, "stencil test mask modify-enable");
00522    FLAG(stream, ptr[j], 16, "stencil write mask modify-enable");
00523    BITS(stream, ptr[j], 15, 8, "stencil test mask");
00524    BITS(stream, ptr[j], 7, 0,  "stencil write mask");
00525    j++;
00526 
00527    stream->offset += len * sizeof(unsigned);
00528    assert(j == len);
00529    return TRUE;
00530 }
00531 
00532 static boolean debug_map_state( struct debug_stream *stream,
00533                                   const char *name,
00534                                   unsigned len )
00535 {
00536    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00537    unsigned j = 0;
00538 
00539    PRINTF(stream, "%s (%d dwords):\n", name, len);
00540    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00541    
00542    {
00543       PRINTF(stream, "\t0x%08x\n",  ptr[j]);
00544       BITS(stream, ptr[j], 15, 0,   "map mask");
00545       j++;
00546    }
00547 
00548    while (j < len) {
00549       {
00550          PRINTF(stream, "\t  TMn.0: 0x%08x\n", ptr[j]);
00551          PRINTF(stream, "\t map address: 0x%08x\n", (ptr[j] & ~0x3));
00552          FLAG(stream, ptr[j], 1, "vertical line stride");
00553          FLAG(stream, ptr[j], 0, "vertical line stride offset");
00554          j++;
00555       }
00556 
00557       {
00558          PRINTF(stream, "\t  TMn.1: 0x%08x\n", ptr[j]);
00559          BITS(stream, ptr[j], 31, 21, "height");
00560          BITS(stream, ptr[j], 20, 10, "width");
00561          BITS(stream, ptr[j], 9, 7, "surface format");
00562          BITS(stream, ptr[j], 6, 3, "texel format");
00563          FLAG(stream, ptr[j], 2, "use fence regs");
00564          FLAG(stream, ptr[j], 1, "tiled surface");
00565          FLAG(stream, ptr[j], 0, "tile walk ymajor");
00566          j++;
00567       }
00568       {
00569          PRINTF(stream, "\t  TMn.2: 0x%08x\n", ptr[j]);
00570          BITS(stream, ptr[j], 31, 21, "dword pitch");
00571          BITS(stream, ptr[j], 20, 15, "cube face enables");
00572          BITS(stream, ptr[j], 14, 9, "max lod");
00573          FLAG(stream, ptr[j], 8,     "mip layout right");
00574          BITS(stream, ptr[j], 7, 0, "depth");
00575          j++;
00576       }
00577    }
00578 
00579    stream->offset += len * sizeof(unsigned);
00580    assert(j == len);
00581    return TRUE;
00582 }
00583 
00584 static boolean debug_sampler_state( struct debug_stream *stream,
00585                                   const char *name,
00586                                   unsigned len )
00587 {
00588    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00589    unsigned j = 0;
00590 
00591    PRINTF(stream, "%s (%d dwords):\n", name, len);
00592    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00593    
00594    {
00595       PRINTF(stream, "\t0x%08x\n",  ptr[j]);
00596       BITS(stream, ptr[j], 15, 0,   "sampler mask");
00597       j++;
00598    }
00599 
00600    while (j < len) {
00601       {
00602          PRINTF(stream, "\t  TSn.0: 0x%08x\n", ptr[j]);
00603          FLAG(stream, ptr[j], 31, "reverse gamma");
00604          FLAG(stream, ptr[j], 30, "planar to packed");
00605          FLAG(stream, ptr[j], 29, "yuv->rgb");
00606          BITS(stream, ptr[j], 28, 27, "chromakey index");
00607          BITS(stream, ptr[j], 26, 22, "base mip level");
00608          BITS(stream, ptr[j], 21, 20, "mip mode filter");
00609          BITS(stream, ptr[j], 19, 17, "mag mode filter");
00610          BITS(stream, ptr[j], 16, 14, "min mode filter");
00611          BITS(stream, ptr[j], 13, 5,  "lod bias (s4.4)");
00612          FLAG(stream, ptr[j], 4,      "shadow enable");
00613          FLAG(stream, ptr[j], 3,      "max-aniso-4");
00614          BITS(stream, ptr[j], 2, 0,   "shadow func");
00615          j++;
00616       }
00617 
00618       {
00619          PRINTF(stream, "\t  TSn.1: 0x%08x\n", ptr[j]);
00620          BITS(stream, ptr[j], 31, 24, "min lod");
00621          MBZ( ptr[j], 23, 18 );
00622          FLAG(stream, ptr[j], 17,     "kill pixel enable");
00623          FLAG(stream, ptr[j], 16,     "keyed tex filter mode");
00624          FLAG(stream, ptr[j], 15,     "chromakey enable");
00625          BITS(stream, ptr[j], 14, 12, "tcx wrap mode");
00626          BITS(stream, ptr[j], 11, 9,  "tcy wrap mode");
00627          BITS(stream, ptr[j], 8,  6,  "tcz wrap mode");
00628          FLAG(stream, ptr[j], 5,      "normalized coords");
00629          BITS(stream, ptr[j], 4,  1,  "map (surface) index");
00630          FLAG(stream, ptr[j], 0,      "EAST deinterlacer enable");
00631          j++;
00632       }
00633       {
00634          PRINTF(stream, "\t  TSn.2: 0x%08x  (default color)\n", ptr[j]);
00635          j++;
00636       }
00637    }
00638 
00639    stream->offset += len * sizeof(unsigned);
00640    assert(j == len);
00641    return TRUE;
00642 }
00643 
00644 static boolean debug_dest_vars( struct debug_stream *stream,
00645                                   const char *name,
00646                                   unsigned len )
00647 {
00648    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00649    int j = 0;
00650 
00651    PRINTF(stream, "%s (%d dwords):\n", name, len);
00652    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00653 
00654    {
00655       PRINTF(stream, "\t0x%08x\n",  ptr[j]);
00656       FLAG(stream, ptr[j], 31,     "early classic ztest");
00657       FLAG(stream, ptr[j], 30,     "opengl tex default color");
00658       FLAG(stream, ptr[j], 29,     "bypass iz");
00659       FLAG(stream, ptr[j], 28,     "lod preclamp");
00660       BITS(stream, ptr[j], 27, 26, "dither pattern");
00661       FLAG(stream, ptr[j], 25,     "linear gamma blend");
00662       FLAG(stream, ptr[j], 24,     "debug dither");
00663       BITS(stream, ptr[j], 23, 20, "dstorg x");
00664       BITS(stream, ptr[j], 19, 16, "dstorg y");
00665       MBZ (ptr[j], 15, 15 );
00666       BITS(stream, ptr[j], 14, 12, "422 write select");
00667       BITS(stream, ptr[j], 11, 8,  "cbuf format");
00668       BITS(stream, ptr[j], 3, 2,   "zbuf format");
00669       FLAG(stream, ptr[j], 1,      "vert line stride");
00670       FLAG(stream, ptr[j], 1,      "vert line stride offset");
00671       j++;
00672    }
00673    
00674    stream->offset += len * sizeof(unsigned);
00675    assert(j == len);
00676    return TRUE;
00677 }
00678 
00679 static boolean debug_buf_info( struct debug_stream *stream,
00680                                   const char *name,
00681                                   unsigned len )
00682 {
00683    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00684    int j = 0;
00685 
00686    PRINTF(stream, "%s (%d dwords):\n", name, len);
00687    PRINTF(stream, "\t0x%08x\n",  ptr[j++]);
00688 
00689    {
00690       PRINTF(stream, "\t0x%08x\n",  ptr[j]);
00691       BITS(stream, ptr[j], 28, 28, "aux buffer id");
00692       BITS(stream, ptr[j], 27, 24, "buffer id (7=depth, 3=back)");
00693       FLAG(stream, ptr[j], 23,     "use fence regs");
00694       FLAG(stream, ptr[j], 22,     "tiled surface");
00695       FLAG(stream, ptr[j], 21,     "tile walk ymajor");
00696       MBZ (ptr[j], 20, 14);
00697       BITS(stream, ptr[j], 13, 2,  "dword pitch");
00698       MBZ (ptr[j], 2,  0);
00699       j++;
00700    }
00701    
00702    PRINTF(stream, "\t0x%08x -- buffer base address\n",  ptr[j++]);
00703 
00704    stream->offset += len * sizeof(unsigned);
00705    assert(j == len);
00706    return TRUE;
00707 }
00708 
00709 static boolean i915_debug_packet( struct debug_stream *stream )
00710 {
00711    unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
00712    unsigned cmd = *ptr;
00713    
00714    switch (((cmd >> 29) & 0x7)) {
00715    case 0x0:
00716       switch ((cmd >> 23) & 0x3f) {
00717       case 0x0:
00718          return debug(stream, "MI_NOOP", 1);
00719       case 0x3:
00720          return debug(stream, "MI_WAIT_FOR_EVENT", 1);
00721       case 0x4:
00722          return debug(stream, "MI_FLUSH", 1);
00723       case 0xA:
00724          debug(stream, "MI_BATCH_BUFFER_END", 1);
00725          return FALSE;
00726       case 0x22:
00727          return debug(stream, "MI_LOAD_REGISTER_IMM", 3);
00728       case 0x31:
00729          return debug_chain(stream, "MI_BATCH_BUFFER_START", 2);
00730       default:
00731          (void)debug(stream, "UNKNOWN 0x0 case!", 1);
00732          assert(0);
00733          break;
00734       }
00735       break;
00736    case 0x1:
00737       (void) debug(stream, "UNKNOWN 0x1 case!", 1);
00738       assert(0);
00739       break;
00740    case 0x2:
00741       switch ((cmd >> 22) & 0xff) {      
00742       case 0x50:
00743          return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2);
00744       case 0x53:
00745          return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2);
00746       default:
00747          return debug(stream, "blit command", (cmd & 0xff) + 2);
00748       }
00749       break;
00750    case 0x3:
00751       switch ((cmd >> 24) & 0x1f) {      
00752       case 0x6:
00753          return debug(stream, "3DSTATE_ANTI_ALIASING", 1);
00754       case 0x7:
00755          return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1);
00756       case 0x8:
00757          return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
00758       case 0x9:
00759          return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
00760       case 0xb:
00761          return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
00762       case 0xc:
00763          return debug(stream, "3DSTATE_MODES5", 1);      
00764       case 0xd:
00765          return debug_modes4(stream, "3DSTATE_MODES4", 1);
00766       case 0x15:
00767          return debug(stream, "3DSTATE_FOG_COLOR", 1);
00768       case 0x16:
00769          return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1);
00770       case 0x1c:
00771          /* 3DState16NP */
00772          switch((cmd >> 19) & 0x1f) {
00773          case 0x10:
00774             return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1);
00775          case 0x11:
00776             return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
00777          default:
00778             (void) debug(stream, "UNKNOWN 0x1c case!", 1);
00779             assert(0);
00780             break;
00781          }
00782          break;
00783       case 0x1d:
00784          /* 3DStateMW */
00785          switch ((cmd >> 16) & 0xff) {
00786          case 0x0:
00787             return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2);
00788          case 0x1:
00789             return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2);
00790          case 0x4:
00791             return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2);
00792          case 0x5:
00793             return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2);
00794          case 0x6:
00795             return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2);
00796          case 0x7:
00797             return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2);
00798          case 0x80:
00799             return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2);
00800          case 0x81:
00801             return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2);
00802          case 0x83:
00803             return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2);
00804          case 0x85:
00805             return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2);
00806          case 0x88:
00807             return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2);
00808          case 0x89:
00809             return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2);
00810          case 0x8e:
00811             return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2);
00812          case 0x97:
00813             return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2);
00814          case 0x98:
00815             return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2);
00816          case 0x99:
00817             return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2);
00818          case 0x9a:
00819             return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2);
00820          case 0x9c:
00821             return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2);
00822          default:
00823             assert(0);
00824             return 0;
00825          }
00826          break;
00827       case 0x1e:
00828          if (cmd & (1 << 23))
00829             return debug(stream, "???", (cmd & 0xffff) + 1);
00830          else
00831             return debug(stream, "", 1);
00832          break;
00833       case 0x1f:
00834          if ((cmd & (1 << 23)) == 0)    
00835             return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2);
00836          else if (cmd & (1 << 17)) 
00837          {
00838             if ((cmd & 0xffff) == 0)
00839                return debug_variable_length_prim(stream);
00840             else
00841                return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1);
00842          }
00843          else
00844             return debug_prim(stream, "3DPRIM  (indirect sequential)", 0, 2); 
00845          break;
00846       default:
00847          return debug(stream, "", 0);
00848       }
00849    default:
00850       assert(0);
00851       return 0;
00852    }
00853 
00854    assert(0);
00855    return 0;
00856 }
00857 
00858 
00859 
00860 void
00861 i915_dump_batchbuffer( struct i915_context *i915 )
00862 {
00863    struct debug_stream stream;
00864    /* TODO fix me */
00865    unsigned *start = 0;/*i915->batch_start;*/
00866    unsigned *end = 0;/*i915->winsys->batch_start( i915->winsys, 0, 0 );*/
00867    unsigned long bytes = (unsigned long) (end - start) * 4;
00868    boolean done = FALSE;
00869 
00870    stream.offset = 0;
00871    stream.ptr = (char *)start;
00872    stream.print_addresses = 0;
00873    stream.winsys = i915->pipe.winsys;
00874 
00875    if (!start || !end) {
00876       debug_printf( "\n\nBATCH: ???\n");
00877       return;
00878    }
00879    
00880    debug_printf( "\n\nBATCH: (%d)\n", bytes / 4);
00881 
00882    while (!done &&
00883           stream.offset < bytes)
00884    {
00885       if (!i915_debug_packet( &stream ))
00886          break;
00887 
00888       assert(stream.offset <= bytes &&
00889              stream.offset >= 0);
00890    }
00891 
00892    debug_printf( "END-BATCH\n\n\n");
00893 }
00894 
00895 

Generated on Tue Sep 29 06:25:16 2009 for Gallium3D by  doxygen 1.5.4