Debian Codegraph @

src/imagination/vulkan/rogue/pvr_dump_csb.c

raw
1 /*
2 * Copyright © 2022 Imagination Technologies Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #include <inttypes.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <stdio.h>
28 #include <vulkan/vulkan.h>
29
30 #include "pvr_bo.h"
31 #include "pvr_csb.h"
32 #include "pvr_csb_enum_helpers.h"
33 #include "pvr_device.h"
34 #include "pvr_device_info.h"
35 #include "pvr_dump.h"
36 #include "pvr_dump_bo.h"
37 #include "pvr_physical_device.h"
38 #include "pvr_util.h"
39 #include "util/list.h"
40 #include "util/macros.h"
41 #include "util/u_math.h"
42 #include "vk_enum_to_str.h"
43
44 /*****************************************************************************
45 Utilities
46 ******************************************************************************/
47
48 #define PVR_DUMP_CSB_WORD_SIZE ((unsigned)sizeof(uint32_t))
49
50 enum buffer_type {
51 BUFFER_TYPE_NONE = 0,
52 BUFFER_TYPE_CDMCTRL,
53 BUFFER_TYPE_VDMCTRL,
54 BUFFER_TYPE_PPP,
55 BUFFER_TYPE_INVALID, /* Must be last. */
56 };
57
58 struct pvr_dump_csb_ctx {
59 struct pvr_dump_buffer_ctx base;
60
61 /* User-modifiable values */
62 uint32_t next_block_idx;
63 };
64
65 static inline bool
66 pvr_dump_csb_ctx_push(struct pvr_dump_csb_ctx *const ctx,
67 struct pvr_dump_buffer_ctx *const parent_ctx)
68 {
69 if (!pvr_dump_buffer_ctx_push(&ctx->base,
70 &parent_ctx->base,
71 parent_ctx->ptr,
72 parent_ctx->remaining_size)) {
73 return false;
74 }
75
76 ctx->next_block_idx = 0;
77
78 return true;
79 }
80
81 static inline struct pvr_dump_buffer_ctx *
82 pvr_dump_csb_ctx_pop(struct pvr_dump_csb_ctx *const ctx, bool advance_parent)
83 {
84 struct pvr_dump_buffer_ctx *parent;
85 struct pvr_dump_ctx *parent_base;
86 const uint64_t unused_words =
87 ctx->base.remaining_size / PVR_DUMP_CSB_WORD_SIZE;
88
89 if (unused_words) {
90 pvr_dump_buffer_print_header_line(&ctx->base,
91 "<%" PRIu64 " unused word%s (%" PRIu64
92 " bytes)>",
93 unused_words,
94 unused_words == 1 ? "" : "s",
95 unused_words * PVR_DUMP_CSB_WORD_SIZE);
96
97 pvr_dump_buffer_advance(&ctx->base,
98 unused_words * PVR_DUMP_CSB_WORD_SIZE);
99 }
100
101 pvr_dump_buffer_print_header_line(&ctx->base, "<end of buffer>");
102
103 parent_base = pvr_dump_buffer_ctx_pop(&ctx->base);
104 if (!parent_base)
105 return NULL;
106
107 parent = container_of(parent_base, struct pvr_dump_buffer_ctx, base);
108
109 if (advance_parent)
110 pvr_dump_buffer_advance(parent, ctx->base.capacity);
111
112 return parent;
113 }
114
115 struct pvr_dump_csb_block_ctx {
116 struct pvr_dump_buffer_ctx base;
117 };
118
119 #define pvr_dump_csb_block_ctx_push(ctx, \
120 parent_ctx, \
121 header_format, \
122 header_args...) \
123 ({ \
124 struct pvr_dump_csb_ctx *const _csb_ctx = (parent_ctx); \
125 pvr_dump_buffer_print_header_line(&_csb_ctx->base, \
126 "%" PRIu32 ": " header_format, \
127 _csb_ctx->next_block_idx, \
128 ##header_args); \
129 __pvr_dump_csb_block_ctx_push(ctx, _csb_ctx); \
130 })
131
132 static inline bool
133 __pvr_dump_csb_block_ctx_push(struct pvr_dump_csb_block_ctx *const ctx,
134 struct pvr_dump_csb_ctx *const parent_ctx)
135 {
136 pvr_dump_indent(&parent_ctx->base.base);
137
138 if (!pvr_dump_buffer_ctx_push(&ctx->base,
139 &parent_ctx->base.base,
140 parent_ctx->base.ptr,
141 parent_ctx->base.remaining_size)) {
142 return false;
143 }
144
145 parent_ctx->next_block_idx++;
146
147 return true;
148 }
149
150 static inline struct pvr_dump_csb_ctx *
151 pvr_dump_csb_block_ctx_pop(struct pvr_dump_csb_block_ctx *const ctx)
152 {
153 const uint64_t used_size = ctx->base.capacity - ctx->base.remaining_size;
154 struct pvr_dump_csb_ctx *parent_ctx;
155 struct pvr_dump_ctx *parent_base;
156
157 parent_base = pvr_dump_buffer_ctx_pop(&ctx->base);
158 if (!parent_base)
159 return NULL;
160
161 parent_ctx = container_of(parent_base, struct pvr_dump_csb_ctx, base.base);
162
163 /* No need to check this since it can never fail. */
164 pvr_dump_buffer_advance(&parent_ctx->base, used_size);
165
166 pvr_dump_dedent(parent_base);
167
168 return parent_ctx;
169 }
170
171 static inline const uint32_t *
172 pvr_dump_csb_block_take(struct pvr_dump_csb_block_ctx *const restrict ctx,
173 const uint32_t nr_words)
174 {
175 return pvr_dump_buffer_take(&ctx->base, nr_words * PVR_DUMP_CSB_WORD_SIZE);
176 }
177
178 #define pvr_dump_csb_block_take_packed(ctx, cmd, dest) \
179 ({ \
180 struct pvr_dump_csb_block_ctx *const _block_ctx = (ctx); \
181 struct ROGUE_##cmd *const _dest = (dest); \
182 const void *const _ptr = \
183 pvr_dump_csb_block_take(_block_ctx, pvr_cmd_length(cmd)); \
184 if (_ptr) { \
185 pvr_cmd_unpack(cmd)(_ptr, _dest); \
186 } else { \
187 pvr_dump_field_error(&_block_ctx->base.base, \
188 "failed to unpack word(s)"); \
189 } \
190 !!_ptr; \
191 })
192
193 /*****************************************************************************
194 Feature dumping
195 ******************************************************************************/
196
197 static inline void
198 __pvr_dump_field_needs_feature(struct pvr_dump_ctx *const ctx,
199 const char *const name,
200 const char *const feature)
201 {
202 pvr_dump_field(ctx, name, "<feature %s not present>", feature);
203 }
204
205 #define pvr_dump_field_needs_feature(ctx, name, feature) \
206 do { \
207 (void)PVR_HAS_FEATURE((struct pvr_device_info *)NULL, feature); \
208 __pvr_dump_field_needs_feature(ctx, name, #feature); \
209 } while (0)
210
211 #define pvr_dump_field_member_needs_feature(ctx, compound, member, feature) \
212 do { \
213 (void)&(compound)->member; \
214 pvr_dump_field_needs_feature(ctx, #member, feature); \
215 } while (0)
216
217 /******************************************************************************
218 Sub buffer printer declaration
219 ******************************************************************************/
220
221 static bool print_sub_buffer(struct pvr_dump_ctx *ctx,
222 struct pvr_device *device,
223 enum buffer_type type,
224 pvr_dev_addr_t addr,
225 uint64_t expected_size,
226 char const *size_src);
227
228 /******************************************************************************
229 Block printers
230 ******************************************************************************/
231
232 static uint32_t
233 print_block_cdmctrl_kernel(struct pvr_dump_csb_ctx *const csb_ctx,
234 struct pvr_device *const device)
235 {
236 const pvr_dev_addr_t pds_heap_base = device->heaps.pds_heap->base_addr;
237
238 struct pvr_dump_csb_block_ctx ctx;
239 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
240 uint32_t words_read = 0;
241 bool ret = false;
242
243 struct ROGUE_CDMCTRL_KERNEL0 kernel0 = { 0 };
244 struct ROGUE_CDMCTRL_KERNEL1 kernel1 = { 0 };
245 struct ROGUE_CDMCTRL_KERNEL2 kernel2 = { 0 };
246 struct ROGUE_CDMCTRL_KERNEL3 kernel3 = { 0 };
247 struct ROGUE_CDMCTRL_KERNEL4 kernel4 = { 0 };
248 struct ROGUE_CDMCTRL_KERNEL5 kernel5 = { 0 };
249 struct ROGUE_CDMCTRL_KERNEL6 kernel6 = { 0 };
250 struct ROGUE_CDMCTRL_KERNEL7 kernel7 = { 0 };
251 struct ROGUE_CDMCTRL_KERNEL8 kernel8 = { 0 };
252 struct ROGUE_CDMCTRL_KERNEL9 kernel9 = { 0 };
253 struct ROGUE_CDMCTRL_KERNEL10 kernel10 = { 0 };
254 struct ROGUE_CDMCTRL_KERNEL11 kernel11 = { 0 };
255
256 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "KERNEL"))
257 goto end_out;
258
259 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL0, &kernel0) ||
260 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL1, &kernel1) ||
261 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL2, &kernel2)) {
262 goto end_pop_ctx;
263 }
264 words_read += 3;
265
266 if (!kernel0.indirect_present) {
267 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL3, &kernel3) ||
268 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL4, &kernel4) ||
269 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL5, &kernel5)) {
270 goto end_pop_ctx;
271 }
272 words_read += 3;
273 } else {
274 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL6, &kernel6) ||
275 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL7, &kernel7)) {
276 goto end_pop_ctx;
277 }
278 words_read += 2;
279 }
280
281 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL8, &kernel8))
282 goto end_pop_ctx;
283 words_read += 1;
284
285 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL9, &kernel9) ||
286 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL10, &kernel10) ||
287 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_KERNEL11, &kernel11)) {
288 goto end_pop_ctx;
289 }
290 words_read += 3;
291
292 pvr_dump_field_member_bool(base_ctx, &kernel0, indirect_present);
293 pvr_dump_field_member_bool(base_ctx, &kernel0, global_offsets_present);
294 pvr_dump_field_member_bool(base_ctx, &kernel0, event_object_present);
295 pvr_dump_field_member_u32_scaled_units(
296 base_ctx,
297 &kernel0,
298 usc_common_size,
299 ROGUE_CDMCTRL_KERNEL0_USC_COMMON_SIZE_UNIT_SIZE,
300 "bytes");
301 pvr_dump_field_member_u32_scaled_units(
302 base_ctx,
303 &kernel0,
304 usc_unified_size,
305 ROGUE_CDMCTRL_KERNEL0_USC_UNIFIED_SIZE_UNIT_SIZE,
306 "bytes");
307 pvr_dump_field_member_u32_scaled_units(
308 base_ctx,
309 &kernel0,
310 pds_temp_size,
311 ROGUE_CDMCTRL_KERNEL0_PDS_TEMP_SIZE_UNIT_SIZE,
312 "bytes");
313 pvr_dump_field_member_u32_scaled_units(
314 base_ctx,
315 &kernel0,
316 pds_data_size,
317 ROGUE_CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE,
318 "bytes");
319 pvr_dump_field_member_enum(base_ctx,
320 &kernel0,
321 usc_target,
322 pvr_cmd_enum_to_str(CDMCTRL_USC_TARGET));
323 pvr_dump_field_member_bool(base_ctx, &kernel0, fence);
324
325 pvr_dump_field_member_addr_offset(base_ctx,
326 &kernel1,
327 data_addr,
328 pds_heap_base);
329 ret = print_sub_buffer(
330 base_ctx,
331 device,
332 BUFFER_TYPE_NONE,
333 PVR_DEV_ADDR_OFFSET(pds_heap_base, kernel1.data_addr.addr),
334 kernel0.pds_data_size * ROGUE_CDMCTRL_KERNEL0_PDS_DATA_SIZE_UNIT_SIZE,
335 "pds_data_size");
336 if (!ret)
337 goto end_pop_ctx;
338
339 pvr_dump_field_member_enum(base_ctx,
340 &kernel1,
341 sd_type,
342 pvr_cmd_enum_to_str(CDMCTRL_SD_TYPE));
343 pvr_dump_field_member_bool(base_ctx, &kernel1, usc_common_shared);
344
345 pvr_dump_field_member_addr_offset(base_ctx,
346 &kernel2,
347 code_addr,
348 pds_heap_base);
349 /* FIXME: Determine the exact size of the PDS code section once disassembly
350 * is implemented.
351 */
352 ret = print_sub_buffer(base_ctx,
353 device,
354 BUFFER_TYPE_NONE,
355 PVR_DEV_ADDR_OFFSET(pds_heap_base,
356 kernel2.code_addr.addr),
357 0,
358 NULL);
359 if (!ret)
360 goto end_pop_ctx;
361
362 pvr_dump_field_member_bool(base_ctx, &kernel2, one_wg_per_task);
363
364 if (!kernel0.indirect_present) {
365 pvr_dump_field_member_u32_offset(base_ctx, &kernel3, workgroup_x, 1);
366 pvr_dump_field_member_u32_offset(base_ctx, &kernel4, workgroup_y, 1);
367 pvr_dump_field_member_u32_offset(base_ctx, &kernel5, workgroup_z, 1);
368
369 pvr_dump_field_not_present(base_ctx, "indirect_addr");
370 } else {
371 pvr_dump_field_member_not_present(base_ctx, &kernel3, workgroup_x);
372 pvr_dump_field_member_not_present(base_ctx, &kernel4, workgroup_y);
373 pvr_dump_field_member_not_present(base_ctx, &kernel5, workgroup_z);
374
375 pvr_dump_field_addr_split(base_ctx,
376 "indirect_addr",
377 kernel6.indirect_addrmsb,
378 kernel7.indirect_addrlsb);
379 }
380
381 pvr_dump_field_member_u32_zero(base_ctx, &kernel8, max_instances, 32);
382 pvr_dump_field_member_u32_offset(base_ctx, &kernel8, workgroup_size_x, 1);
383 pvr_dump_field_member_u32_offset(base_ctx, &kernel8, workgroup_size_y, 1);
384 pvr_dump_field_member_u32_offset(base_ctx, &kernel8, workgroup_size_z, 1);
385
386 if (kernel0.event_object_present) {
387 pvr_dump_field_member_u32(base_ctx, &kernel9, global_offset_x);
388 pvr_dump_field_member_u32(base_ctx, &kernel10, global_offset_y);
389 pvr_dump_field_member_u32(base_ctx, &kernel11, global_offset_z);
390 } else {
391 pvr_dump_field_member_not_present(base_ctx, &kernel9, global_offset_x);
392 pvr_dump_field_member_not_present(base_ctx, &kernel10, global_offset_y);
393 pvr_dump_field_member_not_present(base_ctx, &kernel11, global_offset_z);
394 }
395
396 ret = true;
397
398 end_pop_ctx:
399 pvr_dump_csb_block_ctx_pop(&ctx);
400
401 end_out:
402 return ret ? words_read : 0;
403 }
404
405 static uint32_t
406 print_block_cdmctrl_stream_link(struct pvr_dump_csb_ctx *const csb_ctx)
407 {
408 struct pvr_dump_csb_block_ctx ctx;
409 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
410 uint32_t words_read = 0;
411 bool ret = false;
412
413 struct ROGUE_CDMCTRL_STREAM_LINK0 link0 = { 0 };
414 struct ROGUE_CDMCTRL_STREAM_LINK1 link1 = { 0 };
415
416 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STREAM_LINK"))
417 goto end_out;
418
419 if (!pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_STREAM_LINK0, &link0) ||
420 !pvr_dump_csb_block_take_packed(&ctx, CDMCTRL_STREAM_LINK1, &link1)) {
421 goto end_pop_ctx;
422 }
423 words_read += 2;
424
425 pvr_dump_field_addr_split(base_ctx,
426 "link_addr",
427 link0.link_addrmsb,
428 link1.link_addrlsb);
429
430 ret = true;
431
432 end_pop_ctx:
433 pvr_dump_csb_block_ctx_pop(&ctx);
434
435 end_out:
436 return ret ? words_read : 0;
437 }
438
439 static uint32_t
440 print_block_cdmctrl_stream_terminate(struct pvr_dump_csb_ctx *const csb_ctx)
441 {
442 struct pvr_dump_csb_block_ctx ctx;
443 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
444 uint32_t words_read = 0;
445 bool ret = false;
446
447 struct ROGUE_CDMCTRL_STREAM_TERMINATE terminate = { 0 };
448
449 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "TERMINATE"))
450 goto end_out;
451
452 if (!pvr_dump_csb_block_take_packed(&ctx,
453 CDMCTRL_STREAM_TERMINATE,
454 &terminate)) {
455 goto end_pop_ctx;
456 }
457 words_read += 1;
458
459 pvr_dump_field_no_fields(base_ctx);
460
461 ret = true;
462
463 end_pop_ctx:
464 pvr_dump_csb_block_ctx_pop(&ctx);
465
466 end_out:
467 return ret ? words_read : 0;
468 }
469
470 static uint32_t
471 print_block_vdmctrl_ppp_state_update(struct pvr_dump_csb_ctx *const csb_ctx,
472 struct pvr_device *const device)
473 {
474 struct pvr_dump_csb_block_ctx ctx;
475 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
476 uint32_t words_read = 0;
477 bool ret = false;
478
479 struct ROGUE_VDMCTRL_PPP_STATE0 state0 = { 0 };
480 struct ROGUE_VDMCTRL_PPP_STATE1 state1 = { 0 };
481
482 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "PPP_STATE_UPDATE"))
483 goto end_out;
484
485 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_PPP_STATE0, &state0) ||
486 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_PPP_STATE1, &state1)) {
487 goto end_pop_ctx;
488 }
489 words_read += 2;
490
491 pvr_dump_field_member_u32_zero(base_ctx, &state0, word_count, 256);
492 pvr_dump_field_addr_split(base_ctx, "addr", state0.addrmsb, state1.addrlsb);
493 ret = print_sub_buffer(
494 base_ctx,
495 device,
496 BUFFER_TYPE_PPP,
497 PVR_DEV_ADDR(state0.addrmsb.addr | state1.addrlsb.addr),
498 (state0.word_count ? state0.word_count : 256) * PVR_DUMP_CSB_WORD_SIZE,
499 "word_count");
500 if (!ret)
501 goto end_pop_ctx;
502
503 ret = true;
504
505 end_pop_ctx:
506 pvr_dump_csb_block_ctx_pop(&ctx);
507
508 end_out:
509 return ret ? words_read : 0;
510 }
511
512 static uint32_t
513 print_block_vdmctrl_pds_state_update(struct pvr_dump_csb_ctx *const csb_ctx,
514 struct pvr_device *const device)
515 {
516 const pvr_dev_addr_t pds_heap_base = device->heaps.pds_heap->base_addr;
517
518 struct pvr_dump_csb_block_ctx ctx;
519 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
520 uint32_t words_read = 0;
521 bool ret = false;
522
523 struct ROGUE_VDMCTRL_PDS_STATE0 state0 = { 0 };
524 struct ROGUE_VDMCTRL_PDS_STATE1 state1 = { 0 };
525 struct ROGUE_VDMCTRL_PDS_STATE2 state2 = { 0 };
526
527 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "PDS_STATE_UPDATE"))
528 goto end_out;
529
530 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_PDS_STATE0, &state0) ||
531 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_PDS_STATE1, &state1) ||
532 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_PDS_STATE2, &state2)) {
533 goto end_pop_ctx;
534 }
535 words_read += 3;
536
537 pvr_dump_field_member_enum(base_ctx,
538 &state0,
539 dm_target,
540 pvr_cmd_enum_to_str(VDMCTRL_DM_TARGET));
541 pvr_dump_field_member_enum(base_ctx,
542 &state0,
543 usc_target,
544 pvr_cmd_enum_to_str(VDMCTRL_USC_TARGET));
545 pvr_dump_field_member_u32_scaled_units(
546 base_ctx,
547 &state0,
548 usc_common_size,
549 ROGUE_VDMCTRL_PDS_STATE0_USC_COMMON_SIZE_UNIT_SIZE,
550 "bytes");
551 pvr_dump_field_member_u32_scaled_units(
552 base_ctx,
553 &state0,
554 usc_unified_size,
555 ROGUE_VDMCTRL_PDS_STATE0_USC_UNIFIED_SIZE_UNIT_SIZE,
556 "bytes");
557 pvr_dump_field_member_u32_scaled_units(
558 base_ctx,
559 &state0,
560 pds_temp_size,
561 ROGUE_VDMCTRL_PDS_STATE0_PDS_TEMP_SIZE_UNIT_SIZE,
562 "bytes");
563 pvr_dump_field_member_u32_scaled_units(
564 base_ctx,
565 &state0,
566 pds_data_size,
567 ROGUE_VDMCTRL_PDS_STATE0_PDS_DATA_SIZE_UNIT_SIZE,
568 "bytes");
569
570 pvr_dump_field_member_addr_offset(base_ctx,
571 &state1,
572 pds_data_addr,
573 pds_heap_base);
574 ret = print_sub_buffer(
575 base_ctx,
576 device,
577 BUFFER_TYPE_NONE,
578 PVR_DEV_ADDR_OFFSET(pds_heap_base, state1.pds_data_addr.addr),
579 state0.pds_data_size * ROGUE_VDMCTRL_PDS_STATE0_PDS_DATA_SIZE_UNIT_SIZE,
580 "pds_data_size");
581 if (!ret)
582 goto end_pop_ctx;
583
584 pvr_dump_field_member_enum(base_ctx,
585 &state1,
586 sd_type,
587 pvr_cmd_enum_to_str(VDMCTRL_SD_TYPE));
588 pvr_dump_field_member_enum(base_ctx,
589 &state1,
590 sd_next_type,
591 pvr_cmd_enum_to_str(VDMCTRL_SD_TYPE));
592
593 pvr_dump_field_member_addr_offset(base_ctx,
594 &state2,
595 pds_code_addr,
596 pds_heap_base);
597 /* FIXME: Determine the exact size of the PDS code section once disassembly
598 * is implemented.
599 */
600 ret = print_sub_buffer(base_ctx,
601 device,
602 BUFFER_TYPE_NONE,
603 PVR_DEV_ADDR_OFFSET(pds_heap_base,
604 state2.pds_code_addr.addr),
605 0,
606 NULL);
607 if (!ret)
608 goto end_pop_ctx;
609
610 ret = true;
611
612 end_pop_ctx:
613 pvr_dump_csb_block_ctx_pop(&ctx);
614
615 end_out:
616 return ret ? words_read : 0;
617 }
618
619 static uint32_t
620 print_block_vdmctrl_vdm_state_update(struct pvr_dump_csb_ctx *const csb_ctx,
621 struct pvr_device *const device)
622 {
623 const pvr_dev_addr_t pds_heap_base = device->heaps.pds_heap->base_addr;
624
625 struct pvr_dump_csb_block_ctx ctx;
626 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
627 uint32_t words_read = 0;
628 bool ret = false;
629
630 struct ROGUE_VDMCTRL_VDM_STATE0 state0 = { 0 };
631 struct ROGUE_VDMCTRL_VDM_STATE1 state1 = { 0 };
632 struct ROGUE_VDMCTRL_VDM_STATE2 state2 = { 0 };
633 struct ROGUE_VDMCTRL_VDM_STATE3 state3 = { 0 };
634 struct ROGUE_VDMCTRL_VDM_STATE4 state4 = { 0 };
635 struct ROGUE_VDMCTRL_VDM_STATE5 state5 = { 0 };
636
637 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "VDM_STATE_UPDATE"))
638 goto end_out;
639
640 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE0, &state0))
641 goto end_pop_ctx;
642 words_read += 1;
643
644 if (state0.cut_index_present) {
645 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE1, &state1))
646 goto end_pop_ctx;
647 words_read += 1;
648 }
649
650 if (state0.vs_data_addr_present) {
651 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE2, &state2))
652 goto end_pop_ctx;
653 words_read += 1;
654 }
655
656 if (state0.vs_other_present) {
657 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE3, &state3) ||
658 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE4, &state4) ||
659 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_VDM_STATE5, &state5)) {
660 goto end_pop_ctx;
661 }
662 words_read += 3;
663 }
664
665 if (state0.cut_index_present) {
666 pvr_dump_field_member_x32(base_ctx, &state1, cut_index, 8);
667 } else {
668 pvr_dump_field_member_not_present(base_ctx, &state1, cut_index);
669 }
670
671 if (state0.vs_data_addr_present) {
672 pvr_dump_field_member_addr_offset(base_ctx,
673 &state2,
674 vs_pds_data_base_addr,
675 pds_heap_base);
676 if (state0.vs_other_present) {
677 ret = print_sub_buffer(
678 base_ctx,
679 device,
680 BUFFER_TYPE_NONE,
681 PVR_DEV_ADDR_OFFSET(pds_heap_base,
682 state2.vs_pds_data_base_addr.addr),
683 state5.vs_pds_data_size *
684 ROGUE_VDMCTRL_VDM_STATE5_VS_PDS_DATA_SIZE_UNIT_SIZE,
685 "pds_data_size");
686 } else {
687 /* FIXME: Determine the exact size of the PDS data section when no
688 * code section is present once disassembly is implemented.
689 */
690 ret = print_sub_buffer(
691 base_ctx,
692 device,
693 BUFFER_TYPE_NONE,
694 PVR_DEV_ADDR_OFFSET(pds_heap_base,
695 state2.vs_pds_data_base_addr.addr),
696 0,
697 NULL);
698 }
699 if (!ret)
700 goto end_pop_ctx;
701 } else {
702 pvr_dump_field_member_not_present(base_ctx,
703 &state2,
704 vs_pds_data_base_addr);
705 }
706
707 if (state0.vs_other_present) {
708 pvr_dump_field_member_addr_offset(base_ctx,
709 &state3,
710 vs_pds_code_base_addr,
711 pds_heap_base);
712 /* FIXME: Determine the exact size of the PDS code section once
713 * disassembly is implemented.
714 */
715 ret = print_sub_buffer(
716 base_ctx,
717 device,
718 BUFFER_TYPE_NONE,
719 PVR_DEV_ADDR_OFFSET(pds_heap_base, state3.vs_pds_code_base_addr.addr),
720 0,
721 NULL);
722 if (!ret)
723 goto end_pop_ctx;
724
725 pvr_dump_field_member_u32_scaled_units(
726 base_ctx,
727 &state4,
728 vs_output_size,
729 ROGUE_VDMCTRL_VDM_STATE4_VS_OUTPUT_SIZE_UNIT_SIZE,
730 "bytes");
731
732 pvr_dump_field_member_u32_zero(base_ctx, &state5, vs_max_instances, 32);
733 pvr_dump_field_member_u32_scaled_units(
734 base_ctx,
735 &state5,
736 vs_usc_common_size,
737 ROGUE_VDMCTRL_VDM_STATE5_VS_USC_COMMON_SIZE_UNIT_SIZE,
738 "bytes");
739 pvr_dump_field_member_u32_scaled_units(
740 base_ctx,
741 &state5,
742 vs_usc_unified_size,
743 ROGUE_VDMCTRL_VDM_STATE5_VS_USC_UNIFIED_SIZE_UNIT_SIZE,
744 "bytes");
745 pvr_dump_field_member_u32_scaled_units(
746 base_ctx,
747 &state5,
748 vs_pds_temp_size,
749 ROGUE_VDMCTRL_VDM_STATE5_VS_PDS_TEMP_SIZE_UNIT_SIZE,
750 "bytes");
751 pvr_dump_field_member_u32_scaled_units(
752 base_ctx,
753 &state5,
754 vs_pds_data_size,
755 ROGUE_VDMCTRL_VDM_STATE5_VS_PDS_DATA_SIZE_UNIT_SIZE,
756 "bytes");
757 } else {
758 pvr_dump_field_member_not_present(base_ctx,
759 &state3,
760 vs_pds_code_base_addr);
761 pvr_dump_field_member_not_present(base_ctx, &state4, vs_output_size);
762 pvr_dump_field_member_not_present(base_ctx, &state5, vs_max_instances);
763 pvr_dump_field_member_not_present(base_ctx, &state5, vs_usc_common_size);
764 pvr_dump_field_member_not_present(base_ctx, &state5, vs_usc_unified_size);
765 pvr_dump_field_member_not_present(base_ctx, &state5, vs_pds_temp_size);
766 pvr_dump_field_member_not_present(base_ctx, &state5, vs_pds_data_size);
767 }
768
769 pvr_dump_field_member_bool(base_ctx, &state0, ds_present);
770 pvr_dump_field_member_bool(base_ctx, &state0, gs_present);
771 pvr_dump_field_member_bool(base_ctx, &state0, hs_present);
772 pvr_dump_field_member_u32_offset(base_ctx, &state0, cam_size, 1);
773 pvr_dump_field_member_enum(
774 base_ctx,
775 &state0,
776 uvs_scratch_size_select,
777 pvr_cmd_enum_to_str(VDMCTRL_UVS_SCRATCH_SIZE_SELECT));
778 pvr_dump_field_member_bool(base_ctx, &state0, cut_index_enable);
779 pvr_dump_field_member_bool(base_ctx, &state0, tess_enable);
780 pvr_dump_field_member_bool(base_ctx, &state0, gs_enable);
781 pvr_dump_field_member_enum(base_ctx,
782 &state0,
783 flatshade_control,
784 pvr_cmd_enum_to_str(VDMCTRL_FLATSHADE_CONTROL));
785 pvr_dump_field_member_bool(base_ctx, &state0, generate_primitive_id);
786
787 ret = true;
788
789 end_pop_ctx:
790 pvr_dump_csb_block_ctx_pop(&ctx);
791
792 end_out:
793 return ret ? words_read : 0;
794 }
795
796 static uint32_t
797 print_block_vdmctrl_index_list(struct pvr_dump_csb_ctx *const csb_ctx,
798 struct pvr_device *const device)
799 {
800 const struct pvr_device_info *const dev_info = &device->pdevice->dev_info;
801
802 struct pvr_dump_csb_block_ctx ctx;
803 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
804 uint32_t words_read = 0;
805 bool ret = false;
806
807 struct ROGUE_VDMCTRL_INDEX_LIST0 index_list0 = { 0 };
808 struct ROGUE_VDMCTRL_INDEX_LIST1 index_list1 = { 0 };
809 struct ROGUE_VDMCTRL_INDEX_LIST2 index_list2 = { 0 };
810 struct ROGUE_VDMCTRL_INDEX_LIST3 index_list3 = { 0 };
811 struct ROGUE_VDMCTRL_INDEX_LIST4 index_list4 = { 0 };
812 struct ROGUE_VDMCTRL_INDEX_LIST5 index_list5 = { 0 };
813 struct ROGUE_VDMCTRL_INDEX_LIST6 index_list6 = { 0 };
814 struct ROGUE_VDMCTRL_INDEX_LIST7 index_list7 = { 0 };
815 struct ROGUE_VDMCTRL_INDEX_LIST8 index_list8 = { 0 };
816 struct ROGUE_VDMCTRL_INDEX_LIST9 index_list9 = { 0 };
817
818 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "INDEX_LIST"))
819 goto end_out;
820
821 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_INDEX_LIST0, &index_list0))
822 goto end_pop_ctx;
823 words_read += 1;
824
825 if (index_list0.index_addr_present) {
826 if (!pvr_dump_csb_block_take_packed(&ctx,
827 VDMCTRL_INDEX_LIST1,
828 &index_list1)) {
829 goto end_pop_ctx;
830 }
831 words_read += 1;
832 }
833
834 if (index_list0.index_count_present) {
835 if (!pvr_dump_csb_block_take_packed(&ctx,
836 VDMCTRL_INDEX_LIST2,
837 &index_list2)) {
838 goto end_pop_ctx;
839 }
840 words_read += 1;
841 }
842
843 if (index_list0.index_instance_count_present) {
844 if (!pvr_dump_csb_block_take_packed(&ctx,
845 VDMCTRL_INDEX_LIST3,
846 &index_list3)) {
847 goto end_pop_ctx;
848 }
849 words_read += 1;
850 }
851
852 if (index_list0.index_offset_present) {
853 if (!pvr_dump_csb_block_take_packed(&ctx,
854 VDMCTRL_INDEX_LIST4,
855 &index_list4)) {
856 goto end_pop_ctx;
857 }
858 words_read += 1;
859 }
860
861 if (index_list0.start_present) {
862 if (!pvr_dump_csb_block_take_packed(&ctx,
863 VDMCTRL_INDEX_LIST5,
864 &index_list5) ||
865 !pvr_dump_csb_block_take_packed(&ctx,
866 VDMCTRL_INDEX_LIST6,
867 &index_list6)) {
868 goto end_pop_ctx;
869 }
870 words_read += 2;
871 }
872
873 if (index_list0.indirect_addr_present) {
874 if (!pvr_dump_csb_block_take_packed(&ctx,
875 VDMCTRL_INDEX_LIST7,
876 &index_list7) ||
877 !pvr_dump_csb_block_take_packed(&ctx,
878 VDMCTRL_INDEX_LIST8,
879 &index_list8)) {
880 goto end_pop_ctx;
881 }
882 words_read += 2;
883 }
884
885 if (index_list0.split_count_present) {
886 if (!pvr_dump_csb_block_take_packed(&ctx,
887 VDMCTRL_INDEX_LIST9,
888 &index_list9))
889 goto end_pop_ctx;
890 words_read += 1;
891 }
892
893 if (PVR_HAS_FEATURE(dev_info, vdm_degenerate_culling)) {
894 pvr_dump_field_member_bool(base_ctx, &index_list0, degen_cull_enable);
895 } else {
896 pvr_dump_field_member_needs_feature(base_ctx,
897 &index_list0,
898 degen_cull_enable,
899 vdm_degenerate_culling);
900 }
901
902 pvr_dump_field_member_enum(base_ctx,
903 &index_list0,
904 index_size,
905 pvr_cmd_enum_to_str(VDMCTRL_INDEX_SIZE));
906 pvr_dump_field_member_u32_offset(base_ctx, &index_list0, patch_count, 1);
907 pvr_dump_field_member_enum(base_ctx,
908 &index_list0,
909 primitive_topology,
910 pvr_cmd_enum_to_str(VDMCTRL_PRIMITIVE_TOPOLOGY));
911
912 if (index_list0.index_addr_present) {
913 pvr_dump_field_addr_split(base_ctx,
914 "index_base_addr",
915 index_list0.index_base_addrmsb,
916 index_list1.index_base_addrlsb);
917 const uint32_t index_size =
918 pvr_vdmctrl_index_size_nr_bytes(index_list0.index_size);
919
920 if (!index_list0.index_count_present) {
921 ret = pvr_dump_error(base_ctx, "index_addr requires index_count");
922 goto end_pop_ctx;
923 }
924
925 ret = print_sub_buffer(base_ctx,
926 device,
927 BUFFER_TYPE_NONE,
928 PVR_DEV_ADDR(index_list0.index_base_addrmsb.addr |
929 index_list1.index_base_addrlsb.addr),
930 index_list2.index_count * index_size,
931 "index_count * index_size");
932 if (!ret)
933 goto end_pop_ctx;
934 } else {
935 pvr_dump_field_not_present(base_ctx, "index_base_addr");
936 }
937
938 if (index_list0.index_count_present) {
939 pvr_dump_field_member_u32(base_ctx, &index_list2, index_count);
940 } else {
941 pvr_dump_field_member_not_present(base_ctx, &index_list2, index_count);
942 }
943
944 if (index_list0.index_instance_count_present) {
945 pvr_dump_field_member_u32_offset(base_ctx,
946 &index_list3,
947 instance_count,
948 1);
949 } else {
950 pvr_dump_field_member_not_present(base_ctx, &index_list3, instance_count);
951 }
952
953 if (index_list0.index_offset_present) {
954 pvr_dump_field_member_u32(base_ctx, &index_list4, index_offset);
955 } else {
956 pvr_dump_field_member_not_present(base_ctx, &index_list4, index_offset);
957 }
958
959 if (index_list0.start_present) {
960 pvr_dump_field_member_u32(base_ctx, &index_list5, start_index);
961 pvr_dump_field_member_u32(base_ctx, &index_list6, start_instance);
962 } else {
963 pvr_dump_field_member_not_present(base_ctx, &index_list5, start_index);
964 pvr_dump_field_member_not_present(base_ctx, &index_list6, start_instance);
965 }
966
967 if (index_list0.indirect_addr_present) {
968 pvr_dump_field_addr_split(base_ctx,
969 "indirect_base_addr",
970 index_list7.indirect_base_addrmsb,
971 index_list8.indirect_base_addrlsb);
972 ret =
973 print_sub_buffer(base_ctx,
974 device,
975 BUFFER_TYPE_NONE,
976 PVR_DEV_ADDR(index_list7.indirect_base_addrmsb.addr |
977 index_list8.indirect_base_addrlsb.addr),
978 0,
979 NULL);
980 if (!ret)
981 goto end_pop_ctx;
982 } else {
983 pvr_dump_field_not_present(base_ctx, "indirect_base_addr");
984 }
985
986 if (index_list0.split_count_present) {
987 pvr_dump_field_member_u32(base_ctx, &index_list9, split_count);
988 } else {
989 pvr_dump_field_member_not_present(base_ctx, &index_list9, split_count);
990 }
991
992 ret = true;
993
994 end_pop_ctx:
995 pvr_dump_csb_block_ctx_pop(&ctx);
996
997 end_out:
998 return ret ? words_read : 0;
999 }
1000
1001 static uint32_t
1002 print_block_vdmctrl_stream_link(struct pvr_dump_csb_ctx *const csb_ctx)
1003 {
1004 struct pvr_dump_csb_block_ctx ctx;
1005 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1006 uint32_t words_read = 0;
1007 bool ret = false;
1008
1009 struct ROGUE_VDMCTRL_STREAM_LINK0 link0 = { 0 };
1010 struct ROGUE_VDMCTRL_STREAM_LINK1 link1 = { 0 };
1011
1012 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STREAM_LINK"))
1013 goto end_out;
1014
1015 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_STREAM_LINK0, &link0) ||
1016 !pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_STREAM_LINK1, &link1)) {
1017 goto end_pop_ctx;
1018 }
1019 words_read += 2;
1020
1021 pvr_dump_field_member_bool(base_ctx, &link0, with_return);
1022
1023 if (link0.compare_present) {
1024 pvr_dump_field_member_u32(base_ctx, &link0, compare_mode);
1025 pvr_dump_field_member_u32(base_ctx, &link0, compare_data);
1026 } else {
1027 pvr_dump_field_member_not_present(base_ctx, &link0, compare_mode);
1028 pvr_dump_field_member_not_present(base_ctx, &link0, compare_data);
1029 }
1030
1031 pvr_dump_field_addr_split(base_ctx,
1032 "link_addr",
1033 link0.link_addrmsb,
1034 link1.link_addrlsb);
1035
1036 ret = true;
1037
1038 end_pop_ctx:
1039 pvr_dump_csb_block_ctx_pop(&ctx);
1040
1041 end_out:
1042 return ret ? words_read : 0;
1043 }
1044
1045 static uint32_t
1046 print_block_vdmctrl_stream_return(struct pvr_dump_csb_ctx *const csb_ctx)
1047 {
1048 struct pvr_dump_csb_block_ctx ctx;
1049 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1050 uint32_t words_read = 0;
1051 bool ret = false;
1052
1053 struct ROGUE_VDMCTRL_STREAM_RETURN return_ = { 0 };
1054
1055 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STREAM_RETURN"))
1056 goto end_out;
1057
1058 if (!pvr_dump_csb_block_take_packed(&ctx, VDMCTRL_STREAM_RETURN, &return_))
1059 goto end_pop_ctx;
1060 words_read += 1;
1061
1062 pvr_dump_field_no_fields(base_ctx);
1063
1064 ret = true;
1065
1066 end_pop_ctx:
1067 pvr_dump_csb_block_ctx_pop(&ctx);
1068
1069 end_out:
1070 return ret ? words_read : 0;
1071 }
1072
1073 static uint32_t
1074 print_block_vdmctrl_stream_terminate(struct pvr_dump_csb_ctx *const csb_ctx)
1075 {
1076 struct pvr_dump_csb_block_ctx ctx;
1077 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1078 uint32_t words_read = 0;
1079 bool ret = false;
1080
1081 struct ROGUE_VDMCTRL_STREAM_TERMINATE terminate = { 0 };
1082
1083 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "TERMINATE"))
1084 goto end_out;
1085
1086 if (!pvr_dump_csb_block_take_packed(&ctx,
1087 VDMCTRL_STREAM_TERMINATE,
1088 &terminate)) {
1089 goto end_pop_ctx;
1090 }
1091 words_read += 1;
1092
1093 pvr_dump_field_member_bool(base_ctx, &terminate, context);
1094
1095 ret = true;
1096
1097 end_pop_ctx:
1098 pvr_dump_csb_block_ctx_pop(&ctx);
1099
1100 end_out:
1101 return ret ? words_read : 0;
1102 }
1103
1104 static uint32_t
1105 print_block_ppp_state_header(struct pvr_dump_csb_ctx *const csb_ctx,
1106 struct ROGUE_TA_STATE_HEADER *const header_out)
1107 {
1108 struct pvr_dump_csb_block_ctx ctx;
1109 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1110 uint32_t words_read = 0;
1111 bool ret = false;
1112
1113 struct ROGUE_TA_STATE_HEADER header = { 0 };
1114
1115 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_HEADER"))
1116 goto end_out;
1117
1118 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_HEADER, &header))
1119 goto end_pop_ctx;
1120 words_read += 1;
1121
1122 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl);
1123 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl_fa);
1124 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl_fb);
1125 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl_ba);
1126 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl_bb);
1127 pvr_dump_field_member_bool(base_ctx, &header, pres_ispctl_dbsc);
1128 pvr_dump_field_member_bool(base_ctx, &header, pres_pds_state_ptr0);
1129 pvr_dump_field_member_bool(base_ctx, &header, pres_pds_state_ptr1);
1130 pvr_dump_field_member_bool(base_ctx, &header, pres_pds_state_ptr2);
1131 pvr_dump_field_member_bool(base_ctx, &header, pres_pds_state_ptr3);
1132 pvr_dump_field_member_bool(base_ctx, &header, pres_region_clip);
1133 pvr_dump_field_member_bool(base_ctx, &header, pres_viewport);
1134 pvr_dump_field_member_u32_offset(base_ctx, &header, view_port_count, 1);
1135 pvr_dump_field_member_bool(base_ctx, &header, pres_wclamp);
1136 pvr_dump_field_member_bool(base_ctx, &header, pres_outselects);
1137 pvr_dump_field_member_bool(base_ctx, &header, pres_varying_word0);
1138 pvr_dump_field_member_bool(base_ctx, &header, pres_varying_word1);
1139 pvr_dump_field_member_bool(base_ctx, &header, pres_varying_word2);
1140 pvr_dump_field_member_bool(base_ctx, &header, pres_ppp_ctrl);
1141 pvr_dump_field_member_bool(base_ctx, &header, pres_stream_out_size);
1142 pvr_dump_field_member_bool(base_ctx, &header, pres_stream_out_program);
1143 pvr_dump_field_member_bool(base_ctx, &header, context_switch);
1144 pvr_dump_field_member_bool(base_ctx, &header, pres_terminate);
1145 pvr_dump_field_member_bool(base_ctx, &header, not_final_term);
1146
1147 if (header_out)
1148 *header_out = header;
1149
1150 ret = true;
1151
1152 end_pop_ctx:
1153 pvr_dump_csb_block_ctx_pop(&ctx);
1154
1155 end_out:
1156 return ret ? words_read : 0;
1157 }
1158
1159 static void print_block_ppp_state_isp_one_side(
1160 struct pvr_dump_csb_block_ctx *const ctx,
1161 const struct ROGUE_TA_STATE_ISPA *const isp_a,
1162 const struct ROGUE_TA_STATE_ISPB *const isp_b,
1163 const bool has_b)
1164 {
1165 struct pvr_dump_ctx *const base_ctx = &ctx->base.base;
1166
1167 pvr_dump_indent(base_ctx);
1168
1169 pvr_dump_field_member_enum(base_ctx,
1170 isp_a,
1171 objtype,
1172 pvr_cmd_enum_to_str(TA_OBJTYPE));
1173 pvr_dump_field_member_enum(base_ctx,
1174 isp_a,
1175 passtype,
1176 pvr_cmd_enum_to_str(TA_PASSTYPE));
1177 pvr_dump_field_member_bool(base_ctx, isp_a, ovgvispassmaskop);
1178 pvr_dump_field_member_bool(base_ctx, isp_a, maskval);
1179 pvr_dump_field_member_bool(base_ctx, isp_a, dwritedisable);
1180 pvr_dump_field_member_bool(base_ctx, isp_a, dfbztestenable);
1181 pvr_dump_field_member_enum(base_ctx,
1182 isp_a,
1183 dcmpmode,
1184 pvr_cmd_enum_to_str(TA_CMPMODE));
1185 pvr_dump_field_member_bool(base_ctx, isp_a, linefilllastpixel);
1186 pvr_dump_field_member_uq4_4_offset(base_ctx, isp_a, pointlinewidth, 0x01);
1187 pvr_dump_field_member_u32(base_ctx, isp_a, sref);
1188
1189 if (has_b) {
1190 pvr_dump_field_member_enum(base_ctx,
1191 isp_b,
1192 scmpmode,
1193 pvr_cmd_enum_to_str(TA_CMPMODE));
1194 pvr_dump_field_member_enum(base_ctx,
1195 isp_b,
1196 sop1,
1197 pvr_cmd_enum_to_str(TA_ISPB_STENCILOP));
1198 pvr_dump_field_member_enum(base_ctx,
1199 isp_b,
1200 sop2,
1201 pvr_cmd_enum_to_str(TA_ISPB_STENCILOP));
1202 pvr_dump_field_member_enum(base_ctx,
1203 isp_b,
1204 sop3,
1205 pvr_cmd_enum_to_str(TA_ISPB_STENCILOP));
1206 pvr_dump_field_member_x32(base_ctx, isp_b, scmpmask, 2);
1207 pvr_dump_field_member_x32(base_ctx, isp_b, swmask, 2);
1208 } else {
1209 pvr_dump_field_member_not_present(base_ctx, isp_b, scmpmode);
1210 pvr_dump_field_member_not_present(base_ctx, isp_b, sop1);
1211 pvr_dump_field_member_not_present(base_ctx, isp_b, sop2);
1212 pvr_dump_field_member_not_present(base_ctx, isp_b, sop3);
1213 pvr_dump_field_member_not_present(base_ctx, isp_b, scmpmask);
1214 pvr_dump_field_member_not_present(base_ctx, isp_b, swmask);
1215 }
1216
1217 pvr_dump_dedent(base_ctx);
1218 }
1219
1220 static uint32_t
1221 print_block_ppp_state_isp(struct pvr_dump_csb_ctx *const csb_ctx,
1222 const bool has_fa,
1223 const bool has_fb,
1224 const bool has_ba,
1225 const bool has_bb,
1226 const bool has_dbsc)
1227 {
1228 struct pvr_dump_csb_block_ctx ctx;
1229 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1230 uint32_t words_read = 0;
1231 bool ret = false;
1232
1233 struct ROGUE_TA_STATE_ISPCTL isp_ctl = { 0 };
1234 struct ROGUE_TA_STATE_ISPA isp_fa = { 0 };
1235 struct ROGUE_TA_STATE_ISPB isp_fb = { 0 };
1236 struct ROGUE_TA_STATE_ISPA isp_ba = { 0 };
1237 struct ROGUE_TA_STATE_ISPB isp_bb = { 0 };
1238 struct ROGUE_TA_STATE_ISPDBSC isp_dbsc = { 0 };
1239
1240 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_ISP"))
1241 goto end_out;
1242
1243 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPCTL, &isp_ctl))
1244 goto end_pop_ctx;
1245 words_read += 1;
1246
1247 /* In most blocks, we try to read all words before printing anything. In
1248 * this case, there can be ambiguity in which words to parse (which results
1249 * in an error from the conditional below). To aid in debugging when this
1250 * ambiguity is present, print the control word's contents before continuing
1251 * so the fields which create the ambiguity are dumped even when the rest of
1252 * the block isn't.
1253 */
1254 pvr_dump_field_member_u32(base_ctx, &isp_ctl, visreg);
1255 pvr_dump_field_member_bool(base_ctx, &isp_ctl, visbool);
1256 pvr_dump_field_member_bool(base_ctx, &isp_ctl, vistest);
1257 pvr_dump_field_member_bool(base_ctx, &isp_ctl, scenable);
1258 pvr_dump_field_member_bool(base_ctx, &isp_ctl, dbenable);
1259 pvr_dump_field_member_bool(base_ctx, &isp_ctl, bpres);
1260 pvr_dump_field_member_bool(base_ctx, &isp_ctl, two_sided);
1261 pvr_dump_field_member_bool(base_ctx, &isp_ctl, ovgmtestdisable);
1262 pvr_dump_field_member_bool(base_ctx, &isp_ctl, tagwritedisable);
1263 pvr_dump_field_member_u32(base_ctx, &isp_ctl, upass);
1264 pvr_dump_field_member_u32(base_ctx, &isp_ctl, validid);
1265
1266 if (!has_fa || has_fb != isp_ctl.bpres || has_ba != isp_ctl.two_sided ||
1267 has_bb != (isp_ctl.bpres && isp_ctl.two_sided)) {
1268 pvr_dump_error(
1269 base_ctx,
1270 "words declared by ppp header do not match requirements of ispctl word");
1271 goto end_pop_ctx;
1272 }
1273
1274 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPA, &isp_fa))
1275 return false;
1276 words_read += 1;
1277
1278 if (has_fb) {
1279 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPB, &isp_fb))
1280 return false;
1281 words_read += 1;
1282 }
1283
1284 if (has_ba) {
1285 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPA, &isp_ba))
1286 return false;
1287 words_read += 1;
1288 }
1289
1290 if (has_bb) {
1291 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPB, &isp_bb))
1292 return false;
1293 words_read += 1;
1294 }
1295
1296 if (has_dbsc) {
1297 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_ISPDBSC, &isp_dbsc))
1298 goto end_pop_ctx;
1299 words_read += 1;
1300 }
1301
1302 pvr_dump_println(base_ctx, "front");
1303 print_block_ppp_state_isp_one_side(&ctx, &isp_fa, &isp_fb, isp_ctl.bpres);
1304
1305 if (isp_ctl.two_sided) {
1306 pvr_dump_println(base_ctx, "back");
1307 print_block_ppp_state_isp_one_side(&ctx, &isp_ba, &isp_bb, isp_ctl.bpres);
1308 } else {
1309 pvr_dump_field_not_present(base_ctx, "back");
1310 }
1311
1312 if (has_dbsc) {
1313 pvr_dump_field_member_u32(base_ctx, &isp_dbsc, dbindex);
1314 pvr_dump_field_member_u32(base_ctx, &isp_dbsc, scindex);
1315 } else {
1316 pvr_dump_field_member_not_present(base_ctx, &isp_dbsc, dbindex);
1317 pvr_dump_field_member_not_present(base_ctx, &isp_dbsc, scindex);
1318 }
1319
1320 ret = true;
1321
1322 end_pop_ctx:
1323 pvr_dump_csb_block_ctx_pop(&ctx);
1324
1325 end_out:
1326 return ret ? words_read : 0;
1327 }
1328
1329 static uint32_t
1330 print_block_ppp_state_pds(struct pvr_dump_csb_ctx *const csb_ctx,
1331 struct pvr_device *const device,
1332 const bool has_initial_words,
1333 const bool has_varying,
1334 const bool has_texturedata,
1335 const bool has_uniformdata)
1336 {
1337 const pvr_dev_addr_t pds_heap_base = device->heaps.pds_heap->base_addr;
1338
1339 struct pvr_dump_csb_block_ctx ctx;
1340 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1341 uint32_t words_read = 0;
1342 bool ret = false;
1343
1344 struct ROGUE_TA_STATE_PDS_SHADERBASE shader_base = { 0 };
1345 struct ROGUE_TA_STATE_PDS_TEXUNICODEBASE tex_unicode_base = { 0 };
1346 struct ROGUE_TA_STATE_PDS_SIZEINFO1 size_info1 = { 0 };
1347 struct ROGUE_TA_STATE_PDS_SIZEINFO2 size_info2 = { 0 };
1348 struct ROGUE_TA_STATE_PDS_VARYINGBASE varying_base = { 0 };
1349 struct ROGUE_TA_STATE_PDS_TEXTUREDATABASE texture_data_base = { 0 };
1350 struct ROGUE_TA_STATE_PDS_UNIFORMDATABASE uniform_data_base = { 0 };
1351
1352 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_PDS"))
1353 goto end_out;
1354
1355 if (has_initial_words) {
1356 if (!pvr_dump_csb_block_take_packed(&ctx,
1357 TA_STATE_PDS_SHADERBASE,
1358 &shader_base) ||
1359 !pvr_dump_csb_block_take_packed(&ctx,
1360 TA_STATE_PDS_TEXUNICODEBASE,
1361 &tex_unicode_base) ||
1362 !pvr_dump_csb_block_take_packed(&ctx,
1363 TA_STATE_PDS_SIZEINFO1,
1364 &size_info1) ||
1365 !pvr_dump_csb_block_take_packed(&ctx,
1366 TA_STATE_PDS_SIZEINFO2,
1367 &size_info2)) {
1368 goto end_pop_ctx;
1369 }
1370 words_read += 4;
1371 }
1372
1373 if (has_varying) {
1374 if (!pvr_dump_csb_block_take_packed(&ctx,
1375 TA_STATE_PDS_VARYINGBASE,
1376 &varying_base)) {
1377 goto end_pop_ctx;
1378 }
1379 words_read += 1;
1380 }
1381
1382 if (has_texturedata) {
1383 if (!pvr_dump_csb_block_take_packed(&ctx,
1384 TA_STATE_PDS_TEXTUREDATABASE,
1385 &texture_data_base)) {
1386 goto end_pop_ctx;
1387 }
1388 words_read += 1;
1389 }
1390
1391 if (has_uniformdata) {
1392 if (!pvr_dump_csb_block_take_packed(&ctx,
1393 TA_STATE_PDS_UNIFORMDATABASE,
1394 &uniform_data_base)) {
1395 goto end_pop_ctx;
1396 }
1397 words_read += 1;
1398 }
1399
1400 if (has_initial_words) {
1401 pvr_dump_field_addr_offset(base_ctx,
1402 "shaderbase",
1403 shader_base.addr,
1404 pds_heap_base);
1405 pvr_dump_field_addr_offset(base_ctx,
1406 "texunicodebase",
1407 tex_unicode_base.addr,
1408 pds_heap_base);
1409
1410 pvr_dump_field_member_u32_scaled_units(
1411 base_ctx,
1412 &size_info1,
1413 pds_uniformsize,
1414 ROGUE_TA_STATE_PDS_SIZEINFO1_PDS_UNIFORMSIZE_UNIT_SIZE,
1415 "words");
1416 pvr_dump_field_member_u32_scaled_units(
1417 base_ctx,
1418 &size_info1,
1419 pds_texturestatesize,
1420 ROGUE_TA_STATE_PDS_SIZEINFO1_PDS_TEXTURESTATESIZE_UNIT_SIZE,
1421 "words");
1422 pvr_dump_field_member_u32_scaled_units(
1423 base_ctx,
1424 &size_info1,
1425 pds_varyingsize,
1426 ROGUE_TA_STATE_PDS_SIZEINFO1_PDS_VARYINGSIZE_UNIT_SIZE,
1427 "words");
1428 pvr_dump_field_member_u32_scaled_units(
1429 base_ctx,
1430 &size_info1,
1431 usc_varyingsize,
1432 ROGUE_TA_STATE_PDS_SIZEINFO1_USC_VARYINGSIZE_UNIT_SIZE,
1433 "words");
1434 pvr_dump_field_member_u32_scaled_units(
1435 base_ctx,
1436 &size_info1,
1437 pds_tempsize,
1438 ROGUE_TA_STATE_PDS_SIZEINFO1_PDS_TEMPSIZE_UNIT_SIZE,
1439 "words");
1440
1441 pvr_dump_field_member_u32_scaled_units(
1442 base_ctx,
1443 &size_info2,
1444 usc_sharedsize,
1445 ROGUE_TA_STATE_PDS_SIZEINFO2_USC_SHAREDSIZE_UNIT_SIZE,
1446 "words");
1447 pvr_dump_field_member_bool(base_ctx, &size_info2, pds_tri_merge_disable);
1448 pvr_dump_field_member_u32(base_ctx, &size_info2, pds_batchnum);
1449 } else {
1450 pvr_dump_field_not_present(base_ctx, "shaderbase");
1451 pvr_dump_field_not_present(base_ctx, "texunicodebase");
1452 pvr_dump_field_member_not_present(base_ctx, &size_info1, pds_uniformsize);
1453 pvr_dump_field_member_not_present(base_ctx,
1454 &size_info1,
1455 pds_texturestatesize);
1456 pvr_dump_field_member_not_present(base_ctx, &size_info1, pds_varyingsize);
1457 pvr_dump_field_member_not_present(base_ctx, &size_info1, usc_varyingsize);
1458 pvr_dump_field_member_not_present(base_ctx, &size_info1, pds_tempsize);
1459 pvr_dump_field_member_not_present(base_ctx, &size_info2, usc_sharedsize);
1460 pvr_dump_field_member_not_present(base_ctx,
1461 &size_info2,
1462 pds_tri_merge_disable);
1463 pvr_dump_field_member_not_present(base_ctx, &size_info2, pds_batchnum);
1464 }
1465
1466 if (has_varying) {
1467 pvr_dump_field_addr_offset(base_ctx,
1468 "varyingbase",
1469 varying_base.addr,
1470 pds_heap_base);
1471 } else {
1472 pvr_dump_field_not_present(base_ctx, "varyingbase");
1473 }
1474
1475 if (has_texturedata) {
1476 pvr_dump_field_addr_offset(base_ctx,
1477 "texturedatabase",
1478 texture_data_base.addr,
1479 pds_heap_base);
1480 } else {
1481 pvr_dump_field_not_present(base_ctx, "texturedatabase");
1482 }
1483
1484 if (has_uniformdata) {
1485 pvr_dump_field_addr_offset(base_ctx,
1486 "uniformdatabase",
1487 uniform_data_base.addr,
1488 pds_heap_base);
1489 } else {
1490 pvr_dump_field_not_present(base_ctx, "uniformdatabase");
1491 }
1492
1493 ret = true;
1494
1495 end_pop_ctx:
1496 pvr_dump_csb_block_ctx_pop(&ctx);
1497
1498 end_out:
1499 return ret ? words_read : 0;
1500 }
1501
1502 static uint32_t
1503 print_block_ppp_region_clip(struct pvr_dump_csb_ctx *const csb_ctx)
1504 {
1505 struct pvr_dump_csb_block_ctx ctx;
1506 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1507 uint32_t words_read = 0;
1508 bool ret = false;
1509
1510 struct ROGUE_TA_REGION_CLIP0 clip0 = { 0 };
1511 struct ROGUE_TA_REGION_CLIP1 clip1 = { 0 };
1512
1513 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "REGION_CLIP"))
1514 goto end_out;
1515
1516 if (!pvr_dump_csb_block_take_packed(&ctx, TA_REGION_CLIP0, &clip0) ||
1517 !pvr_dump_csb_block_take_packed(&ctx, TA_REGION_CLIP1, &clip1)) {
1518 goto end_pop_ctx;
1519 }
1520 words_read += 2;
1521
1522 pvr_dump_field_member_enum(base_ctx,
1523 &clip0,
1524 mode,
1525 pvr_cmd_enum_to_str(TA_REGION_CLIP_MODE));
1526 pvr_dump_field_member_u32_scaled_units(base_ctx, &clip0, left, 32, "pixels");
1527 pvr_dump_field_member_u32_scaled_units(base_ctx, &clip0, right, 32, "pixels");
1528
1529 pvr_dump_field_member_u32_scaled_units(base_ctx, &clip1, top, 32, "pixels");
1530 pvr_dump_field_member_u32_scaled_units(base_ctx,
1531 &clip1,
1532 bottom,
1533 32,
1534 "pixels");
1535
1536 ret = true;
1537
1538 end_pop_ctx:
1539 pvr_dump_csb_block_ctx_pop(&ctx);
1540
1541 end_out:
1542 return ret ? words_read : 0;
1543 }
1544
1545 static uint32_t print_block_ppp_viewport(struct pvr_dump_csb_ctx *const csb_ctx,
1546 const uint32_t idx)
1547 {
1548 static char const *const field_names[] = {
1549 "a0", "m0", "a1", "m1", "a2", "m2"
1550 };
1551
1552 struct pvr_dump_csb_block_ctx ctx;
1553 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1554 uint32_t words_read = 0;
1555 bool ret = false;
1556
1557 STATIC_ASSERT(sizeof(float) == 4);
1558
1559 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "VIEWPORT %" PRIu32, idx))
1560 goto end_out;
1561
1562 for (uint32_t i = 0; i < ARRAY_SIZE(field_names); i++) {
1563 const uint32_t *const value = pvr_dump_csb_block_take(&ctx, 1);
1564 if (!value)
1565 goto end_pop_ctx;
1566 words_read += 1;
1567
1568 pvr_dump_field_f32(base_ctx, field_names[i], uif(*value));
1569 }
1570
1571 ret = true;
1572
1573 end_pop_ctx:
1574 pvr_dump_csb_block_ctx_pop(&ctx);
1575
1576 end_out:
1577 return ret ? words_read : 0;
1578 }
1579
1580 static uint32_t print_block_ppp_wclamp(struct pvr_dump_csb_ctx *const csb_ctx)
1581 {
1582 struct pvr_dump_csb_block_ctx ctx;
1583 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1584 uint32_t words_read = 0;
1585 bool ret = false;
1586
1587 STATIC_ASSERT(sizeof(float) == 4);
1588
1589 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "WCLAMP"))
1590 goto end_out;
1591
1592 const uint32_t *const value = pvr_dump_csb_block_take(&ctx, 1);
1593 if (!value)
1594 goto end_pop_ctx;
1595 words_read += 1;
1596
1597 pvr_dump_field_f32(base_ctx, "value", uif(*value));
1598
1599 ret = true;
1600
1601 end_pop_ctx:
1602 pvr_dump_csb_block_ctx_pop(&ctx);
1603
1604 end_out:
1605 return ret ? words_read : 0;
1606 }
1607
1608 static uint32_t
1609 print_block_ppp_output_sel(struct pvr_dump_csb_ctx *const csb_ctx)
1610 {
1611 struct pvr_dump_csb_block_ctx ctx;
1612 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1613 uint32_t words_read = 0;
1614 bool ret = false;
1615
1616 struct ROGUE_TA_OUTPUT_SEL output_sel = { 0 };
1617
1618 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "OUTPUT_SEL"))
1619 goto end_out;
1620
1621 if (!pvr_dump_csb_block_take_packed(&ctx, TA_OUTPUT_SEL, &output_sel))
1622 goto end_pop_ctx;
1623 words_read += 1;
1624
1625 pvr_dump_field_member_bool(base_ctx, &output_sel, plane0);
1626 pvr_dump_field_member_bool(base_ctx, &output_sel, plane1);
1627 pvr_dump_field_member_bool(base_ctx, &output_sel, plane2);
1628 pvr_dump_field_member_bool(base_ctx, &output_sel, plane3);
1629 pvr_dump_field_member_bool(base_ctx, &output_sel, plane4);
1630 pvr_dump_field_member_bool(base_ctx, &output_sel, plane5);
1631 pvr_dump_field_member_bool(base_ctx, &output_sel, plane6);
1632 pvr_dump_field_member_bool(base_ctx, &output_sel, plane7);
1633 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane0);
1634 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane1);
1635 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane2);
1636 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane3);
1637 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane4);
1638 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane5);
1639 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane6);
1640 pvr_dump_field_member_bool(base_ctx, &output_sel, cullplane7);
1641 pvr_dump_field_member_bool(base_ctx, &output_sel, rhw_pres);
1642 pvr_dump_field_member_bool(base_ctx,
1643 &output_sel,
1644 isp_position_depth_clamp_z);
1645 pvr_dump_field_member_bool(base_ctx, &output_sel, psprite_size_pres);
1646 pvr_dump_field_member_bool(base_ctx, &output_sel, vpt_tgt_pres);
1647 pvr_dump_field_member_bool(base_ctx, &output_sel, render_tgt_pres);
1648 pvr_dump_field_member_bool(base_ctx, &output_sel, tsp_unclamped_z_pres);
1649 pvr_dump_field_member_u32(base_ctx, &output_sel, vtxsize);
1650
1651 ret = true;
1652
1653 end_pop_ctx:
1654 pvr_dump_csb_block_ctx_pop(&ctx);
1655
1656 end_out:
1657 return ret ? words_read : 0;
1658 }
1659
1660 static uint32_t
1661 print_block_ppp_state_varying(struct pvr_dump_csb_ctx *const csb_ctx,
1662 const bool has_word0,
1663 const bool has_word1,
1664 const bool has_word2)
1665 {
1666 struct pvr_dump_csb_block_ctx ctx;
1667 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1668 uint32_t words_read = 0;
1669 bool ret = false;
1670
1671 struct ROGUE_TA_STATE_VARYING0 varying0 = { 0 };
1672 struct ROGUE_TA_STATE_VARYING1 varying1 = { 0 };
1673 struct ROGUE_TA_STATE_VARYING2 varying2 = { 0 };
1674
1675 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_VARYING"))
1676 goto end_out;
1677
1678 if (has_word0) {
1679 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_VARYING0, &varying0))
1680 goto end_pop_ctx;
1681 words_read += 1;
1682 }
1683
1684 if (has_word1) {
1685 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_VARYING1, &varying1))
1686 goto end_pop_ctx;
1687 words_read += 1;
1688 }
1689
1690 if (has_word2) {
1691 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_VARYING2, &varying2))
1692 goto end_pop_ctx;
1693 words_read += 1;
1694 }
1695
1696 if (has_word0) {
1697 pvr_dump_field_member_u32(base_ctx, &varying0, f32_linear);
1698 pvr_dump_field_member_u32(base_ctx, &varying0, f32_flat);
1699 pvr_dump_field_member_u32(base_ctx, &varying0, f32_npc);
1700 } else {
1701 pvr_dump_field_member_not_present(base_ctx, &varying0, f32_linear);
1702 pvr_dump_field_member_not_present(base_ctx, &varying0, f32_flat);
1703 pvr_dump_field_member_not_present(base_ctx, &varying0, f32_npc);
1704 }
1705
1706 if (has_word1) {
1707 pvr_dump_field_member_u32(base_ctx, &varying1, f16_linear);
1708 pvr_dump_field_member_u32(base_ctx, &varying1, f16_flat);
1709 pvr_dump_field_member_u32(base_ctx, &varying1, f16_npc);
1710 } else {
1711 pvr_dump_field_member_not_present(base_ctx, &varying1, f16_linear);
1712 pvr_dump_field_member_not_present(base_ctx, &varying1, f16_flat);
1713 pvr_dump_field_member_not_present(base_ctx, &varying1, f16_npc);
1714 }
1715
1716 if (has_word2) {
1717 pvr_dump_field_member_u32(base_ctx, &varying2, output_clip_planes);
1718 } else {
1719 pvr_dump_field_member_not_present(base_ctx,
1720 &varying2,
1721 output_clip_planes);
1722 }
1723
1724 ret = true;
1725
1726 end_pop_ctx:
1727 pvr_dump_csb_block_ctx_pop(&ctx);
1728
1729 end_out:
1730 return ret ? words_read : 0;
1731 }
1732
1733 static uint32_t
1734 print_block_ppp_state_ppp_ctrl(struct pvr_dump_csb_ctx *const csb_ctx)
1735 {
1736 struct pvr_dump_csb_block_ctx ctx;
1737 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1738 uint32_t words_read = 0;
1739 bool ret = false;
1740
1741 struct ROGUE_TA_STATE_PPP_CTRL ppp_ctrl = { 0 };
1742
1743 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_PPP_CTRL"))
1744 goto end_out;
1745
1746 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_PPP_CTRL, &ppp_ctrl))
1747 goto end_pop_ctx;
1748 words_read += 1;
1749
1750 pvr_dump_field_member_enum(base_ctx,
1751 &ppp_ctrl,
1752 cullmode,
1753 pvr_cmd_enum_to_str(TA_CULLMODE));
1754 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, updatebbox);
1755 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, resetbbox);
1756 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, wbuffen);
1757 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, wclampen);
1758 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, pretransform);
1759 pvr_dump_field_member_enum(base_ctx,
1760 &ppp_ctrl,
1761 flatshade_vtx,
1762 pvr_cmd_enum_to_str(TA_FLATSHADE));
1763 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, drawclippededges);
1764 pvr_dump_field_member_enum(base_ctx,
1765 &ppp_ctrl,
1766 clip_mode,
1767 pvr_cmd_enum_to_str(TA_CLIP_MODE));
1768 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, pres_prim_id);
1769 pvr_dump_field_member_enum(base_ctx,
1770 &ppp_ctrl,
1771 gs_output_topology,
1772 pvr_cmd_enum_to_str(TA_GS_OUTPUT_TOPOLOGY));
1773 pvr_dump_field_member_bool(base_ctx, &ppp_ctrl, prim_msaa);
1774
1775 ret = true;
1776
1777 end_pop_ctx:
1778 pvr_dump_csb_block_ctx_pop(&ctx);
1779
1780 end_out:
1781 return ret ? words_read : 0;
1782 }
1783
1784 static uint32_t
1785 print_block_ppp_state_stream_out(struct pvr_dump_csb_ctx *const csb_ctx,
1786 struct pvr_device *const device,
1787 const bool has_word0,
1788 const bool has_words12)
1789 {
1790 const pvr_dev_addr_t pds_heap_base = device->heaps.pds_heap->base_addr;
1791
1792 struct pvr_dump_csb_block_ctx ctx;
1793 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1794 uint32_t words_read = 0;
1795 bool ret = false;
1796
1797 struct ROGUE_TA_STATE_STREAM_OUT0 stream_out0 = { 0 };
1798 struct ROGUE_TA_STATE_STREAM_OUT1 stream_out1 = { 0 };
1799 struct ROGUE_TA_STATE_STREAM_OUT2 stream_out2 = { 0 };
1800
1801 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_STREAM_OUT"))
1802 goto end_out;
1803
1804 if (has_word0) {
1805 if (!pvr_dump_csb_block_take_packed(&ctx,
1806 TA_STATE_STREAM_OUT0,
1807 &stream_out0)) {
1808 goto end_pop_ctx;
1809 }
1810 words_read += 1;
1811 }
1812
1813 if (has_words12) {
1814 if (!pvr_dump_csb_block_take_packed(&ctx,
1815 TA_STATE_STREAM_OUT1,
1816 &stream_out1) ||
1817 !pvr_dump_csb_block_take_packed(&ctx,
1818 TA_STATE_STREAM_OUT2,
1819 &stream_out2)) {
1820 goto end_pop_ctx;
1821 }
1822 words_read += 2;
1823 }
1824
1825 if (has_word0) {
1826 pvr_dump_field_member_bool(base_ctx, &stream_out0, stream0_ta_output);
1827 pvr_dump_field_member_bool(base_ctx, &stream_out0, stream0_mem_output);
1828 pvr_dump_field_member_u32_units(base_ctx,
1829 &stream_out0,
1830 stream1_size,
1831 "words");
1832 pvr_dump_field_member_u32_units(base_ctx,
1833 &stream_out0,
1834 stream2_size,
1835 "words");
1836 pvr_dump_field_member_u32_units(base_ctx,
1837 &stream_out0,
1838 stream3_size,
1839 "words");
1840 } else {
1841 pvr_dump_field_member_not_present(base_ctx,
1842 &stream_out0,
1843 stream0_ta_output);
1844 pvr_dump_field_member_not_present(base_ctx,
1845 &stream_out0,
1846 stream0_mem_output);
1847 pvr_dump_field_member_not_present(base_ctx, &stream_out0, stream1_size);
1848 pvr_dump_field_member_not_present(base_ctx, &stream_out0, stream2_size);
1849 pvr_dump_field_member_not_present(base_ctx, &stream_out0, stream3_size);
1850 }
1851
1852 if (has_words12) {
1853 pvr_dump_field_member_u32_scaled_units(
1854 base_ctx,
1855 &stream_out1,
1856 pds_temp_size,
1857 ROGUE_TA_STATE_STREAM_OUT1_PDS_TEMP_SIZE_UNIT_SIZE,
1858 "bytes");
1859 pvr_dump_field_member_u32_scaled_units(
1860 base_ctx,
1861 &stream_out1,
1862 pds_data_size,
1863 ROGUE_TA_STATE_STREAM_OUT1_PDS_DATA_SIZE_UNIT_SIZE,
1864 "bytes");
1865 pvr_dump_field_member_bool(base_ctx, &stream_out1, sync);
1866 pvr_dump_field_member_addr_offset(base_ctx,
1867 &stream_out2,
1868 pds_data_addr,
1869 pds_heap_base);
1870 ret = print_sub_buffer(
1871 base_ctx,
1872 device,
1873 BUFFER_TYPE_NONE,
1874 PVR_DEV_ADDR_OFFSET(pds_heap_base, stream_out2.pds_data_addr.addr),
1875 stream_out1.pds_data_size,
1876 "pds_data_size");
1877 if (!ret)
1878 goto end_pop_ctx;
1879 } else {
1880 pvr_dump_field_member_not_present(base_ctx, &stream_out1, pds_temp_size);
1881 pvr_dump_field_member_not_present(base_ctx, &stream_out1, pds_data_size);
1882 pvr_dump_field_member_not_present(base_ctx, &stream_out1, sync);
1883 pvr_dump_field_member_not_present(base_ctx, &stream_out2, pds_data_addr);
1884 }
1885
1886 ret = true;
1887
1888 end_pop_ctx:
1889 pvr_dump_csb_block_ctx_pop(&ctx);
1890
1891 end_out:
1892 return ret ? words_read : 0;
1893 }
1894
1895 static uint32_t
1896 print_block_ppp_state_terminate(struct pvr_dump_csb_ctx *const csb_ctx)
1897 {
1898 struct pvr_dump_csb_block_ctx ctx;
1899 struct pvr_dump_ctx *const base_ctx = &ctx.base.base;
1900 uint32_t words_read = 0;
1901 bool ret = false;
1902
1903 struct ROGUE_TA_STATE_TERMINATE0 terminate0 = { 0 };
1904 struct ROGUE_TA_STATE_TERMINATE1 terminate1 = { 0 };
1905
1906 if (!pvr_dump_csb_block_ctx_push(&ctx, csb_ctx, "STATE_TERMINATE"))
1907 goto end_out;
1908
1909 if (!pvr_dump_csb_block_take_packed(&ctx, TA_STATE_TERMINATE0, &terminate0) ||
1910 !pvr_dump_csb_block_take_packed(&ctx, TA_STATE_TERMINATE1, &terminate1)) {
1911 goto end_pop_ctx;
1912 }
1913 words_read += 2;
1914
1915 pvr_dump_field_member_u32_scaled_units(base_ctx,
1916 &terminate0,
1917 clip_right,
1918 32,
1919 "pixels");
1920 pvr_dump_field_member_u32_scaled_units(base_ctx,
1921 &terminate0,
1922 clip_top,
1923 32,
1924 "pixels");
1925 pvr_dump_field_member_u32_scaled_units(base_ctx,
1926 &terminate0,
1927 clip_bottom,
1928 32,
1929 "pixels");
1930 pvr_dump_field_member_u32_scaled_units(base_ctx,
1931 &terminate1,
1932 clip_left,
1933 32,
1934 "pixels");
1935 pvr_dump_field_member_u32(base_ctx, &terminate1, render_target);
1936
1937 ret = true;
1938
1939 end_pop_ctx:
1940 pvr_dump_csb_block_ctx_pop(&ctx);
1941
1942 end_out:
1943 return ret ? words_read : 0;
1944 }
1945
1946 /******************************************************************************
1947 Buffer printers
1948 ******************************************************************************/
1949
1950 static bool print_block_hex(struct pvr_dump_buffer_ctx *const ctx,
1951 const uint32_t nr_words)
1952 {
1953 const uint32_t nr_bytes = nr_words * PVR_DUMP_CSB_WORD_SIZE;
1954
1955 if (!nr_words)
1956 return false;
1957
1958 pvr_dump_indent(&ctx->base);
1959
1960 pvr_dump_field_u32_units(&ctx->base, "<raw>", nr_bytes, "bytes");
1961
1962 pvr_dump_indent(&ctx->base);
1963 pvr_dump_buffer_rewind(ctx, nr_bytes);
1964 pvr_dump_buffer_hex(ctx, nr_bytes);
1965 pvr_dump_dedent(&ctx->base);
1966
1967 pvr_dump_dedent(&ctx->base);
1968
1969 return true;
1970 }
1971
1972 static bool print_cdmctrl_buffer(struct pvr_dump_buffer_ctx *const parent_ctx,
1973 struct pvr_device *const device)
1974 {
1975 struct pvr_dump_csb_ctx ctx;
1976 bool ret = true;
1977
1978 /* All blocks contain a block_type member in the first word at the same
1979 * position. We could unpack any block to pick out this discriminant field,
1980 * but this one has been chosen because it's only one word long.
1981 */
1982 STATIC_ASSERT(pvr_cmd_length(CDMCTRL_STREAM_TERMINATE) == 1);
1983
1984 if (!pvr_dump_csb_ctx_push(&ctx, parent_ctx))
1985 return false;
1986
1987 do {
1988 enum ROGUE_CDMCTRL_BLOCK_TYPE block_type;
1989 const uint32_t *next_word;
1990 uint32_t words_read = 0;
1991
1992 next_word = pvr_dump_buffer_peek(&ctx.base, sizeof(*next_word));
1993 if (!next_word) {
1994 ret = false;
1995 goto end_pop_ctx;
1996 }
1997
1998 block_type =
1999 pvr_csb_unpack(next_word, CDMCTRL_STREAM_TERMINATE).block_type;
2000 switch (block_type) {
2001 case ROGUE_CDMCTRL_BLOCK_TYPE_COMPUTE_KERNEL:
2002 words_read = print_block_cdmctrl_kernel(&ctx, device);
2003 break;
2004
2005 case ROGUE_CDMCTRL_BLOCK_TYPE_STREAM_LINK:
2006 words_read = print_block_cdmctrl_stream_link(&ctx);
2007 break;
2008
2009 case ROGUE_CDMCTRL_BLOCK_TYPE_STREAM_TERMINATE:
2010 words_read = print_block_cdmctrl_stream_terminate(&ctx);
2011 break;
2012
2013 default:
2014 pvr_dump_buffer_print_header_line(
2015 &ctx.base,
2016 "<could not decode CDMCTRL block (%u)>",
2017 block_type);
2018 break;
2019 }
2020
2021 if (!print_block_hex(&ctx.base, words_read))
2022 ret = false;
2023
2024 if (block_type == ROGUE_CDMCTRL_BLOCK_TYPE_STREAM_TERMINATE)
2025 break;
2026 } while (ret);
2027
2028 end_pop_ctx:
2029 pvr_dump_csb_ctx_pop(&ctx, true);
2030
2031 return ret;
2032 }
2033
2034 static bool print_vdmctrl_buffer(struct pvr_dump_buffer_ctx *const parent_ctx,
2035 struct pvr_device *const device)
2036 {
2037 struct pvr_dump_csb_ctx ctx;
2038 bool ret = true;
2039
2040 /* All blocks contain a block_type member in the first word at the same
2041 * position. We could unpack any block to pick out this discriminant field,
2042 * but this one has been chosen because it's only one word long.
2043 */
2044 STATIC_ASSERT(pvr_cmd_length(VDMCTRL_STREAM_RETURN) == 1);
2045
2046 if (!pvr_dump_csb_ctx_push(&ctx, parent_ctx))
2047 return false;
2048
2049 do {
2050 enum ROGUE_VDMCTRL_BLOCK_TYPE block_type;
2051 const uint32_t *next_word;
2052 uint32_t words_read = 0;
2053
2054 next_word = pvr_dump_buffer_peek(&ctx.base, sizeof(*next_word));
2055 if (!next_word) {
2056 ret = false;
2057 goto end_pop_ctx;
2058 }
2059
2060 block_type = pvr_csb_unpack(next_word, VDMCTRL_STREAM_RETURN).block_type;
2061 switch (block_type) {
2062 case ROGUE_VDMCTRL_BLOCK_TYPE_PPP_STATE_UPDATE:
2063 words_read = print_block_vdmctrl_ppp_state_update(&ctx, device);
2064 break;
2065
2066 case ROGUE_VDMCTRL_BLOCK_TYPE_PDS_STATE_UPDATE:
2067 words_read = print_block_vdmctrl_pds_state_update(&ctx, device);
2068 break;
2069
2070 case ROGUE_VDMCTRL_BLOCK_TYPE_VDM_STATE_UPDATE:
2071 words_read = print_block_vdmctrl_vdm_state_update(&ctx, device);
2072 break;
2073
2074 case ROGUE_VDMCTRL_BLOCK_TYPE_INDEX_LIST:
2075 words_read = print_block_vdmctrl_index_list(&ctx, device);
2076 break;
2077
2078 case ROGUE_VDMCTRL_BLOCK_TYPE_STREAM_LINK:
2079 words_read = print_block_vdmctrl_stream_link(&ctx);
2080 break;
2081
2082 case ROGUE_VDMCTRL_BLOCK_TYPE_STREAM_RETURN:
2083 words_read = print_block_vdmctrl_stream_return(&ctx);
2084 break;
2085
2086 case ROGUE_VDMCTRL_BLOCK_TYPE_STREAM_TERMINATE:
2087 words_read = print_block_vdmctrl_stream_terminate(&ctx);
2088 break;
2089
2090 default:
2091 pvr_dump_buffer_print_header_line(
2092 &ctx.base,
2093 "<could not decode VDMCTRL block (%u)>",
2094 block_type);
2095 break;
2096 }
2097
2098 if (!print_block_hex(&ctx.base, words_read))
2099 ret = false;
2100
2101 if (block_type == ROGUE_VDMCTRL_BLOCK_TYPE_STREAM_TERMINATE)
2102 break;
2103 } while (ret);
2104
2105 end_pop_ctx:
2106 pvr_dump_csb_ctx_pop(&ctx, true);
2107
2108 return ret;
2109 }
2110
2111 static bool print_ppp_buffer(struct pvr_dump_buffer_ctx *const parent_ctx,
2112 struct pvr_device *const device)
2113 {
2114 struct pvr_dump_csb_ctx ctx;
2115 uint32_t words_read;
2116 bool ret = false;
2117
2118 struct ROGUE_TA_STATE_HEADER header = { 0 };
2119
2120 if (!pvr_dump_csb_ctx_push(&ctx, parent_ctx))
2121 goto end_out;
2122
2123 words_read = print_block_ppp_state_header(&ctx, &header);
2124 if (!print_block_hex(&ctx.base, words_read))
2125 goto end_pop_ctx;
2126
2127 if (header.pres_ispctl_fa || header.pres_ispctl_fb ||
2128 header.pres_ispctl_ba || header.pres_ispctl_bb ||
2129 header.pres_ispctl_dbsc) {
2130 if (!header.pres_ispctl) {
2131 ret =
2132 pvr_dump_field_error(&ctx.base.base, "missing ispctl control word");
2133 goto end_pop_ctx;
2134 }
2135
2136 words_read = print_block_ppp_state_isp(&ctx,
2137 header.pres_ispctl_fa,
2138 header.pres_ispctl_fb,
2139 header.pres_ispctl_ba,
2140 header.pres_ispctl_bb,
2141 header.pres_ispctl_dbsc);
2142 if (!print_block_hex(&ctx.base, words_read))
2143 goto end_pop_ctx;
2144 }
2145
2146 if (header.pres_pds_state_ptr0 || header.pres_pds_state_ptr1 ||
2147 header.pres_pds_state_ptr2 || header.pres_pds_state_ptr3) {
2148 words_read = print_block_ppp_state_pds(&ctx,
2149 device,
2150 header.pres_pds_state_ptr0,
2151 header.pres_pds_state_ptr1,
2152 header.pres_pds_state_ptr2,
2153 header.pres_pds_state_ptr3);
2154 if (!print_block_hex(&ctx.base, words_read))
2155 goto end_pop_ctx;
2156 }
2157
2158 if (header.pres_region_clip) {
2159 words_read = print_block_ppp_region_clip(&ctx);
2160 if (!print_block_hex(&ctx.base, words_read))
2161 goto end_pop_ctx;
2162 }
2163
2164 if (header.pres_viewport) {
2165 for (uint32_t i = 0; i < header.view_port_count + 1; i++) {
2166 words_read = print_block_ppp_viewport(&ctx, i);
2167 if (!print_block_hex(&ctx.base, words_read))
2168 goto end_pop_ctx;
2169 }
2170 }
2171
2172 if (header.pres_wclamp) {
2173 words_read = print_block_ppp_wclamp(&ctx);
2174 if (!print_block_hex(&ctx.base, words_read))
2175 goto end_pop_ctx;
2176 }
2177
2178 if (header.pres_outselects) {
2179 words_read = print_block_ppp_output_sel(&ctx);
2180 if (!print_block_hex(&ctx.base, words_read))
2181 goto end_pop_ctx;
2182 }
2183
2184 if (header.pres_varying_word0 || header.pres_varying_word1 ||
2185 header.pres_varying_word2) {
2186 words_read = print_block_ppp_state_varying(&ctx,
2187 header.pres_varying_word0,
2188 header.pres_varying_word1,
2189 header.pres_varying_word2);
2190 if (!print_block_hex(&ctx.base, words_read))
2191 goto end_pop_ctx;
2192 }
2193
2194 if (header.pres_ppp_ctrl) {
2195 words_read = print_block_ppp_state_ppp_ctrl(&ctx);
2196 if (!print_block_hex(&ctx.base, words_read))
2197 goto end_pop_ctx;
2198 }
2199
2200 if (header.pres_stream_out_size || header.pres_stream_out_program) {
2201 words_read =
2202 print_block_ppp_state_stream_out(&ctx,
2203 device,
2204 header.pres_stream_out_size,
2205 header.pres_stream_out_program);
2206 if (!print_block_hex(&ctx.base, words_read))
2207 goto end_pop_ctx;
2208 }
2209
2210 if (header.pres_terminate) {
2211 words_read = print_block_ppp_state_terminate(&ctx);
2212 if (!print_block_hex(&ctx.base, words_read))
2213 goto end_pop_ctx;
2214 }
2215
2216 ret = true;
2217
2218 end_pop_ctx:
2219 pvr_dump_csb_ctx_pop(&ctx, true);
2220
2221 end_out:
2222 return ret;
2223 }
2224
2225 /******************************************************************************
2226 Sub buffer printer definition
2227 ******************************************************************************/
2228
2229 static bool print_sub_buffer(struct pvr_dump_ctx *const ctx,
2230 struct pvr_device *const device,
2231 const enum buffer_type type,
2232 const pvr_dev_addr_t addr,
2233 const uint64_t expected_size,
2234 const char *const size_src)
2235 {
2236 struct pvr_dump_bo_ctx sub_ctx;
2237 struct pvr_dump_ctx *base_ctx;
2238 struct pvr_bo *bo;
2239 uint64_t real_size;
2240 uint64_t offset;
2241 bool ret = false;
2242
2243 pvr_dump_indent(ctx);
2244
2245 bo = pvr_bo_store_lookup(device, addr);
2246 if (!bo) {
2247 if (expected_size) {
2248 pvr_dump_field(ctx,
2249 "<buffer size>",
2250 "%" PRIu64 " bytes (from %s)",
2251 expected_size,
2252 size_src);
2253 } else {
2254 pvr_dump_field(ctx, "<buffer size>", "<unknown>");
2255 }
2256
2257 /* FIXME: Trace pvr_buffer allocations with pvr_bo_store. */
2258 pvr_dump_warn(ctx, "no mapping found at " PVR_DEV_ADDR_FMT, addr.addr);
2259
2260 /* Not a fatal error; don't let a single bad address halt the dump. */
2261 ret = true;
2262 goto end_out;
2263 }
2264
2265 offset = addr.addr - bo->vma->dev_addr.addr;
2266
2267 if (!pvr_dump_bo_ctx_push(&sub_ctx, ctx, device, bo)) {
2268 pvr_dump_println(&sub_ctx.base.base, "<unable to read buffer>");
2269 goto end_out;
2270 }
2271
2272 base_ctx = &sub_ctx.base.base;
2273
2274 if (!pvr_dump_buffer_advance(&sub_ctx.base, offset))
2275 goto end_pop_ctx;
2276
2277 real_size = sub_ctx.base.remaining_size;
2278
2279 if (!expected_size) {
2280 pvr_dump_field(base_ctx,
2281 "<buffer size>",
2282 "%" PRIu64 " bytes mapped",
2283 real_size);
2284 } else if (expected_size > real_size) {
2285 pvr_dump_field(base_ctx,
2286 "<buffer size>",
2287 "%" PRIu64 " bytes mapped, expected %" PRIu64
2288 " bytes (from %s)",
2289 real_size,
2290 expected_size,
2291 size_src);
2292 } else {
2293 pvr_dump_field(base_ctx,
2294 "<buffer size>",
2295 "%" PRIu64 " bytes (from %s)",
2296 expected_size,
2297 size_src);
2298 pvr_dump_buffer_truncate(&sub_ctx.base, expected_size);
2299 }
2300
2301 if (sub_ctx.bo_mapped_in_ctx)
2302 pvr_dump_field(base_ctx, "<host addr>", "<unmapped>");
2303 else
2304 pvr_dump_field(base_ctx, "<host addr>", "%p", sub_ctx.base.ptr);
2305
2306 switch (type) {
2307 case BUFFER_TYPE_NONE:
2308 pvr_dump_field(base_ctx, "<content>", "<not decoded>");
2309 ret = true;
2310 break;
2311
2312 case BUFFER_TYPE_PPP:
2313 pvr_dump_field(base_ctx, "<content>", "<decoded as PPP>");
2314 ret = print_ppp_buffer(&sub_ctx.base, device);
2315 break;
2316
2317 default:
2318 pvr_dump_field(base_ctx, "<content>", "<unsupported format>");
2319 ret = false;
2320 }
2321
2322 pvr_dump_field_u32_units(&sub_ctx.base.base,
2323 "<raw>",
2324 sub_ctx.base.capacity,
2325 "bytes");
2326
2327 pvr_dump_indent(&sub_ctx.base.base);
2328 pvr_dump_buffer_restart(&sub_ctx.base);
2329 pvr_dump_buffer_hex(&sub_ctx.base, 0);
2330 pvr_dump_dedent(&sub_ctx.base.base);
2331
2332 end_pop_ctx:
2333 pvr_dump_bo_ctx_pop(&sub_ctx);
2334
2335 end_out:
2336 pvr_dump_dedent(ctx);
2337
2338 return ret;
2339 }
2340
2341 /******************************************************************************
2342 Top-level dumping
2343 ******************************************************************************/
2344
2345 static bool dump_first_buffer(struct pvr_dump_buffer_ctx *const ctx,
2346 const enum pvr_cmd_stream_type stream_type,
2347 struct pvr_device *const device)
2348 {
2349 bool ret = false;
2350
2351 pvr_dump_mark_section(&ctx->base, "First buffer content");
2352 switch (stream_type) {
2353 case PVR_CMD_STREAM_TYPE_GRAPHICS:
2354 ret = print_vdmctrl_buffer(ctx, device);
2355 break;
2356
2357 case PVR_CMD_STREAM_TYPE_COMPUTE:
2358 ret = print_cdmctrl_buffer(ctx, device);
2359 break;
2360
2361 default:
2362 UNREACHABLE("Unknown stream type");
2363 }
2364
2365 if (!ret)
2366 pvr_dump_println(&ctx->base,
2367 "<error while decoding at 0x%tx>",
2368 (uint8_t *)ctx->ptr - (uint8_t *)ctx->initial_ptr);
2369
2370 pvr_dump_buffer_restart(ctx);
2371 pvr_dump_mark_section(&ctx->base, "First buffer hexdump");
2372 return pvr_dump_buffer_hex(ctx, 0);
2373 }
2374
2375 /******************************************************************************
2376 Public functions
2377 ******************************************************************************/
2378
2379 void pvr_csb_dump(const struct pvr_csb *const csb,
2380 const uint32_t frame_num,
2381 const uint32_t job_num)
2382 {
2383 const uint32_t nr_bos = list_length(&csb->pvr_bo_list);
2384 struct pvr_device *const device = csb->device;
2385
2386 struct pvr_dump_bo_ctx first_bo_ctx;
2387 struct pvr_dump_ctx root_ctx;
2388
2389 pvr_bo_store_dump(device);
2390
2391 pvr_dump_begin(&root_ctx, stderr, "CONTROL STREAM DUMP", 6);
2392
2393 pvr_dump_field_u32(&root_ctx, "Frame num", frame_num);
2394 pvr_dump_field_u32(&root_ctx, "Job num", job_num);
2395 pvr_dump_field_enum(&root_ctx, "Status", csb->status, vk_Result_to_str);
2396 pvr_dump_field_enum(&root_ctx,
2397 "Stream type",
2398 csb->stream_type,
2399 pvr_cmd_stream_type_to_str);
2400
2401 if (nr_bos <= 1) {
2402 pvr_dump_field_u32(&root_ctx, "Nr of BOs", nr_bos);
2403 } else {
2404 /* TODO: Implement multi-buffer dumping. */
2405 pvr_dump_field_computed(&root_ctx,
2406 "Nr of BOs",
2407 "%" PRIu32,
2408 "only the first buffer will be dumped",
2409 nr_bos);
2410 }
2411
2412 if (nr_bos == 0)
2413 goto end_dump;
2414
2415 pvr_dump_mark_section(&root_ctx, "Buffer objects");
2416 pvr_bo_list_dump(&root_ctx, &csb->pvr_bo_list, nr_bos);
2417
2418 if (!pvr_dump_bo_ctx_push(
2419 &first_bo_ctx,
2420 &root_ctx,
2421 device,
2422 list_first_entry(&csb->pvr_bo_list, struct pvr_bo, link))) {
2423 pvr_dump_mark_section(&root_ctx, "First buffer");
2424 pvr_dump_println(&root_ctx, "<unable to read buffer>");
2425 goto end_dump;
2426 }
2427
2428 dump_first_buffer(&first_bo_ctx.base, csb->stream_type, device);
2429
2430 pvr_dump_bo_ctx_pop(&first_bo_ctx);
2431
2432 end_dump:
2433 pvr_dump_end(&root_ctx);
2434 }