Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/i915/i915_debug.c
4570 views
1
/**************************************************************************
2
*
3
* Copyright 2003 VMware, Inc.
4
* All Rights Reserved.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the
8
* "Software"), to deal in the Software without restriction, including
9
* without limitation the rights to use, copy, modify, merge, publish,
10
* distribute, sub license, and/or sell copies of the Software, and to
11
* permit persons to whom the Software is furnished to do so, subject to
12
* the following conditions:
13
*
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
16
* of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
*
26
**************************************************************************/
27
28
#include "i915_debug.h"
29
#include "util/log.h"
30
#include "util/ralloc.h"
31
#include "util/u_debug.h"
32
#include "i915_batch.h"
33
#include "i915_context.h"
34
#include "i915_debug_private.h"
35
#include "i915_reg.h"
36
#include "i915_screen.h"
37
38
static const struct debug_named_value i915_debug_options[] = {
39
{"blit", DBG_BLIT, "Print when using the 2d blitter"},
40
{"emit", DBG_EMIT, "State emit information"},
41
{"atoms", DBG_ATOMS, "Print dirty state atoms"},
42
{"flush", DBG_FLUSH, "Flushing information"},
43
{"texture", DBG_TEXTURE, "Texture information"},
44
{"constants", DBG_CONSTANTS, "Constant buffers"},
45
{"fs", DBG_FS, "Dump fragment shaders"},
46
DEBUG_NAMED_VALUE_END};
47
48
unsigned i915_debug = 0;
49
50
DEBUG_GET_ONCE_FLAGS_OPTION(i915_debug, "I915_DEBUG", i915_debug_options, 0)
51
DEBUG_GET_ONCE_BOOL_OPTION(i915_no_tiling, "I915_NO_TILING", false)
52
DEBUG_GET_ONCE_BOOL_OPTION(i915_lie, "I915_LIE", true)
53
DEBUG_GET_ONCE_BOOL_OPTION(i915_use_blitter, "I915_USE_BLITTER", true)
54
55
void
56
i915_debug_init(struct i915_screen *is)
57
{
58
i915_debug = debug_get_option_i915_debug();
59
is->debug.tiling = !debug_get_option_i915_no_tiling();
60
is->debug.lie = debug_get_option_i915_lie();
61
is->debug.use_blitter = debug_get_option_i915_use_blitter();
62
}
63
64
/***********************************************************************
65
* Batchbuffer dumping
66
*/
67
68
static bool
69
debug(struct debug_stream *stream, const char *name, unsigned len)
70
{
71
unsigned i;
72
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
73
74
if (len == 0) {
75
mesa_logi("Error - zero length packet (0x%08x)", stream->ptr[0]);
76
assert(0);
77
return false;
78
}
79
80
if (stream->print_addresses)
81
mesa_logi("%08x: ", stream->offset);
82
83
mesa_logi("%s (%d dwords):", name, len);
84
for (i = 0; i < len; i++)
85
mesa_logi("\t0x%08x", ptr[i]);
86
mesa_logi("%s", "");
87
88
stream->offset += len * sizeof(unsigned);
89
90
return true;
91
}
92
93
static const char *
94
get_prim_name(unsigned val)
95
{
96
switch (val & PRIM3D_MASK) {
97
case PRIM3D_TRILIST:
98
return "TRILIST";
99
break;
100
case PRIM3D_TRISTRIP:
101
return "TRISTRIP";
102
break;
103
case PRIM3D_TRISTRIP_RVRSE:
104
return "TRISTRIP_RVRSE";
105
break;
106
case PRIM3D_TRIFAN:
107
return "TRIFAN";
108
break;
109
case PRIM3D_POLY:
110
return "POLY";
111
break;
112
case PRIM3D_LINELIST:
113
return "LINELIST";
114
break;
115
case PRIM3D_LINESTRIP:
116
return "LINESTRIP";
117
break;
118
case PRIM3D_RECTLIST:
119
return "RECTLIST";
120
break;
121
case PRIM3D_POINTLIST:
122
return "POINTLIST";
123
break;
124
case PRIM3D_DIB:
125
return "DIB";
126
break;
127
case PRIM3D_CLEAR_RECT:
128
return "CLEAR_RECT";
129
break;
130
case PRIM3D_ZONE_INIT:
131
return "ZONE_INIT";
132
break;
133
default:
134
return "????";
135
break;
136
}
137
}
138
139
static bool
140
debug_prim(struct debug_stream *stream, const char *name, bool dump_floats,
141
unsigned len)
142
{
143
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
144
const char *prim = get_prim_name(ptr[0]);
145
unsigned i;
146
147
mesa_logi("%s %s (%d dwords):", name, prim, len);
148
mesa_logi("\t0x%08x", ptr[0]);
149
for (i = 1; i < len; i++) {
150
if (dump_floats)
151
mesa_logi("\t0x%08x // %f", ptr[i], *(float *)&ptr[i]);
152
else
153
mesa_logi("\t0x%08x", ptr[i]);
154
}
155
156
mesa_logi("%s", "");
157
158
stream->offset += len * sizeof(unsigned);
159
160
return true;
161
}
162
163
static bool
164
debug_program(struct debug_stream *stream, const char *name, unsigned len)
165
{
166
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
167
168
if (len == 0) {
169
mesa_logi("Error - zero length packet (0x%08x)", stream->ptr[0]);
170
assert(0);
171
return false;
172
}
173
174
if (stream->print_addresses)
175
mesa_logi("%08x: ", stream->offset);
176
177
mesa_logi("%s (%d dwords):", name, len);
178
i915_disassemble_program(ptr, len);
179
180
stream->offset += len * sizeof(unsigned);
181
return true;
182
}
183
184
static bool
185
debug_chain(struct debug_stream *stream, const char *name, unsigned len)
186
{
187
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
188
unsigned old_offset = stream->offset + len * sizeof(unsigned);
189
unsigned i;
190
191
mesa_logi("%s (%d dwords):", name, len);
192
for (i = 0; i < len; i++)
193
mesa_logi("\t0x%08x", ptr[i]);
194
195
stream->offset = ptr[1] & ~0x3;
196
197
if (stream->offset < old_offset)
198
mesa_logi("... skipping backwards from 0x%x --> 0x%x ...", old_offset,
199
stream->offset);
200
else
201
mesa_logi("... skipping from 0x%x --> 0x%x ...", old_offset,
202
stream->offset);
203
204
return true;
205
}
206
207
static bool
208
debug_variable_length_prim(struct debug_stream *stream)
209
{
210
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
211
const char *prim = get_prim_name(ptr[0]);
212
unsigned i, len;
213
214
ushort *idx = (ushort *)(ptr + 1);
215
for (i = 0; idx[i] != 0xffff; i++)
216
;
217
218
len = 1 + (i + 2) / 2;
219
220
mesa_logi("3DPRIM, %s variable length %d indicies (%d dwords):", prim, i,
221
len);
222
for (i = 0; i < len; i++)
223
mesa_logi("\t0x%08x", ptr[i]);
224
mesa_logi("%s", "");
225
226
stream->offset += len * sizeof(unsigned);
227
return true;
228
}
229
230
static void
231
BITS(struct debug_stream *stream, unsigned dw, unsigned hi, unsigned lo,
232
const char *fmt, ...)
233
{
234
va_list args;
235
unsigned himask = 0xFFFFFFFFUL >> (31 - (hi));
236
237
va_start(args, fmt);
238
char *out = ralloc_vasprintf(NULL, fmt, args);
239
va_end(args);
240
241
mesa_logi("\t\t %s : 0x%x", out, ((dw)&himask) >> (lo));
242
243
ralloc_free(out);
244
}
245
246
#define MBZ(dw, hi, lo) \
247
do { \
248
ASSERTED unsigned x = (dw) >> (lo); \
249
ASSERTED unsigned lomask = (1 << (lo)) - 1; \
250
ASSERTED unsigned himask; \
251
himask = (1UL << (hi)) - 1; \
252
assert((x & himask & ~lomask) == 0); \
253
} while (0)
254
255
static void
256
FLAG(struct debug_stream *stream, unsigned dw, unsigned bit, const char *fmt,
257
...)
258
{
259
if (((dw) >> (bit)) & 1) {
260
va_list args;
261
va_start(args, fmt);
262
char *out = ralloc_vasprintf(NULL, fmt, args);
263
va_end(args);
264
265
mesa_logi("\t\t %s", out);
266
267
ralloc_free(out);
268
}
269
}
270
271
static bool
272
debug_load_immediate(struct debug_stream *stream, const char *name,
273
unsigned len)
274
{
275
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
276
unsigned bits = (ptr[0] >> 4) & 0xff;
277
unsigned j = 0;
278
279
mesa_logi("%s (%d dwords, flags: %x):", name, len, bits);
280
mesa_logi("\t0x%08x", ptr[j++]);
281
282
if (bits & (1 << 0)) {
283
mesa_logi("\t LIS0: 0x%08x", ptr[j]);
284
mesa_logi("\t vb address: 0x%08x", (ptr[j] & ~0x3));
285
BITS(stream, ptr[j], 0, 0, "vb invalidate disable");
286
j++;
287
}
288
if (bits & (1 << 1)) {
289
mesa_logi("\t LIS1: 0x%08x", ptr[j]);
290
BITS(stream, ptr[j], 29, 24, "vb dword width");
291
BITS(stream, ptr[j], 21, 16, "vb dword pitch");
292
BITS(stream, ptr[j], 15, 0, "vb max index");
293
j++;
294
}
295
if (bits & (1 << 2)) {
296
int i;
297
mesa_logi("\t LIS2: 0x%08x", ptr[j]);
298
for (i = 0; i < 8; i++) {
299
unsigned tc = (ptr[j] >> (i * 4)) & 0xf;
300
if (tc != 0xf)
301
BITS(stream, tc, 3, 0, "tex coord %d", i);
302
}
303
j++;
304
}
305
if (bits & (1 << 3)) {
306
mesa_logi("\t LIS3: 0x%08x", ptr[j]);
307
j++;
308
}
309
if (bits & (1 << 4)) {
310
mesa_logi("\t LIS4: 0x%08x", ptr[j]);
311
BITS(stream, ptr[j], 31, 23, "point width");
312
BITS(stream, ptr[j], 22, 19, "line width");
313
FLAG(stream, ptr[j], 18, "alpha flatshade");
314
FLAG(stream, ptr[j], 17, "fog flatshade");
315
FLAG(stream, ptr[j], 16, "spec flatshade");
316
FLAG(stream, ptr[j], 15, "rgb flatshade");
317
BITS(stream, ptr[j], 14, 13, "cull mode");
318
FLAG(stream, ptr[j], 12, "vfmt: point width");
319
FLAG(stream, ptr[j], 11, "vfmt: specular/fog");
320
FLAG(stream, ptr[j], 10, "vfmt: rgba");
321
FLAG(stream, ptr[j], 9, "vfmt: depth offset");
322
BITS(stream, ptr[j], 8, 6, "vfmt: position (2==xyzw)");
323
FLAG(stream, ptr[j], 5, "force dflt diffuse");
324
FLAG(stream, ptr[j], 4, "force dflt specular");
325
FLAG(stream, ptr[j], 3, "local depth offset enable");
326
FLAG(stream, ptr[j], 2, "vfmt: fp32 fog coord");
327
FLAG(stream, ptr[j], 1, "sprite point");
328
FLAG(stream, ptr[j], 0, "antialiasing");
329
j++;
330
}
331
if (bits & (1 << 5)) {
332
mesa_logi("\t LIS5: 0x%08x", ptr[j]);
333
BITS(stream, ptr[j], 31, 28, "rgba write disables");
334
FLAG(stream, ptr[j], 27, "force dflt point width");
335
FLAG(stream, ptr[j], 26, "last pixel enable");
336
FLAG(stream, ptr[j], 25, "global z offset enable");
337
FLAG(stream, ptr[j], 24, "fog enable");
338
BITS(stream, ptr[j], 23, 16, "stencil ref");
339
BITS(stream, ptr[j], 15, 13, "stencil test");
340
BITS(stream, ptr[j], 12, 10, "stencil fail op");
341
BITS(stream, ptr[j], 9, 7, "stencil pass z fail op");
342
BITS(stream, ptr[j], 6, 4, "stencil pass z pass op");
343
FLAG(stream, ptr[j], 3, "stencil write enable");
344
FLAG(stream, ptr[j], 2, "stencil test enable");
345
FLAG(stream, ptr[j], 1, "color dither enable");
346
FLAG(stream, ptr[j], 0, "logiop enable");
347
j++;
348
}
349
if (bits & (1 << 6)) {
350
mesa_logi("\t LIS6: 0x%08x", ptr[j]);
351
FLAG(stream, ptr[j], 31, "alpha test enable");
352
BITS(stream, ptr[j], 30, 28, "alpha func");
353
BITS(stream, ptr[j], 27, 20, "alpha ref");
354
FLAG(stream, ptr[j], 19, "depth test enable");
355
BITS(stream, ptr[j], 18, 16, "depth func");
356
FLAG(stream, ptr[j], 15, "blend enable");
357
BITS(stream, ptr[j], 14, 12, "blend func");
358
BITS(stream, ptr[j], 11, 8, "blend src factor");
359
BITS(stream, ptr[j], 7, 4, "blend dst factor");
360
FLAG(stream, ptr[j], 3, "depth write enable");
361
FLAG(stream, ptr[j], 2, "color write enable");
362
BITS(stream, ptr[j], 1, 0, "provoking vertex");
363
j++;
364
}
365
366
mesa_logi("%s", "");
367
368
assert(j == len);
369
370
stream->offset += len * sizeof(unsigned);
371
372
return true;
373
}
374
375
static bool
376
debug_load_indirect(struct debug_stream *stream, const char *name, unsigned len)
377
{
378
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
379
unsigned bits = (ptr[0] >> 8) & 0x3f;
380
unsigned i, j = 0;
381
382
mesa_logi("%s (%d dwords):", name, len);
383
mesa_logi("\t0x%08x", ptr[j++]);
384
385
for (i = 0; i < 6; i++) {
386
if (bits & (1 << i)) {
387
switch (1 << (8 + i)) {
388
case LI0_STATE_STATIC_INDIRECT:
389
mesa_logi(" STATIC: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
390
j++;
391
mesa_logi(" 0x%08x", ptr[j++]);
392
break;
393
case LI0_STATE_DYNAMIC_INDIRECT:
394
mesa_logi(" DYNAMIC: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
395
j++;
396
break;
397
case LI0_STATE_SAMPLER:
398
mesa_logi(" SAMPLER: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
399
j++;
400
mesa_logi(" 0x%08x", ptr[j++]);
401
break;
402
case LI0_STATE_MAP:
403
mesa_logi(" MAP: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
404
j++;
405
mesa_logi(" 0x%08x", ptr[j++]);
406
break;
407
case LI0_STATE_PROGRAM:
408
mesa_logi(" PROGRAM: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
409
j++;
410
mesa_logi(" 0x%08x", ptr[j++]);
411
break;
412
case LI0_STATE_CONSTANTS:
413
mesa_logi(" CONSTANTS: 0x%08x | %x", ptr[j] & ~3, ptr[j] & 3);
414
j++;
415
mesa_logi(" 0x%08x", ptr[j++]);
416
break;
417
default:
418
assert(0);
419
break;
420
}
421
}
422
}
423
424
if (bits == 0) {
425
mesa_logi("\t DUMMY: 0x%08x", ptr[j++]);
426
}
427
428
mesa_logi("%s", "");
429
430
assert(j == len);
431
432
stream->offset += len * sizeof(unsigned);
433
434
return true;
435
}
436
437
static void
438
BR13(struct debug_stream *stream, unsigned val)
439
{
440
mesa_logi("\t0x%08x", val);
441
FLAG(stream, val, 30, "clipping enable");
442
BITS(stream, val, 25, 24, "color depth (3==32bpp)");
443
BITS(stream, val, 23, 16, "raster op");
444
BITS(stream, val, 15, 0, "dest pitch");
445
}
446
447
static void
448
BR22(struct debug_stream *stream, unsigned val)
449
{
450
mesa_logi("\t0x%08x", val);
451
BITS(stream, val, 31, 16, "dest y1");
452
BITS(stream, val, 15, 0, "dest x1");
453
}
454
455
static void
456
BR23(struct debug_stream *stream, unsigned val)
457
{
458
mesa_logi("\t0x%08x", val);
459
BITS(stream, val, 31, 16, "dest y2");
460
BITS(stream, val, 15, 0, "dest x2");
461
}
462
463
static void
464
BR09(struct debug_stream *stream, unsigned val)
465
{
466
mesa_logi("\t0x%08x -- dest address", val);
467
}
468
469
static void
470
BR26(struct debug_stream *stream, unsigned val)
471
{
472
mesa_logi("\t0x%08x", val);
473
BITS(stream, val, 31, 16, "src y1");
474
BITS(stream, val, 15, 0, "src x1");
475
}
476
477
static void
478
BR11(struct debug_stream *stream, unsigned val)
479
{
480
mesa_logi("\t0x%08x", val);
481
BITS(stream, val, 15, 0, "src pitch");
482
}
483
484
static void
485
BR12(struct debug_stream *stream, unsigned val)
486
{
487
mesa_logi("\t0x%08x -- src address", val);
488
}
489
490
static void
491
BR16(struct debug_stream *stream, unsigned val)
492
{
493
mesa_logi("\t0x%08x -- color", val);
494
}
495
496
static bool
497
debug_copy_blit(struct debug_stream *stream, const char *name, unsigned len)
498
{
499
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
500
int j = 0;
501
502
mesa_logi("%s (%d dwords):", name, len);
503
mesa_logi("\t0x%08x", ptr[j++]);
504
505
BR13(stream, ptr[j++]);
506
BR22(stream, ptr[j++]);
507
BR23(stream, ptr[j++]);
508
BR09(stream, ptr[j++]);
509
BR26(stream, ptr[j++]);
510
BR11(stream, ptr[j++]);
511
BR12(stream, ptr[j++]);
512
513
stream->offset += len * sizeof(unsigned);
514
assert(j == len);
515
return true;
516
}
517
518
static bool
519
debug_color_blit(struct debug_stream *stream, const char *name, unsigned len)
520
{
521
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
522
int j = 0;
523
524
mesa_logi("%s (%d dwords):", name, len);
525
mesa_logi("\t0x%08x", ptr[j++]);
526
527
BR13(stream, ptr[j++]);
528
BR22(stream, ptr[j++]);
529
BR23(stream, ptr[j++]);
530
BR09(stream, ptr[j++]);
531
BR16(stream, ptr[j++]);
532
533
stream->offset += len * sizeof(unsigned);
534
assert(j == len);
535
return true;
536
}
537
538
static bool
539
debug_modes4(struct debug_stream *stream, const char *name, unsigned len)
540
{
541
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
542
int j = 0;
543
544
mesa_logi("%s (%d dwords):", name, len);
545
mesa_logi("\t0x%08x", ptr[j]);
546
BITS(stream, ptr[j], 21, 18, "logicop func");
547
FLAG(stream, ptr[j], 17, "stencil test mask modify-enable");
548
FLAG(stream, ptr[j], 16, "stencil write mask modify-enable");
549
BITS(stream, ptr[j], 15, 8, "stencil test mask");
550
BITS(stream, ptr[j], 7, 0, "stencil write mask");
551
j++;
552
553
stream->offset += len * sizeof(unsigned);
554
assert(j == len);
555
return true;
556
}
557
558
static bool
559
debug_map_state(struct debug_stream *stream, const char *name, unsigned len)
560
{
561
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
562
unsigned j = 0;
563
564
mesa_logi("%s (%d dwords):", name, len);
565
mesa_logi("\t0x%08x", ptr[j++]);
566
567
{
568
mesa_logi("\t0x%08x", ptr[j]);
569
BITS(stream, ptr[j], 15, 0, "map mask");
570
j++;
571
}
572
573
while (j < len) {
574
{
575
mesa_logi("\t TMn.0: 0x%08x", ptr[j]);
576
mesa_logi("\t map address: 0x%08x", (ptr[j] & ~0x3));
577
FLAG(stream, ptr[j], 1, "vertical line stride");
578
FLAG(stream, ptr[j], 0, "vertical line stride offset");
579
j++;
580
}
581
582
{
583
mesa_logi("\t TMn.1: 0x%08x", ptr[j]);
584
BITS(stream, ptr[j], 31, 21, "height");
585
BITS(stream, ptr[j], 20, 10, "width");
586
BITS(stream, ptr[j], 9, 7, "surface format");
587
BITS(stream, ptr[j], 6, 3, "texel format");
588
FLAG(stream, ptr[j], 2, "use fence regs");
589
FLAG(stream, ptr[j], 1, "tiled surface");
590
FLAG(stream, ptr[j], 0, "tile walk ymajor");
591
j++;
592
}
593
{
594
mesa_logi("\t TMn.2: 0x%08x", ptr[j]);
595
BITS(stream, ptr[j], 31, 21, "dword pitch");
596
BITS(stream, ptr[j], 20, 15, "cube face enables");
597
BITS(stream, ptr[j], 14, 9, "max lod");
598
FLAG(stream, ptr[j], 8, "mip layout right");
599
BITS(stream, ptr[j], 7, 0, "depth");
600
j++;
601
}
602
}
603
604
stream->offset += len * sizeof(unsigned);
605
assert(j == len);
606
return true;
607
}
608
609
static bool
610
debug_sampler_state(struct debug_stream *stream, const char *name, unsigned len)
611
{
612
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
613
unsigned j = 0;
614
615
mesa_logi("%s (%d dwords):", name, len);
616
mesa_logi("\t0x%08x", ptr[j++]);
617
618
{
619
mesa_logi("\t0x%08x", ptr[j]);
620
BITS(stream, ptr[j], 15, 0, "sampler mask");
621
j++;
622
}
623
624
while (j < len) {
625
{
626
mesa_logi("\t TSn.0: 0x%08x", ptr[j]);
627
FLAG(stream, ptr[j], 31, "reverse gamma");
628
FLAG(stream, ptr[j], 30, "planar to packed");
629
FLAG(stream, ptr[j], 29, "yuv->rgb");
630
BITS(stream, ptr[j], 28, 27, "chromakey index");
631
BITS(stream, ptr[j], 26, 22, "base mip level");
632
BITS(stream, ptr[j], 21, 20, "mip mode filter");
633
BITS(stream, ptr[j], 19, 17, "mag mode filter");
634
BITS(stream, ptr[j], 16, 14, "min mode filter");
635
BITS(stream, ptr[j], 13, 5, "lod bias (s4.4)");
636
FLAG(stream, ptr[j], 4, "shadow enable");
637
FLAG(stream, ptr[j], 3, "max-aniso-4");
638
BITS(stream, ptr[j], 2, 0, "shadow func");
639
j++;
640
}
641
642
{
643
mesa_logi("\t TSn.1: 0x%08x", ptr[j]);
644
BITS(stream, ptr[j], 31, 24, "min lod");
645
MBZ(ptr[j], 23, 18);
646
FLAG(stream, ptr[j], 17, "kill pixel enable");
647
FLAG(stream, ptr[j], 16, "keyed tex filter mode");
648
FLAG(stream, ptr[j], 15, "chromakey enable");
649
BITS(stream, ptr[j], 14, 12, "tcx wrap mode");
650
BITS(stream, ptr[j], 11, 9, "tcy wrap mode");
651
BITS(stream, ptr[j], 8, 6, "tcz wrap mode");
652
FLAG(stream, ptr[j], 5, "normalized coords");
653
BITS(stream, ptr[j], 4, 1, "map (surface) index");
654
FLAG(stream, ptr[j], 0, "EAST deinterlacer enable");
655
j++;
656
}
657
{
658
mesa_logi("\t TSn.2: 0x%08x (default color)", ptr[j]);
659
j++;
660
}
661
}
662
663
stream->offset += len * sizeof(unsigned);
664
assert(j == len);
665
return true;
666
}
667
668
static bool
669
debug_dest_vars(struct debug_stream *stream, const char *name, unsigned len)
670
{
671
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
672
int j = 0;
673
674
mesa_logi("%s (%d dwords):", name, len);
675
mesa_logi("\t0x%08x", ptr[j++]);
676
677
{
678
mesa_logi("\t0x%08x", ptr[j]);
679
FLAG(stream, ptr[j], 31, "early classic ztest");
680
FLAG(stream, ptr[j], 30, "opengl tex default color");
681
FLAG(stream, ptr[j], 29, "bypass iz");
682
FLAG(stream, ptr[j], 28, "lod preclamp");
683
BITS(stream, ptr[j], 27, 26, "dither pattern");
684
FLAG(stream, ptr[j], 25, "linear gamma blend");
685
FLAG(stream, ptr[j], 24, "debug dither");
686
BITS(stream, ptr[j], 23, 20, "dstorg x");
687
BITS(stream, ptr[j], 19, 16, "dstorg y");
688
MBZ(ptr[j], 15, 15);
689
BITS(stream, ptr[j], 14, 12, "422 write select");
690
BITS(stream, ptr[j], 11, 8, "cbuf format");
691
BITS(stream, ptr[j], 3, 2, "zbuf format");
692
FLAG(stream, ptr[j], 1, "vert line stride");
693
FLAG(stream, ptr[j], 1, "vert line stride offset");
694
j++;
695
}
696
697
stream->offset += len * sizeof(unsigned);
698
assert(j == len);
699
return true;
700
}
701
702
static bool
703
debug_buf_info(struct debug_stream *stream, const char *name, unsigned len)
704
{
705
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
706
int j = 0;
707
708
mesa_logi("%s (%d dwords):", name, len);
709
mesa_logi("\t0x%08x", ptr[j++]);
710
711
{
712
mesa_logi("\t0x%08x", ptr[j]);
713
BITS(stream, ptr[j], 28, 28, "aux buffer id");
714
BITS(stream, ptr[j], 27, 24, "buffer id (7=depth, 3=back)");
715
FLAG(stream, ptr[j], 23, "use fence regs");
716
FLAG(stream, ptr[j], 22, "tiled surface");
717
FLAG(stream, ptr[j], 21, "tile walk ymajor");
718
MBZ(ptr[j], 20, 14);
719
BITS(stream, ptr[j], 13, 2, "dword pitch");
720
MBZ(ptr[j], 2, 0);
721
j++;
722
}
723
724
mesa_logi("\t0x%08x -- buffer base address", ptr[j++]);
725
726
stream->offset += len * sizeof(unsigned);
727
assert(j == len);
728
return true;
729
}
730
731
static bool
732
i915_debug_packet(struct debug_stream *stream)
733
{
734
unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
735
unsigned cmd = *ptr;
736
737
switch (((cmd >> 29) & 0x7)) {
738
case 0x0:
739
switch ((cmd >> 23) & 0x3f) {
740
case 0x0:
741
return debug(stream, "MI_NOOP", 1);
742
case 0x3:
743
return debug(stream, "MI_WAIT_FOR_EVENT", 1);
744
case 0x4:
745
return debug(stream, "MI_FLUSH", 1);
746
case 0xA:
747
debug(stream, "MI_BATCH_BUFFER_END", 1);
748
return false;
749
case 0x22:
750
return debug(stream, "MI_LOAD_REGISTER_IMM", 3);
751
case 0x31:
752
return debug_chain(stream, "MI_BATCH_BUFFER_START", 2);
753
default:
754
(void)debug(stream, "UNKNOWN 0x0 case!", 1);
755
assert(0);
756
break;
757
}
758
break;
759
case 0x1:
760
(void)debug(stream, "UNKNOWN 0x1 case!", 1);
761
assert(0);
762
break;
763
case 0x2:
764
switch ((cmd >> 22) & 0xff) {
765
case 0x50:
766
return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2);
767
case 0x53:
768
return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2);
769
default:
770
return debug(stream, "blit command", (cmd & 0xff) + 2);
771
}
772
break;
773
case 0x3:
774
switch ((cmd >> 24) & 0x1f) {
775
case 0x6:
776
return debug(stream, "3DSTATE_ANTI_ALIASING", 1);
777
case 0x7:
778
return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1);
779
case 0x8:
780
return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 1);
781
case 0x9:
782
return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
783
case 0xb:
784
return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
785
case 0xc:
786
return debug(stream, "3DSTATE_MODES5", 1);
787
case 0xd:
788
return debug_modes4(stream, "3DSTATE_MODES4", 1);
789
case 0x15:
790
return debug(stream, "3DSTATE_FOG_COLOR", 1);
791
case 0x16:
792
return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1);
793
case 0x1c:
794
/* 3DState16NP */
795
switch ((cmd >> 19) & 0x1f) {
796
case 0x10:
797
return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1);
798
case 0x11:
799
return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
800
default:
801
(void)debug(stream, "UNKNOWN 0x1c case!", 1);
802
assert(0);
803
break;
804
}
805
break;
806
case 0x1d:
807
/* 3DStateMW */
808
switch ((cmd >> 16) & 0xff) {
809
case 0x0:
810
return debug_map_state(stream, "3DSTATE_MAP_STATE",
811
(cmd & 0x1f) + 2);
812
case 0x1:
813
return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE",
814
(cmd & 0x1f) + 2);
815
case 0x4:
816
return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE",
817
(cmd & 0xf) + 2);
818
case 0x5:
819
return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM",
820
(cmd & 0x1ff) + 2);
821
case 0x6:
822
return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS",
823
(cmd & 0xff) + 2);
824
case 0x7:
825
return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT",
826
(cmd & 0xff) + 2);
827
case 0x80:
828
return debug(stream, "3DSTATE_DRAWING_RECTANGLE",
829
(cmd & 0xffff) + 2);
830
case 0x81:
831
return debug(stream, "3DSTATE_SCISSOR_RECTANGLE",
832
(cmd & 0xffff) + 2);
833
case 0x83:
834
return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2);
835
case 0x85:
836
return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS",
837
(cmd & 0xffff) + 2);
838
case 0x88:
839
return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR",
840
(cmd & 0xffff) + 2);
841
case 0x89:
842
return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2);
843
case 0x8e:
844
return debug_buf_info(stream, "3DSTATE_BUFFER_INFO",
845
(cmd & 0xffff) + 2);
846
case 0x97:
847
return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE",
848
(cmd & 0xffff) + 2);
849
case 0x98:
850
return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2);
851
case 0x99:
852
return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2);
853
case 0x9a:
854
return debug(stream, "3DSTATE_DEFAULT_SPECULAR",
855
(cmd & 0xffff) + 2);
856
case 0x9c:
857
return debug(stream, "3DSTATE_CLEAR_PARAMETERS",
858
(cmd & 0xffff) + 2);
859
default:
860
assert(0);
861
return 0;
862
}
863
break;
864
case 0x1e:
865
if (cmd & (1 << 23))
866
return debug(stream, "???", (cmd & 0xffff) + 1);
867
else
868
return debug(stream, "", 1);
869
break;
870
case 0x1f:
871
if ((cmd & (1 << 23)) == 0)
872
return debug_prim(stream, "3DPRIM (inline)", 1,
873
(cmd & 0x1ffff) + 2);
874
else if (cmd & (1 << 17)) {
875
if ((cmd & 0xffff) == 0)
876
return debug_variable_length_prim(stream);
877
else
878
return debug_prim(stream, "3DPRIM (indexed)", 0,
879
(((cmd & 0xffff) + 1) / 2) + 1);
880
} else
881
return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2);
882
break;
883
default:
884
return debug(stream, "", 0);
885
}
886
break;
887
default:
888
assert(0);
889
return 0;
890
}
891
892
assert(0);
893
return 0;
894
}
895
896
void
897
i915_dump_batchbuffer(struct i915_winsys_batchbuffer *batch)
898
{
899
struct debug_stream stream;
900
unsigned *start = (unsigned *)batch->map;
901
unsigned *end = (unsigned *)batch->ptr;
902
unsigned long bytes = (unsigned long)(end - start) * 4;
903
bool done = false;
904
905
stream.offset = 0;
906
stream.ptr = (char *)start;
907
stream.print_addresses = 0;
908
909
if (!start || !end) {
910
mesa_logi("BATCH: ???");
911
return;
912
}
913
914
mesa_logi("BATCH: (%d)", (int)bytes / 4);
915
916
while (!done && stream.offset < bytes) {
917
if (!i915_debug_packet(&stream))
918
break;
919
920
assert(stream.offset <= bytes);
921
}
922
923
mesa_logi("END-BATCH");
924
}
925
926
/***********************************************************************
927
* Dirty state atom dumping
928
*/
929
930
void
931
i915_dump_dirty(struct i915_context *i915, const char *func)
932
{
933
struct {
934
unsigned dirty;
935
const char *name;
936
} l[] = {
937
{I915_NEW_VIEWPORT, "viewport"},
938
{I915_NEW_RASTERIZER, "rasterizer"},
939
{I915_NEW_FS, "fs"},
940
{I915_NEW_BLEND, "blend"},
941
{I915_NEW_CLIP, "clip"},
942
{I915_NEW_SCISSOR, "scissor"},
943
{I915_NEW_STIPPLE, "stipple"},
944
{I915_NEW_FRAMEBUFFER, "framebuffer"},
945
{I915_NEW_ALPHA_TEST, "alpha_test"},
946
{I915_NEW_DEPTH_STENCIL, "depth_stencil"},
947
{I915_NEW_SAMPLER, "sampler"},
948
{I915_NEW_SAMPLER_VIEW, "sampler_view"},
949
{I915_NEW_VS_CONSTANTS, "vs_const"},
950
{I915_NEW_FS_CONSTANTS, "fs_const"},
951
{I915_NEW_VBO, "vbo"},
952
{I915_NEW_VS, "vs"},
953
{0, NULL},
954
};
955
int i;
956
957
mesa_logi("%s: ", func);
958
for (i = 0; l[i].name; i++)
959
if (i915->dirty & l[i].dirty)
960
mesa_logi("%s ", l[i].name);
961
mesa_logi("%s", "");
962
}
963
964
void
965
i915_dump_hardware_dirty(struct i915_context *i915, const char *func)
966
{
967
struct {
968
unsigned dirty;
969
const char *name;
970
} l[] = {
971
{I915_HW_STATIC, "static"},
972
{I915_HW_DYNAMIC, "dynamic"},
973
{I915_HW_SAMPLER, "sampler"},
974
{I915_HW_MAP, "map"},
975
{I915_HW_PROGRAM, "program"},
976
{I915_HW_CONSTANTS, "constants"},
977
{I915_HW_IMMEDIATE, "immediate"},
978
{I915_HW_INVARIANT, "invariant"},
979
{0, NULL},
980
};
981
int i;
982
983
mesa_logi("%s: ", func);
984
for (i = 0; l[i].name; i++)
985
if (i915->hardware_dirty & l[i].dirty)
986
mesa_logi("%s ", l[i].name);
987
mesa_logi("%s", "");
988
}
989
990