Path: blob/21.2-virgl/src/gallium/drivers/i915/i915_debug.c
4570 views
/**************************************************************************1*2* Copyright 2003 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include "i915_debug.h"28#include "util/log.h"29#include "util/ralloc.h"30#include "util/u_debug.h"31#include "i915_batch.h"32#include "i915_context.h"33#include "i915_debug_private.h"34#include "i915_reg.h"35#include "i915_screen.h"3637static const struct debug_named_value i915_debug_options[] = {38{"blit", DBG_BLIT, "Print when using the 2d blitter"},39{"emit", DBG_EMIT, "State emit information"},40{"atoms", DBG_ATOMS, "Print dirty state atoms"},41{"flush", DBG_FLUSH, "Flushing information"},42{"texture", DBG_TEXTURE, "Texture information"},43{"constants", DBG_CONSTANTS, "Constant buffers"},44{"fs", DBG_FS, "Dump fragment shaders"},45DEBUG_NAMED_VALUE_END};4647unsigned i915_debug = 0;4849DEBUG_GET_ONCE_FLAGS_OPTION(i915_debug, "I915_DEBUG", i915_debug_options, 0)50DEBUG_GET_ONCE_BOOL_OPTION(i915_no_tiling, "I915_NO_TILING", false)51DEBUG_GET_ONCE_BOOL_OPTION(i915_lie, "I915_LIE", true)52DEBUG_GET_ONCE_BOOL_OPTION(i915_use_blitter, "I915_USE_BLITTER", true)5354void55i915_debug_init(struct i915_screen *is)56{57i915_debug = debug_get_option_i915_debug();58is->debug.tiling = !debug_get_option_i915_no_tiling();59is->debug.lie = debug_get_option_i915_lie();60is->debug.use_blitter = debug_get_option_i915_use_blitter();61}6263/***********************************************************************64* Batchbuffer dumping65*/6667static bool68debug(struct debug_stream *stream, const char *name, unsigned len)69{70unsigned i;71unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);7273if (len == 0) {74mesa_logi("Error - zero length packet (0x%08x)", stream->ptr[0]);75assert(0);76return false;77}7879if (stream->print_addresses)80mesa_logi("%08x: ", stream->offset);8182mesa_logi("%s (%d dwords):", name, len);83for (i = 0; i < len; i++)84mesa_logi("\t0x%08x", ptr[i]);85mesa_logi("%s", "");8687stream->offset += len * sizeof(unsigned);8889return true;90}9192static const char *93get_prim_name(unsigned val)94{95switch (val & PRIM3D_MASK) {96case PRIM3D_TRILIST:97return "TRILIST";98break;99case PRIM3D_TRISTRIP:100return "TRISTRIP";101break;102case PRIM3D_TRISTRIP_RVRSE:103return "TRISTRIP_RVRSE";104break;105case PRIM3D_TRIFAN:106return "TRIFAN";107break;108case PRIM3D_POLY:109return "POLY";110break;111case PRIM3D_LINELIST:112return "LINELIST";113break;114case PRIM3D_LINESTRIP:115return "LINESTRIP";116break;117case PRIM3D_RECTLIST:118return "RECTLIST";119break;120case PRIM3D_POINTLIST:121return "POINTLIST";122break;123case PRIM3D_DIB:124return "DIB";125break;126case PRIM3D_CLEAR_RECT:127return "CLEAR_RECT";128break;129case PRIM3D_ZONE_INIT:130return "ZONE_INIT";131break;132default:133return "????";134break;135}136}137138static bool139debug_prim(struct debug_stream *stream, const char *name, bool dump_floats,140unsigned len)141{142unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);143const char *prim = get_prim_name(ptr[0]);144unsigned i;145146mesa_logi("%s %s (%d dwords):", name, prim, len);147mesa_logi("\t0x%08x", ptr[0]);148for (i = 1; i < len; i++) {149if (dump_floats)150mesa_logi("\t0x%08x // %f", ptr[i], *(float *)&ptr[i]);151else152mesa_logi("\t0x%08x", ptr[i]);153}154155mesa_logi("%s", "");156157stream->offset += len * sizeof(unsigned);158159return true;160}161162static bool163debug_program(struct debug_stream *stream, const char *name, unsigned len)164{165unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);166167if (len == 0) {168mesa_logi("Error - zero length packet (0x%08x)", stream->ptr[0]);169assert(0);170return false;171}172173if (stream->print_addresses)174mesa_logi("%08x: ", stream->offset);175176mesa_logi("%s (%d dwords):", name, len);177i915_disassemble_program(ptr, len);178179stream->offset += len * sizeof(unsigned);180return true;181}182183static bool184debug_chain(struct debug_stream *stream, const char *name, unsigned len)185{186unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);187unsigned old_offset = stream->offset + len * sizeof(unsigned);188unsigned i;189190mesa_logi("%s (%d dwords):", name, len);191for (i = 0; i < len; i++)192mesa_logi("\t0x%08x", ptr[i]);193194stream->offset = ptr[1] & ~0x3;195196if (stream->offset < old_offset)197mesa_logi("... skipping backwards from 0x%x --> 0x%x ...", old_offset,198stream->offset);199else200mesa_logi("... skipping from 0x%x --> 0x%x ...", old_offset,201stream->offset);202203return true;204}205206static bool207debug_variable_length_prim(struct debug_stream *stream)208{209unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);210const char *prim = get_prim_name(ptr[0]);211unsigned i, len;212213ushort *idx = (ushort *)(ptr + 1);214for (i = 0; idx[i] != 0xffff; i++)215;216217len = 1 + (i + 2) / 2;218219mesa_logi("3DPRIM, %s variable length %d indicies (%d dwords):", prim, i,220len);221for (i = 0; i < len; i++)222mesa_logi("\t0x%08x", ptr[i]);223mesa_logi("%s", "");224225stream->offset += len * sizeof(unsigned);226return true;227}228229static void230BITS(struct debug_stream *stream, unsigned dw, unsigned hi, unsigned lo,231const char *fmt, ...)232{233va_list args;234unsigned himask = 0xFFFFFFFFUL >> (31 - (hi));235236va_start(args, fmt);237char *out = ralloc_vasprintf(NULL, fmt, args);238va_end(args);239240mesa_logi("\t\t %s : 0x%x", out, ((dw)&himask) >> (lo));241242ralloc_free(out);243}244245#define MBZ(dw, hi, lo) \246do { \247ASSERTED unsigned x = (dw) >> (lo); \248ASSERTED unsigned lomask = (1 << (lo)) - 1; \249ASSERTED unsigned himask; \250himask = (1UL << (hi)) - 1; \251assert((x & himask & ~lomask) == 0); \252} while (0)253254static void255FLAG(struct debug_stream *stream, unsigned dw, unsigned bit, const char *fmt,256...)257{258if (((dw) >> (bit)) & 1) {259va_list args;260va_start(args, fmt);261char *out = ralloc_vasprintf(NULL, fmt, args);262va_end(args);263264mesa_logi("\t\t %s", out);265266ralloc_free(out);267}268}269270static bool271debug_load_immediate(struct debug_stream *stream, const char *name,272unsigned len)273{274unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);275unsigned bits = (ptr[0] >> 4) & 0xff;276unsigned j = 0;277278mesa_logi("%s (%d dwords, flags: %x):", name, len, bits);279mesa_logi("\t0x%08x", ptr[j++]);280281if (bits & (1 << 0)) {282mesa_logi("\t LIS0: 0x%08x", ptr[j]);283mesa_logi("\t vb address: 0x%08x", (ptr[j] & ~0x3));284BITS(stream, ptr[j], 0, 0, "vb invalidate disable");285j++;286}287if (bits & (1 << 1)) {288mesa_logi("\t LIS1: 0x%08x", ptr[j]);289BITS(stream, ptr[j], 29, 24, "vb dword width");290BITS(stream, ptr[j], 21, 16, "vb dword pitch");291BITS(stream, ptr[j], 15, 0, "vb max index");292j++;293}294if (bits & (1 << 2)) {295int i;296mesa_logi("\t LIS2: 0x%08x", ptr[j]);297for (i = 0; i < 8; i++) {298unsigned tc = (ptr[j] >> (i * 4)) & 0xf;299if (tc != 0xf)300BITS(stream, tc, 3, 0, "tex coord %d", i);301}302j++;303}304if (bits & (1 << 3)) {305mesa_logi("\t LIS3: 0x%08x", ptr[j]);306j++;307}308if (bits & (1 << 4)) {309mesa_logi("\t LIS4: 0x%08x", ptr[j]);310BITS(stream, ptr[j], 31, 23, "point width");311BITS(stream, ptr[j], 22, 19, "line width");312FLAG(stream, ptr[j], 18, "alpha flatshade");313FLAG(stream, ptr[j], 17, "fog flatshade");314FLAG(stream, ptr[j], 16, "spec flatshade");315FLAG(stream, ptr[j], 15, "rgb flatshade");316BITS(stream, ptr[j], 14, 13, "cull mode");317FLAG(stream, ptr[j], 12, "vfmt: point width");318FLAG(stream, ptr[j], 11, "vfmt: specular/fog");319FLAG(stream, ptr[j], 10, "vfmt: rgba");320FLAG(stream, ptr[j], 9, "vfmt: depth offset");321BITS(stream, ptr[j], 8, 6, "vfmt: position (2==xyzw)");322FLAG(stream, ptr[j], 5, "force dflt diffuse");323FLAG(stream, ptr[j], 4, "force dflt specular");324FLAG(stream, ptr[j], 3, "local depth offset enable");325FLAG(stream, ptr[j], 2, "vfmt: fp32 fog coord");326FLAG(stream, ptr[j], 1, "sprite point");327FLAG(stream, ptr[j], 0, "antialiasing");328j++;329}330if (bits & (1 << 5)) {331mesa_logi("\t LIS5: 0x%08x", ptr[j]);332BITS(stream, ptr[j], 31, 28, "rgba write disables");333FLAG(stream, ptr[j], 27, "force dflt point width");334FLAG(stream, ptr[j], 26, "last pixel enable");335FLAG(stream, ptr[j], 25, "global z offset enable");336FLAG(stream, ptr[j], 24, "fog enable");337BITS(stream, ptr[j], 23, 16, "stencil ref");338BITS(stream, ptr[j], 15, 13, "stencil test");339BITS(stream, ptr[j], 12, 10, "stencil fail op");340BITS(stream, ptr[j], 9, 7, "stencil pass z fail op");341BITS(stream, ptr[j], 6, 4, "stencil pass z pass op");342FLAG(stream, ptr[j], 3, "stencil write enable");343FLAG(stream, ptr[j], 2, "stencil test enable");344FLAG(stream, ptr[j], 1, "color dither enable");345FLAG(stream, ptr[j], 0, "logiop enable");346j++;347}348if (bits & (1 << 6)) {349mesa_logi("\t LIS6: 0x%08x", ptr[j]);350FLAG(stream, ptr[j], 31, "alpha test enable");351BITS(stream, ptr[j], 30, 28, "alpha func");352BITS(stream, ptr[j], 27, 20, "alpha ref");353FLAG(stream, ptr[j], 19, "depth test enable");354BITS(stream, ptr[j], 18, 16, "depth func");355FLAG(stream, ptr[j], 15, "blend enable");356BITS(stream, ptr[j], 14, 12, "blend func");357BITS(stream, ptr[j], 11, 8, "blend src factor");358BITS(stream, ptr[j], 7, 4, "blend dst factor");359FLAG(stream, ptr[j], 3, "depth write enable");360FLAG(stream, ptr[j], 2, "color write enable");361BITS(stream, ptr[j], 1, 0, "provoking vertex");362j++;363}364365mesa_logi("%s", "");366367assert(j == len);368369stream->offset += len * sizeof(unsigned);370371return true;372}373374static bool375debug_load_indirect(struct debug_stream *stream, const char *name, unsigned len)376{377unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);378unsigned bits = (ptr[0] >> 8) & 0x3f;379unsigned i, j = 0;380381mesa_logi("%s (%d dwords):", name, len);382mesa_logi("\t0x%08x", ptr[j++]);383384for (i = 0; i < 6; i++) {385if (bits & (1 << i)) {386switch (1 << (8 + i)) {387case LI0_STATE_STATIC_INDIRECT:388mesa_logi(" STATIC: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);389j++;390mesa_logi(" 0x%08x", ptr[j++]);391break;392case LI0_STATE_DYNAMIC_INDIRECT:393mesa_logi(" DYNAMIC: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);394j++;395break;396case LI0_STATE_SAMPLER:397mesa_logi(" SAMPLER: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);398j++;399mesa_logi(" 0x%08x", ptr[j++]);400break;401case LI0_STATE_MAP:402mesa_logi(" MAP: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);403j++;404mesa_logi(" 0x%08x", ptr[j++]);405break;406case LI0_STATE_PROGRAM:407mesa_logi(" PROGRAM: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);408j++;409mesa_logi(" 0x%08x", ptr[j++]);410break;411case LI0_STATE_CONSTANTS:412mesa_logi(" CONSTANTS: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);413j++;414mesa_logi(" 0x%08x", ptr[j++]);415break;416default:417assert(0);418break;419}420}421}422423if (bits == 0) {424mesa_logi("\t DUMMY: 0x%08x", ptr[j++]);425}426427mesa_logi("%s", "");428429assert(j == len);430431stream->offset += len * sizeof(unsigned);432433return true;434}435436static void437BR13(struct debug_stream *stream, unsigned val)438{439mesa_logi("\t0x%08x", val);440FLAG(stream, val, 30, "clipping enable");441BITS(stream, val, 25, 24, "color depth (3==32bpp)");442BITS(stream, val, 23, 16, "raster op");443BITS(stream, val, 15, 0, "dest pitch");444}445446static void447BR22(struct debug_stream *stream, unsigned val)448{449mesa_logi("\t0x%08x", val);450BITS(stream, val, 31, 16, "dest y1");451BITS(stream, val, 15, 0, "dest x1");452}453454static void455BR23(struct debug_stream *stream, unsigned val)456{457mesa_logi("\t0x%08x", val);458BITS(stream, val, 31, 16, "dest y2");459BITS(stream, val, 15, 0, "dest x2");460}461462static void463BR09(struct debug_stream *stream, unsigned val)464{465mesa_logi("\t0x%08x -- dest address", val);466}467468static void469BR26(struct debug_stream *stream, unsigned val)470{471mesa_logi("\t0x%08x", val);472BITS(stream, val, 31, 16, "src y1");473BITS(stream, val, 15, 0, "src x1");474}475476static void477BR11(struct debug_stream *stream, unsigned val)478{479mesa_logi("\t0x%08x", val);480BITS(stream, val, 15, 0, "src pitch");481}482483static void484BR12(struct debug_stream *stream, unsigned val)485{486mesa_logi("\t0x%08x -- src address", val);487}488489static void490BR16(struct debug_stream *stream, unsigned val)491{492mesa_logi("\t0x%08x -- color", val);493}494495static bool496debug_copy_blit(struct debug_stream *stream, const char *name, unsigned len)497{498unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);499int j = 0;500501mesa_logi("%s (%d dwords):", name, len);502mesa_logi("\t0x%08x", ptr[j++]);503504BR13(stream, ptr[j++]);505BR22(stream, ptr[j++]);506BR23(stream, ptr[j++]);507BR09(stream, ptr[j++]);508BR26(stream, ptr[j++]);509BR11(stream, ptr[j++]);510BR12(stream, ptr[j++]);511512stream->offset += len * sizeof(unsigned);513assert(j == len);514return true;515}516517static bool518debug_color_blit(struct debug_stream *stream, const char *name, unsigned len)519{520unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);521int j = 0;522523mesa_logi("%s (%d dwords):", name, len);524mesa_logi("\t0x%08x", ptr[j++]);525526BR13(stream, ptr[j++]);527BR22(stream, ptr[j++]);528BR23(stream, ptr[j++]);529BR09(stream, ptr[j++]);530BR16(stream, ptr[j++]);531532stream->offset += len * sizeof(unsigned);533assert(j == len);534return true;535}536537static bool538debug_modes4(struct debug_stream *stream, const char *name, unsigned len)539{540unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);541int j = 0;542543mesa_logi("%s (%d dwords):", name, len);544mesa_logi("\t0x%08x", ptr[j]);545BITS(stream, ptr[j], 21, 18, "logicop func");546FLAG(stream, ptr[j], 17, "stencil test mask modify-enable");547FLAG(stream, ptr[j], 16, "stencil write mask modify-enable");548BITS(stream, ptr[j], 15, 8, "stencil test mask");549BITS(stream, ptr[j], 7, 0, "stencil write mask");550j++;551552stream->offset += len * sizeof(unsigned);553assert(j == len);554return true;555}556557static bool558debug_map_state(struct debug_stream *stream, const char *name, unsigned len)559{560unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);561unsigned j = 0;562563mesa_logi("%s (%d dwords):", name, len);564mesa_logi("\t0x%08x", ptr[j++]);565566{567mesa_logi("\t0x%08x", ptr[j]);568BITS(stream, ptr[j], 15, 0, "map mask");569j++;570}571572while (j < len) {573{574mesa_logi("\t TMn.0: 0x%08x", ptr[j]);575mesa_logi("\t map address: 0x%08x", (ptr[j] & ~0x3));576FLAG(stream, ptr[j], 1, "vertical line stride");577FLAG(stream, ptr[j], 0, "vertical line stride offset");578j++;579}580581{582mesa_logi("\t TMn.1: 0x%08x", ptr[j]);583BITS(stream, ptr[j], 31, 21, "height");584BITS(stream, ptr[j], 20, 10, "width");585BITS(stream, ptr[j], 9, 7, "surface format");586BITS(stream, ptr[j], 6, 3, "texel format");587FLAG(stream, ptr[j], 2, "use fence regs");588FLAG(stream, ptr[j], 1, "tiled surface");589FLAG(stream, ptr[j], 0, "tile walk ymajor");590j++;591}592{593mesa_logi("\t TMn.2: 0x%08x", ptr[j]);594BITS(stream, ptr[j], 31, 21, "dword pitch");595BITS(stream, ptr[j], 20, 15, "cube face enables");596BITS(stream, ptr[j], 14, 9, "max lod");597FLAG(stream, ptr[j], 8, "mip layout right");598BITS(stream, ptr[j], 7, 0, "depth");599j++;600}601}602603stream->offset += len * sizeof(unsigned);604assert(j == len);605return true;606}607608static bool609debug_sampler_state(struct debug_stream *stream, const char *name, unsigned len)610{611unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);612unsigned j = 0;613614mesa_logi("%s (%d dwords):", name, len);615mesa_logi("\t0x%08x", ptr[j++]);616617{618mesa_logi("\t0x%08x", ptr[j]);619BITS(stream, ptr[j], 15, 0, "sampler mask");620j++;621}622623while (j < len) {624{625mesa_logi("\t TSn.0: 0x%08x", ptr[j]);626FLAG(stream, ptr[j], 31, "reverse gamma");627FLAG(stream, ptr[j], 30, "planar to packed");628FLAG(stream, ptr[j], 29, "yuv->rgb");629BITS(stream, ptr[j], 28, 27, "chromakey index");630BITS(stream, ptr[j], 26, 22, "base mip level");631BITS(stream, ptr[j], 21, 20, "mip mode filter");632BITS(stream, ptr[j], 19, 17, "mag mode filter");633BITS(stream, ptr[j], 16, 14, "min mode filter");634BITS(stream, ptr[j], 13, 5, "lod bias (s4.4)");635FLAG(stream, ptr[j], 4, "shadow enable");636FLAG(stream, ptr[j], 3, "max-aniso-4");637BITS(stream, ptr[j], 2, 0, "shadow func");638j++;639}640641{642mesa_logi("\t TSn.1: 0x%08x", ptr[j]);643BITS(stream, ptr[j], 31, 24, "min lod");644MBZ(ptr[j], 23, 18);645FLAG(stream, ptr[j], 17, "kill pixel enable");646FLAG(stream, ptr[j], 16, "keyed tex filter mode");647FLAG(stream, ptr[j], 15, "chromakey enable");648BITS(stream, ptr[j], 14, 12, "tcx wrap mode");649BITS(stream, ptr[j], 11, 9, "tcy wrap mode");650BITS(stream, ptr[j], 8, 6, "tcz wrap mode");651FLAG(stream, ptr[j], 5, "normalized coords");652BITS(stream, ptr[j], 4, 1, "map (surface) index");653FLAG(stream, ptr[j], 0, "EAST deinterlacer enable");654j++;655}656{657mesa_logi("\t TSn.2: 0x%08x (default color)", ptr[j]);658j++;659}660}661662stream->offset += len * sizeof(unsigned);663assert(j == len);664return true;665}666667static bool668debug_dest_vars(struct debug_stream *stream, const char *name, unsigned len)669{670unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);671int j = 0;672673mesa_logi("%s (%d dwords):", name, len);674mesa_logi("\t0x%08x", ptr[j++]);675676{677mesa_logi("\t0x%08x", ptr[j]);678FLAG(stream, ptr[j], 31, "early classic ztest");679FLAG(stream, ptr[j], 30, "opengl tex default color");680FLAG(stream, ptr[j], 29, "bypass iz");681FLAG(stream, ptr[j], 28, "lod preclamp");682BITS(stream, ptr[j], 27, 26, "dither pattern");683FLAG(stream, ptr[j], 25, "linear gamma blend");684FLAG(stream, ptr[j], 24, "debug dither");685BITS(stream, ptr[j], 23, 20, "dstorg x");686BITS(stream, ptr[j], 19, 16, "dstorg y");687MBZ(ptr[j], 15, 15);688BITS(stream, ptr[j], 14, 12, "422 write select");689BITS(stream, ptr[j], 11, 8, "cbuf format");690BITS(stream, ptr[j], 3, 2, "zbuf format");691FLAG(stream, ptr[j], 1, "vert line stride");692FLAG(stream, ptr[j], 1, "vert line stride offset");693j++;694}695696stream->offset += len * sizeof(unsigned);697assert(j == len);698return true;699}700701static bool702debug_buf_info(struct debug_stream *stream, const char *name, unsigned len)703{704unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);705int j = 0;706707mesa_logi("%s (%d dwords):", name, len);708mesa_logi("\t0x%08x", ptr[j++]);709710{711mesa_logi("\t0x%08x", ptr[j]);712BITS(stream, ptr[j], 28, 28, "aux buffer id");713BITS(stream, ptr[j], 27, 24, "buffer id (7=depth, 3=back)");714FLAG(stream, ptr[j], 23, "use fence regs");715FLAG(stream, ptr[j], 22, "tiled surface");716FLAG(stream, ptr[j], 21, "tile walk ymajor");717MBZ(ptr[j], 20, 14);718BITS(stream, ptr[j], 13, 2, "dword pitch");719MBZ(ptr[j], 2, 0);720j++;721}722723mesa_logi("\t0x%08x -- buffer base address", ptr[j++]);724725stream->offset += len * sizeof(unsigned);726assert(j == len);727return true;728}729730static bool731i915_debug_packet(struct debug_stream *stream)732{733unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);734unsigned cmd = *ptr;735736switch (((cmd >> 29) & 0x7)) {737case 0x0:738switch ((cmd >> 23) & 0x3f) {739case 0x0:740return debug(stream, "MI_NOOP", 1);741case 0x3:742return debug(stream, "MI_WAIT_FOR_EVENT", 1);743case 0x4:744return debug(stream, "MI_FLUSH", 1);745case 0xA:746debug(stream, "MI_BATCH_BUFFER_END", 1);747return false;748case 0x22:749return debug(stream, "MI_LOAD_REGISTER_IMM", 3);750case 0x31:751return debug_chain(stream, "MI_BATCH_BUFFER_START", 2);752default:753(void)debug(stream, "UNKNOWN 0x0 case!", 1);754assert(0);755break;756}757break;758case 0x1:759(void)debug(stream, "UNKNOWN 0x1 case!", 1);760assert(0);761break;762case 0x2:763switch ((cmd >> 22) & 0xff) {764case 0x50:765return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2);766case 0x53:767return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2);768default:769return debug(stream, "blit command", (cmd & 0xff) + 2);770}771break;772case 0x3:773switch ((cmd >> 24) & 0x1f) {774case 0x6:775return debug(stream, "3DSTATE_ANTI_ALIASING", 1);776case 0x7:777return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1);778case 0x8:779return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 1);780case 0x9:781return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);782case 0xb:783return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);784case 0xc:785return debug(stream, "3DSTATE_MODES5", 1);786case 0xd:787return debug_modes4(stream, "3DSTATE_MODES4", 1);788case 0x15:789return debug(stream, "3DSTATE_FOG_COLOR", 1);790case 0x16:791return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1);792case 0x1c:793/* 3DState16NP */794switch ((cmd >> 19) & 0x1f) {795case 0x10:796return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1);797case 0x11:798return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);799default:800(void)debug(stream, "UNKNOWN 0x1c case!", 1);801assert(0);802break;803}804break;805case 0x1d:806/* 3DStateMW */807switch ((cmd >> 16) & 0xff) {808case 0x0:809return debug_map_state(stream, "3DSTATE_MAP_STATE",810(cmd & 0x1f) + 2);811case 0x1:812return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE",813(cmd & 0x1f) + 2);814case 0x4:815return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE",816(cmd & 0xf) + 2);817case 0x5:818return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM",819(cmd & 0x1ff) + 2);820case 0x6:821return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS",822(cmd & 0xff) + 2);823case 0x7:824return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT",825(cmd & 0xff) + 2);826case 0x80:827return debug(stream, "3DSTATE_DRAWING_RECTANGLE",828(cmd & 0xffff) + 2);829case 0x81:830return debug(stream, "3DSTATE_SCISSOR_RECTANGLE",831(cmd & 0xffff) + 2);832case 0x83:833return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2);834case 0x85:835return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS",836(cmd & 0xffff) + 2);837case 0x88:838return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR",839(cmd & 0xffff) + 2);840case 0x89:841return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2);842case 0x8e:843return debug_buf_info(stream, "3DSTATE_BUFFER_INFO",844(cmd & 0xffff) + 2);845case 0x97:846return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE",847(cmd & 0xffff) + 2);848case 0x98:849return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2);850case 0x99:851return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2);852case 0x9a:853return debug(stream, "3DSTATE_DEFAULT_SPECULAR",854(cmd & 0xffff) + 2);855case 0x9c:856return debug(stream, "3DSTATE_CLEAR_PARAMETERS",857(cmd & 0xffff) + 2);858default:859assert(0);860return 0;861}862break;863case 0x1e:864if (cmd & (1 << 23))865return debug(stream, "???", (cmd & 0xffff) + 1);866else867return debug(stream, "", 1);868break;869case 0x1f:870if ((cmd & (1 << 23)) == 0)871return debug_prim(stream, "3DPRIM (inline)", 1,872(cmd & 0x1ffff) + 2);873else if (cmd & (1 << 17)) {874if ((cmd & 0xffff) == 0)875return debug_variable_length_prim(stream);876else877return debug_prim(stream, "3DPRIM (indexed)", 0,878(((cmd & 0xffff) + 1) / 2) + 1);879} else880return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2);881break;882default:883return debug(stream, "", 0);884}885break;886default:887assert(0);888return 0;889}890891assert(0);892return 0;893}894895void896i915_dump_batchbuffer(struct i915_winsys_batchbuffer *batch)897{898struct debug_stream stream;899unsigned *start = (unsigned *)batch->map;900unsigned *end = (unsigned *)batch->ptr;901unsigned long bytes = (unsigned long)(end - start) * 4;902bool done = false;903904stream.offset = 0;905stream.ptr = (char *)start;906stream.print_addresses = 0;907908if (!start || !end) {909mesa_logi("BATCH: ???");910return;911}912913mesa_logi("BATCH: (%d)", (int)bytes / 4);914915while (!done && stream.offset < bytes) {916if (!i915_debug_packet(&stream))917break;918919assert(stream.offset <= bytes);920}921922mesa_logi("END-BATCH");923}924925/***********************************************************************926* Dirty state atom dumping927*/928929void930i915_dump_dirty(struct i915_context *i915, const char *func)931{932struct {933unsigned dirty;934const char *name;935} l[] = {936{I915_NEW_VIEWPORT, "viewport"},937{I915_NEW_RASTERIZER, "rasterizer"},938{I915_NEW_FS, "fs"},939{I915_NEW_BLEND, "blend"},940{I915_NEW_CLIP, "clip"},941{I915_NEW_SCISSOR, "scissor"},942{I915_NEW_STIPPLE, "stipple"},943{I915_NEW_FRAMEBUFFER, "framebuffer"},944{I915_NEW_ALPHA_TEST, "alpha_test"},945{I915_NEW_DEPTH_STENCIL, "depth_stencil"},946{I915_NEW_SAMPLER, "sampler"},947{I915_NEW_SAMPLER_VIEW, "sampler_view"},948{I915_NEW_VS_CONSTANTS, "vs_const"},949{I915_NEW_FS_CONSTANTS, "fs_const"},950{I915_NEW_VBO, "vbo"},951{I915_NEW_VS, "vs"},952{0, NULL},953};954int i;955956mesa_logi("%s: ", func);957for (i = 0; l[i].name; i++)958if (i915->dirty & l[i].dirty)959mesa_logi("%s ", l[i].name);960mesa_logi("%s", "");961}962963void964i915_dump_hardware_dirty(struct i915_context *i915, const char *func)965{966struct {967unsigned dirty;968const char *name;969} l[] = {970{I915_HW_STATIC, "static"},971{I915_HW_DYNAMIC, "dynamic"},972{I915_HW_SAMPLER, "sampler"},973{I915_HW_MAP, "map"},974{I915_HW_PROGRAM, "program"},975{I915_HW_CONSTANTS, "constants"},976{I915_HW_IMMEDIATE, "immediate"},977{I915_HW_INVARIANT, "invariant"},978{0, NULL},979};980int i;981982mesa_logi("%s: ", func);983for (i = 0; l[i].name; i++)984if (i915->hardware_dirty & l[i].dirty)985mesa_logi("%s ", l[i].name);986mesa_logi("%s", "");987}988989990