blob: 08ce48fccf9764130c65b83591064e4412a1fc7f [file] [log] [blame]
Chia-I Wu00b51a82014-09-09 12:07:37 +08001/*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28#include <stdio.h>
29#include <stdarg.h>
30#include "genhw/genhw.h"
31#include "kmd/winsys.h"
32#include "cmd_priv.h"
33
34#define READ(dw, field) (((dw) & field ## __MASK) >> field ## __SHIFT)
35
36static const uint32_t *
37writer_pointer(const struct intel_cmd *cmd,
38 enum intel_cmd_writer_type which,
39 unsigned offset)
40{
41 const struct intel_cmd_writer *writer = &cmd->writers[which];
42 return (const uint32_t *) ((const char *) writer->ptr + offset);
43}
44
45static uint32_t
46writer_dw(const struct intel_cmd *cmd,
47 enum intel_cmd_writer_type which,
48 unsigned offset, unsigned dw_index,
49 const char *format, ...)
50{
51 const uint32_t *dw = writer_pointer(cmd, which, offset);
52 va_list ap;
53 char desc[16];
54 int len;
55
56 fprintf(stderr, "0x%08x: 0x%08x: ",
57 offset + (dw_index << 2), dw[dw_index]);
58
59 va_start(ap, format);
60 len = vsnprintf(desc, sizeof(desc), format, ap);
61 va_end(ap);
62
63 if (len >= sizeof(desc)) {
64 len = sizeof(desc) - 1;
65 desc[len] = '\0';
66 }
67
68 if (desc[len - 1] == '\n') {
69 desc[len - 1] = '\0';
70 fprintf(stderr, "%8s: \n", desc);
71 } else {
72 fprintf(stderr, "%8s: ", desc);
73 }
74
75 return dw[dw_index];
76}
77
78static void
79writer_decode_blob(const struct intel_cmd *cmd,
80 enum intel_cmd_writer_type which,
81 const struct intel_cmd_item *item)
82{
Chia-I Wu238cabd2014-10-25 13:59:45 +080083 const unsigned state_size = sizeof(uint32_t);
Chia-I Wu00b51a82014-09-09 12:07:37 +080084 const unsigned count = item->size / state_size;
85 unsigned offset = item->offset;
86 unsigned i;
87
Chia-I Wu238cabd2014-10-25 13:59:45 +080088 for (i = 0; i < count; i += 4) {
Chia-I Wu00b51a82014-09-09 12:07:37 +080089 const uint32_t *dw = writer_pointer(cmd, which, offset);
90
Chia-I Wu238cabd2014-10-25 13:59:45 +080091 writer_dw(cmd, which, offset, 0, "BLOB%d", i / 4);
Chia-I Wu00b51a82014-09-09 12:07:37 +080092
Chia-I Wu238cabd2014-10-25 13:59:45 +080093 switch (count - i) {
94 case 1:
95 fprintf(stderr, "(%10.4f, %10c, %10c, %10c) "
96 "(0x%08x, %10c, %10c, %10c)\n",
97 u_uif(dw[0]), 'X', 'X', 'X',
98 dw[0], 'X', 'X', 'X');
99 break;
100 case 2:
101 fprintf(stderr, "(%10.4f, %10.4f, %10c, %10c) "
102 "(0x%08x, 0x%08x, %10c, %10c)\n",
103 u_uif(dw[0]), u_uif(dw[1]), 'X', 'X',
104 dw[0], dw[1], 'X', 'X');
105 break;
106 case 3:
107 fprintf(stderr, "(%10.4f, %10.4f, %10.4f, %10c) "
108 "(0x%08x, 0x%08x, 0x%08x, %10c)\n",
109 u_uif(dw[0]), u_uif(dw[1]), u_uif(dw[2]), 'X',
110 dw[0], dw[1], dw[2], 'X');
111 break;
112 default:
113 fprintf(stderr, "(%10.4f, %10.4f, %10.4f, %10.4f) "
114 "(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
115 u_uif(dw[0]), u_uif(dw[1]), u_uif(dw[2]), u_uif(dw[3]),
116 dw[0], dw[1], dw[2], dw[3]);
117 break;
118 }
119
120 offset += state_size * 4;
Chia-I Wu00b51a82014-09-09 12:07:37 +0800121 }
122}
123
124static void
125writer_decode_clip_viewport(const struct intel_cmd *cmd,
126 enum intel_cmd_writer_type which,
127 const struct intel_cmd_item *item)
128{
129 const unsigned state_size = sizeof(uint32_t) * 4;
130 const unsigned count = item->size / state_size;
131 unsigned offset = item->offset;
132 unsigned i;
133
134 for (i = 0; i < count; i++) {
135 uint32_t dw;
136
137 dw = writer_dw(cmd, which, offset, 0, "CLIP VP%d", i);
138 fprintf(stderr, "xmin = %f\n", u_uif(dw));
139
140 dw = writer_dw(cmd, which, offset, 1, "CLIP VP%d", i);
141 fprintf(stderr, "xmax = %f\n", u_uif(dw));
142
143 dw = writer_dw(cmd, which, offset, 2, "CLIP VP%d", i);
144 fprintf(stderr, "ymin = %f\n", u_uif(dw));
145
146 dw = writer_dw(cmd, which, offset, 3, "CLIP VP%d", i);
147 fprintf(stderr, "ymax = %f\n", u_uif(dw));
148
149 offset += state_size;
150 }
151}
152
153static void
154writer_decode_sf_clip_viewport_gen7(const struct intel_cmd *cmd,
155 enum intel_cmd_writer_type which,
156 const struct intel_cmd_item *item)
157{
158 const unsigned state_size = sizeof(uint32_t) * 16;
159 const unsigned count = item->size / state_size;
160 unsigned offset = item->offset;
161 unsigned i;
162
163 for (i = 0; i < count; i++) {
164 uint32_t dw;
165
166 dw = writer_dw(cmd, which, offset, 0, "SF_CLIP VP%d", i);
167 fprintf(stderr, "m00 = %f\n", u_uif(dw));
168
169 dw = writer_dw(cmd, which, offset, 1, "SF_CLIP VP%d", i);
170 fprintf(stderr, "m11 = %f\n", u_uif(dw));
171
172 dw = writer_dw(cmd, which, offset, 2, "SF_CLIP VP%d", i);
173 fprintf(stderr, "m22 = %f\n", u_uif(dw));
174
175 dw = writer_dw(cmd, which, offset, 3, "SF_CLIP VP%d", i);
176 fprintf(stderr, "m30 = %f\n", u_uif(dw));
177
178 dw = writer_dw(cmd, which, offset, 4, "SF_CLIP VP%d", i);
179 fprintf(stderr, "m31 = %f\n", u_uif(dw));
180
181 dw = writer_dw(cmd, which, offset, 5, "SF_CLIP VP%d", i);
182 fprintf(stderr, "m32 = %f\n", u_uif(dw));
183
184 dw = writer_dw(cmd, which, offset, 8, "SF_CLIP VP%d", i);
185 fprintf(stderr, "guardband xmin = %f\n", u_uif(dw));
186
187 dw = writer_dw(cmd, which, offset, 9, "SF_CLIP VP%d", i);
188 fprintf(stderr, "guardband xmax = %f\n", u_uif(dw));
189
190 dw = writer_dw(cmd, which, offset, 10, "SF_CLIP VP%d", i);
191 fprintf(stderr, "guardband ymin = %f\n", u_uif(dw));
192
193 dw = writer_dw(cmd, which, offset, 11, "SF_CLIP VP%d", i);
194 fprintf(stderr, "guardband ymax = %f\n", u_uif(dw));
195
196 offset += state_size;
197 }
198}
199
200static void
201writer_decode_sf_viewport_gen6(const struct intel_cmd *cmd,
202 enum intel_cmd_writer_type which,
203 const struct intel_cmd_item *item)
204{
205 const unsigned state_size = sizeof(uint32_t) * 8;
206 const unsigned count = item->size / state_size;
207 unsigned offset = item->offset;
208 unsigned i;
209
210 for (i = 0; i < count; i++) {
211 uint32_t dw;
212
213 dw = writer_dw(cmd, which, offset, 0, "SF VP%d", i);
214 fprintf(stderr, "m00 = %f\n", u_uif(dw));
215
216 dw = writer_dw(cmd, which, offset, 1, "SF VP%d", i);
217 fprintf(stderr, "m11 = %f\n", u_uif(dw));
218
219 dw = writer_dw(cmd, which, offset, 2, "SF VP%d", i);
220 fprintf(stderr, "m22 = %f\n", u_uif(dw));
221
222 dw = writer_dw(cmd, which, offset, 3, "SF VP%d", i);
223 fprintf(stderr, "m30 = %f\n", u_uif(dw));
224
225 dw = writer_dw(cmd, which, offset, 4, "SF VP%d", i);
226 fprintf(stderr, "m31 = %f\n", u_uif(dw));
227
228 dw = writer_dw(cmd, which, offset, 5, "SF VP%d", i);
229 fprintf(stderr, "m32 = %f\n", u_uif(dw));
230
231 offset += state_size;
232 }
233}
234
235static void
236writer_decode_sf_viewport(const struct intel_cmd *cmd,
237 enum intel_cmd_writer_type which,
238 const struct intel_cmd_item *item)
239{
240 if (cmd_gen(cmd) >= INTEL_GEN(7))
241 writer_decode_sf_clip_viewport_gen7(cmd, which, item);
242 else
243 writer_decode_sf_viewport_gen6(cmd, which, item);
244}
245
246static void
247writer_decode_scissor_rect(const struct intel_cmd *cmd,
248 enum intel_cmd_writer_type which,
249 const struct intel_cmd_item *item)
250{
251 const unsigned state_size = sizeof(uint32_t) * 2;
252 const unsigned count = item->size / state_size;
253 unsigned offset = item->offset;
254 unsigned i;
255
256 for (i = 0; i < count; i++) {
257 uint32_t dw;
258
259 dw = writer_dw(cmd, which, offset, 0, "SCISSOR%d", i);
260 fprintf(stderr, "xmin %d, ymin %d\n",
261 READ(dw, GEN6_SCISSOR_DW0_MIN_X),
262 READ(dw, GEN6_SCISSOR_DW0_MIN_Y));
263
264 dw = writer_dw(cmd, which, offset, 1, "SCISSOR%d", i);
265 fprintf(stderr, "xmax %d, ymax %d\n",
266 READ(dw, GEN6_SCISSOR_DW1_MAX_X),
267 READ(dw, GEN6_SCISSOR_DW1_MAX_Y));
268
269 offset += state_size;
270 }
271}
272
273static void
274writer_decode_cc_viewport(const struct intel_cmd *cmd,
275 enum intel_cmd_writer_type which,
276 const struct intel_cmd_item *item)
277{
278 const unsigned state_size = sizeof(uint32_t) * 2;
279 const unsigned count = item->size / state_size;
280 unsigned offset = item->offset;
281 unsigned i;
282
283 for (i = 0; i < count; i++) {
284 uint32_t dw;
285
286 dw = writer_dw(cmd, which, offset, 0, "CC VP%d", i);
287 fprintf(stderr, "min_depth = %f\n", u_uif(dw));
288
289 dw = writer_dw(cmd, which, offset, 1, "CC VP%d", i);
290 fprintf(stderr, "max_depth = %f\n", u_uif(dw));
291
292 offset += state_size;
293 }
294}
295
296static void
297writer_decode_color_calc(const struct intel_cmd *cmd,
298 enum intel_cmd_writer_type which,
299 const struct intel_cmd_item *item)
300{
301 uint32_t dw;
302
303 dw = writer_dw(cmd, which, item->offset, 0, "CC");
304 fprintf(stderr, "alpha test format %s, round disable %d, "
305 "stencil ref %d, bf stencil ref %d\n",
306 READ(dw, GEN6_CC_DW0_ALPHATEST) ? "FLOAT32" : "UNORM8",
307 (bool) (dw & GEN6_CC_DW0_ROUND_DISABLE_DISABLE),
308 READ(dw, GEN6_CC_DW0_STENCIL0_REF),
309 READ(dw, GEN6_CC_DW0_STENCIL1_REF));
310
311 writer_dw(cmd, which, item->offset, 1, "CC\n");
312
313 dw = writer_dw(cmd, which, item->offset, 2, "CC");
314 fprintf(stderr, "constant red %f\n", u_uif(dw));
315
316 dw = writer_dw(cmd, which, item->offset, 3, "CC");
317 fprintf(stderr, "constant green %f\n", u_uif(dw));
318
319 dw = writer_dw(cmd, which, item->offset, 4, "CC");
320 fprintf(stderr, "constant blue %f\n", u_uif(dw));
321
322 dw = writer_dw(cmd, which, item->offset, 5, "CC");
323 fprintf(stderr, "constant alpha %f\n", u_uif(dw));
324}
325
326static void
327writer_decode_depth_stencil(const struct intel_cmd *cmd,
328 enum intel_cmd_writer_type which,
329 const struct intel_cmd_item *item)
330{
331 uint32_t dw;
332
333 dw = writer_dw(cmd, which, item->offset, 0, "D_S");
334 fprintf(stderr, "stencil %sable, func %d, write %sable\n",
335 (dw & GEN6_ZS_DW0_STENCIL_TEST_ENABLE) ? "en" : "dis",
336 READ(dw, GEN6_ZS_DW0_STENCIL0_FUNC),
337 (dw & GEN6_ZS_DW0_STENCIL_WRITE_ENABLE) ? "en" : "dis");
338
339 dw = writer_dw(cmd, which, item->offset, 1, "D_S");
340 fprintf(stderr, "stencil test mask 0x%x, write mask 0x%x\n",
341 READ(dw, GEN6_ZS_DW1_STENCIL0_VALUEMASK),
342 READ(dw, GEN6_ZS_DW1_STENCIL0_WRITEMASK));
343
344 dw = writer_dw(cmd, which, item->offset, 2, "D_S");
345 fprintf(stderr, "depth test %sable, func %d, write %sable\n",
346 (dw & GEN6_ZS_DW2_DEPTH_TEST_ENABLE) ? "en" : "dis",
347 READ(dw, GEN6_ZS_DW2_DEPTH_FUNC),
348 (dw & GEN6_ZS_DW2_DEPTH_WRITE_ENABLE) ? "en" : "dis");
349}
350
351static void
352writer_decode_blend(const struct intel_cmd *cmd,
353 enum intel_cmd_writer_type which,
354 const struct intel_cmd_item *item)
355{
356 const unsigned state_size = sizeof(uint32_t) * 2;
357 const unsigned count = item->size / state_size;
358 unsigned offset = item->offset;
359 unsigned i;
360
361 for (i = 0; i < count; i++) {
362 writer_dw(cmd, which, offset, 0, "BLEND%d\n", i);
363 writer_dw(cmd, which, offset, 1, "BLEND%d\n", i);
364
365 offset += state_size;
366 }
367}
368
369static void
370writer_decode_sampler(const struct intel_cmd *cmd,
371 enum intel_cmd_writer_type which,
372 const struct intel_cmd_item *item)
373{
374 const unsigned state_size = sizeof(uint32_t) * 4;
375 const unsigned count = item->size / state_size;
376 unsigned offset = item->offset;
377 unsigned i;
378
379 for (i = 0; i < count; i++) {
380 writer_dw(cmd, which, offset, 0, "WM SAMP%d", i);
381 fprintf(stderr, "filtering\n");
382
383 writer_dw(cmd, which, offset, 1, "WM SAMP%d", i);
384 fprintf(stderr, "wrapping, lod\n");
385
386 writer_dw(cmd, which, offset, 2, "WM SAMP%d", i);
387 fprintf(stderr, "default color pointer\n");
388
389 writer_dw(cmd, which, offset, 3, "WM SAMP%d", i);
390 fprintf(stderr, "chroma key, aniso\n");
391
392 offset += state_size;
393 }
394}
395
396static void
397writer_decode_surface_gen7(const struct intel_cmd *cmd,
398 enum intel_cmd_writer_type which,
399 const struct intel_cmd_item *item)
400{
401 uint32_t dw;
402
403 dw = writer_dw(cmd, which, item->offset, 0, "SURF");
404 fprintf(stderr, "type 0x%x, format 0x%x, tiling %d, %s array\n",
405 READ(dw, GEN7_SURFACE_DW0_TYPE),
406 READ(dw, GEN7_SURFACE_DW0_FORMAT),
407 READ(dw, GEN7_SURFACE_DW0_TILING),
408 (dw & GEN7_SURFACE_DW0_IS_ARRAY) ? "is" : "not");
409
410 writer_dw(cmd, which, item->offset, 1, "SURF");
411 fprintf(stderr, "offset\n");
412
413 dw = writer_dw(cmd, which, item->offset, 2, "SURF");
414 fprintf(stderr, "%dx%d size\n",
415 READ(dw, GEN7_SURFACE_DW2_WIDTH),
416 READ(dw, GEN7_SURFACE_DW2_HEIGHT));
417
418 dw = writer_dw(cmd, which, item->offset, 3, "SURF");
419 fprintf(stderr, "depth %d, pitch %d\n",
420 READ(dw, GEN7_SURFACE_DW3_DEPTH),
421 READ(dw, GEN7_SURFACE_DW3_PITCH));
422
423 dw = writer_dw(cmd, which, item->offset, 4, "SURF");
424 fprintf(stderr, "min array element %d, array extent %d\n",
425 READ(dw, GEN7_SURFACE_DW4_MIN_ARRAY_ELEMENT),
426 READ(dw, GEN7_SURFACE_DW4_RT_VIEW_EXTENT));
427
428 dw = writer_dw(cmd, which, item->offset, 5, "SURF");
429 fprintf(stderr, "mip base %d, mips %d, x,y offset: %d,%d\n",
430 READ(dw, GEN7_SURFACE_DW5_MIN_LOD),
431 READ(dw, GEN7_SURFACE_DW5_MIP_COUNT_LOD),
432 READ(dw, GEN7_SURFACE_DW5_X_OFFSET),
433 READ(dw, GEN7_SURFACE_DW5_Y_OFFSET));
434
435 writer_dw(cmd, which, item->offset, 6, "SURF\n");
436 writer_dw(cmd, which, item->offset, 7, "SURF\n");
437}
438
439static void
440writer_decode_surface_gen6(const struct intel_cmd *cmd,
441 enum intel_cmd_writer_type which,
442 const struct intel_cmd_item *item)
443{
444 uint32_t dw;
445
446 dw = writer_dw(cmd, which, item->offset, 0, "SURF");
447 fprintf(stderr, "type 0x%x, format 0x%x\n",
448 READ(dw, GEN6_SURFACE_DW0_TYPE),
449 READ(dw, GEN6_SURFACE_DW0_FORMAT));
450
451 writer_dw(cmd, which, item->offset, 1, "SURF");
452 fprintf(stderr, "offset\n");
453
454 dw = writer_dw(cmd, which, item->offset, 2, "SURF");
455 fprintf(stderr, "%dx%d size, %d mips\n",
456 READ(dw, GEN6_SURFACE_DW2_WIDTH),
457 READ(dw, GEN6_SURFACE_DW2_HEIGHT),
458 READ(dw, GEN6_SURFACE_DW2_MIP_COUNT_LOD));
459
460 dw = writer_dw(cmd, which, item->offset, 3, "SURF");
461 fprintf(stderr, "pitch %d, tiling %d\n",
462 READ(dw, GEN6_SURFACE_DW3_PITCH),
463 READ(dw, GEN6_SURFACE_DW3_TILING));
464
465 dw = writer_dw(cmd, which, item->offset, 4, "SURF");
466 fprintf(stderr, "mip base %d\n",
467 READ(dw, GEN6_SURFACE_DW4_MIN_LOD));
468
469 dw = writer_dw(cmd, which, item->offset, 5, "SURF");
470 fprintf(stderr, "x,y offset: %d,%d\n",
471 READ(dw, GEN6_SURFACE_DW5_X_OFFSET),
472 READ(dw, GEN6_SURFACE_DW5_Y_OFFSET));
473}
474
475static void
476writer_decode_surface(const struct intel_cmd *cmd,
477 enum intel_cmd_writer_type which,
478 const struct intel_cmd_item *item)
479{
480 if (cmd_gen(cmd) >= INTEL_GEN(7))
481 writer_decode_surface_gen7(cmd, which, item);
482 else
483 writer_decode_surface_gen6(cmd, which, item);
484}
485
486static void
487writer_decode_binding_table(const struct intel_cmd *cmd,
488 enum intel_cmd_writer_type which,
489 const struct intel_cmd_item *item)
490{
491 const unsigned state_size = sizeof(uint32_t) * 1;
492 const unsigned count = item->size / state_size;
493 unsigned offset = item->offset;
494 unsigned i;
495
496 for (i = 0; i < count; i++) {
497 writer_dw(cmd, which, offset, 0, "BIND");
498 fprintf(stderr, "BINDING_TABLE_STATE[%d]\n", i);
499
500 offset += state_size;
501 }
502}
503
504static void
505writer_decode_kernel(const struct intel_cmd *cmd,
506 enum intel_cmd_writer_type which,
507 const struct intel_cmd_item *item)
508{
509}
510
511static const struct {
512 void (*func)(const struct intel_cmd *cmd,
513 enum intel_cmd_writer_type which,
514 const struct intel_cmd_item *item);
515} writer_decode_table[INTEL_CMD_ITEM_COUNT] = {
516 [INTEL_CMD_ITEM_BLOB] = { writer_decode_blob },
517 [INTEL_CMD_ITEM_CLIP_VIEWPORT] = { writer_decode_clip_viewport },
518 [INTEL_CMD_ITEM_SF_VIEWPORT] = { writer_decode_sf_viewport },
519 [INTEL_CMD_ITEM_SCISSOR_RECT] = { writer_decode_scissor_rect },
520 [INTEL_CMD_ITEM_CC_VIEWPORT] = { writer_decode_cc_viewport },
521 [INTEL_CMD_ITEM_COLOR_CALC] = { writer_decode_color_calc },
522 [INTEL_CMD_ITEM_DEPTH_STENCIL] = { writer_decode_depth_stencil },
523 [INTEL_CMD_ITEM_BLEND] = { writer_decode_blend },
524 [INTEL_CMD_ITEM_SAMPLER] = { writer_decode_sampler },
525 [INTEL_CMD_ITEM_SURFACE] = { writer_decode_surface },
526 [INTEL_CMD_ITEM_BINDING_TABLE] = { writer_decode_binding_table },
527 [INTEL_CMD_ITEM_KERNEL] = { writer_decode_kernel },
528};
529
530static void cmd_writer_decode_items(struct intel_cmd *cmd,
531 enum intel_cmd_writer_type which)
532{
533 struct intel_cmd_writer *writer = &cmd->writers[which];
534 int i;
535
536 if (!writer->item_used)
537 return;
538
539 writer->ptr = intel_bo_map(writer->bo, false);
540 if (!writer->ptr)
541 return;
542
543 for (i = 0; i < writer->item_used; i++) {
544 const struct intel_cmd_item *item = &writer->items[i];
545
546 writer_decode_table[item->type].func(cmd, which, item);
547 }
548
549 intel_bo_unmap(writer->bo);
Courtney Goeltzenleuchterbbc3db22014-10-13 17:03:12 -0600550 writer->ptr = NULL;
Chia-I Wu00b51a82014-09-09 12:07:37 +0800551}
552
553static void cmd_writer_decode(struct intel_cmd *cmd,
554 enum intel_cmd_writer_type which)
555{
556 struct intel_cmd_writer *writer = &cmd->writers[which];
557
558 assert(writer->bo && !writer->ptr);
559
560 switch (which) {
561 case INTEL_CMD_WRITER_BATCH:
562 fprintf(stderr, "decoding batch buffer: %d bytes\n", writer->used);
563 if (writer->used) {
564 intel_winsys_decode_bo(cmd->dev->winsys,
565 writer->bo, writer->used);
566 }
567 break;
568 case INTEL_CMD_WRITER_STATE:
569 fprintf(stderr, "decoding state buffer: %d states\n",
570 writer->item_used);
571 cmd_writer_decode_items(cmd, which);
572 break;
573 case INTEL_CMD_WRITER_INSTRUCTION:
574 if (true) {
575 fprintf(stderr, "skipping instruction buffer: %d kernels\n",
576 writer->item_used);
577 } else {
578 fprintf(stderr, "decoding instruction buffer: %d kernels\n",
579 writer->item_used);
580
581 cmd_writer_decode_items(cmd, which);
582 }
583 break;
584 default:
585 break;
586 }
587}
588
589/**
590 * Decode according to the recorded items. This can be called only after a
591 * successful intel_cmd_end().
592 */
593void intel_cmd_decode(struct intel_cmd *cmd)
594{
595 int i;
596
597 assert(cmd->result == XGL_SUCCESS);
598
599 for (i = 0; i < INTEL_CMD_WRITER_COUNT; i++)
600 cmd_writer_decode(cmd, i);
601}