1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 #include "pipe/p_compiler.h"
30 #include "util/u_memory.h"
31 #include "util/u_format.h"
32 #include "tgsi/tgsi_dump.h"
33
34 #include "tr_dump.h"
35 #include "tr_dump_state.h"
36
37
trace_dump_format(enum pipe_format format)38 void trace_dump_format(enum pipe_format format)
39 {
40 if (!trace_dumping_enabled_locked())
41 return;
42
43 trace_dump_enum(util_format_name(format) );
44 }
45
46
trace_dump_resource_template(const struct pipe_resource * templat)47 void trace_dump_resource_template(const struct pipe_resource *templat)
48 {
49 if (!trace_dumping_enabled_locked())
50 return;
51
52 if(!templat) {
53 trace_dump_null();
54 return;
55 }
56
57 trace_dump_struct_begin("pipe_resource");
58
59 trace_dump_member(int, templat, target);
60 trace_dump_member(format, templat, format);
61
62 trace_dump_member_begin("width");
63 trace_dump_uint(templat->width0);
64 trace_dump_member_end();
65
66 trace_dump_member_begin("height");
67 trace_dump_uint(templat->height0);
68 trace_dump_member_end();
69
70 trace_dump_member_begin("depth");
71 trace_dump_uint(templat->depth0);
72 trace_dump_member_end();
73
74 trace_dump_member_begin("array_size");
75 trace_dump_uint(templat->array_size);
76 trace_dump_member_end();
77
78 trace_dump_member(uint, templat, last_level);
79 trace_dump_member(uint, templat, usage);
80 trace_dump_member(uint, templat, bind);
81 trace_dump_member(uint, templat, flags);
82
83 trace_dump_struct_end();
84 }
85
86
trace_dump_box(const struct pipe_box * box)87 void trace_dump_box(const struct pipe_box *box)
88 {
89 if (!trace_dumping_enabled_locked())
90 return;
91
92 if(!box) {
93 trace_dump_null();
94 return;
95 }
96
97 trace_dump_struct_begin("pipe_box");
98
99 trace_dump_member(uint, box, x);
100 trace_dump_member(uint, box, y);
101 trace_dump_member(uint, box, z);
102 trace_dump_member(uint, box, width);
103 trace_dump_member(uint, box, height);
104 trace_dump_member(uint, box, depth);
105
106 trace_dump_struct_end();
107 }
108
109
trace_dump_rasterizer_state(const struct pipe_rasterizer_state * state)110 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
111 {
112 if (!trace_dumping_enabled_locked())
113 return;
114
115 if(!state) {
116 trace_dump_null();
117 return;
118 }
119
120 trace_dump_struct_begin("pipe_rasterizer_state");
121
122 trace_dump_member(bool, state, flatshade);
123 trace_dump_member(bool, state, light_twoside);
124 trace_dump_member(bool, state, clamp_vertex_color);
125 trace_dump_member(bool, state, clamp_fragment_color);
126 trace_dump_member(uint, state, front_ccw);
127 trace_dump_member(uint, state, cull_face);
128 trace_dump_member(uint, state, fill_front);
129 trace_dump_member(uint, state, fill_back);
130 trace_dump_member(bool, state, offset_point);
131 trace_dump_member(bool, state, offset_line);
132 trace_dump_member(bool, state, offset_tri);
133 trace_dump_member(bool, state, scissor);
134 trace_dump_member(bool, state, poly_smooth);
135 trace_dump_member(bool, state, poly_stipple_enable);
136 trace_dump_member(bool, state, point_smooth);
137 trace_dump_member(uint, state, sprite_coord_enable);
138 trace_dump_member(bool, state, sprite_coord_mode);
139 trace_dump_member(bool, state, point_quad_rasterization);
140 trace_dump_member(bool, state, point_size_per_vertex);
141 trace_dump_member(bool, state, multisample);
142 trace_dump_member(bool, state, line_smooth);
143 trace_dump_member(bool, state, line_stipple_enable);
144 trace_dump_member(uint, state, line_stipple_factor);
145 trace_dump_member(uint, state, line_stipple_pattern);
146 trace_dump_member(bool, state, line_last_pixel);
147 trace_dump_member(bool, state, flatshade_first);
148 trace_dump_member(bool, state, gl_rasterization_rules);
149 trace_dump_member(bool, state, rasterizer_discard);
150 trace_dump_member(bool, state, depth_clip);
151 trace_dump_member(uint, state, clip_plane_enable);
152
153 trace_dump_member(float, state, line_width);
154 trace_dump_member(float, state, point_size);
155 trace_dump_member(float, state, offset_units);
156 trace_dump_member(float, state, offset_scale);
157 trace_dump_member(float, state, offset_clamp);
158
159 trace_dump_struct_end();
160 }
161
162
trace_dump_poly_stipple(const struct pipe_poly_stipple * state)163 void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
164 {
165 if (!trace_dumping_enabled_locked())
166 return;
167
168 if(!state) {
169 trace_dump_null();
170 return;
171 }
172
173 trace_dump_struct_begin("pipe_poly_stipple");
174
175 trace_dump_member_begin("stipple");
176 trace_dump_array(uint,
177 state->stipple,
178 Elements(state->stipple));
179 trace_dump_member_end();
180
181 trace_dump_struct_end();
182 }
183
184
trace_dump_viewport_state(const struct pipe_viewport_state * state)185 void trace_dump_viewport_state(const struct pipe_viewport_state *state)
186 {
187 if (!trace_dumping_enabled_locked())
188 return;
189
190 if(!state) {
191 trace_dump_null();
192 return;
193 }
194
195 trace_dump_struct_begin("pipe_viewport_state");
196
197 trace_dump_member_array(float, state, scale);
198 trace_dump_member_array(float, state, translate);
199
200 trace_dump_struct_end();
201 }
202
203
trace_dump_scissor_state(const struct pipe_scissor_state * state)204 void trace_dump_scissor_state(const struct pipe_scissor_state *state)
205 {
206 if (!trace_dumping_enabled_locked())
207 return;
208
209 if(!state) {
210 trace_dump_null();
211 return;
212 }
213
214 trace_dump_struct_begin("pipe_scissor_state");
215
216 trace_dump_member(uint, state, minx);
217 trace_dump_member(uint, state, miny);
218 trace_dump_member(uint, state, maxx);
219 trace_dump_member(uint, state, maxy);
220
221 trace_dump_struct_end();
222 }
223
224
trace_dump_clip_state(const struct pipe_clip_state * state)225 void trace_dump_clip_state(const struct pipe_clip_state *state)
226 {
227 unsigned i;
228
229 if (!trace_dumping_enabled_locked())
230 return;
231
232 if(!state) {
233 trace_dump_null();
234 return;
235 }
236
237 trace_dump_struct_begin("pipe_clip_state");
238
239 trace_dump_member_begin("ucp");
240 trace_dump_array_begin();
241 for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
242 trace_dump_elem_begin();
243 trace_dump_array(float, state->ucp[i], 4);
244 trace_dump_elem_end();
245 }
246 trace_dump_array_end();
247 trace_dump_member_end();
248
249 trace_dump_struct_end();
250 }
251
252
trace_dump_shader_state(const struct pipe_shader_state * state)253 void trace_dump_shader_state(const struct pipe_shader_state *state)
254 {
255 static char str[8192];
256 unsigned i;
257
258 if (!trace_dumping_enabled_locked())
259 return;
260
261 if(!state) {
262 trace_dump_null();
263 return;
264 }
265
266 tgsi_dump_str(state->tokens, 0, str, sizeof(str));
267
268 trace_dump_struct_begin("pipe_shader_state");
269
270 trace_dump_member_begin("tokens");
271 trace_dump_string(str);
272 trace_dump_member_end();
273
274 trace_dump_member_begin("stream_output");
275 trace_dump_struct_begin("pipe_stream_output_info");
276 trace_dump_member(uint, &state->stream_output, num_outputs);
277 trace_dump_member_array(uint, &state->stream_output, stride);
278 trace_dump_member_begin("output");
279 trace_dump_array_begin();
280 for(i = 0; i < state->stream_output.num_outputs; ++i) {
281 trace_dump_elem_begin();
282 trace_dump_struct_begin(""); /* anonymous */
283 trace_dump_member(uint, &state->stream_output.output[i], register_index);
284 trace_dump_member(uint, &state->stream_output.output[i], start_component);
285 trace_dump_member(uint, &state->stream_output.output[i], num_components);
286 trace_dump_member(uint, &state->stream_output.output[i], output_buffer);
287 trace_dump_member(uint, &state->stream_output.output[i], dst_offset);
288 trace_dump_struct_end();
289 trace_dump_elem_end();
290 }
291 trace_dump_array_end();
292 trace_dump_member_end(); // output
293 trace_dump_struct_end();
294 trace_dump_member_end(); // stream_output
295
296 trace_dump_struct_end();
297 }
298
299
trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state * state)300 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
301 {
302 unsigned i;
303
304 if (!trace_dumping_enabled_locked())
305 return;
306
307 if(!state) {
308 trace_dump_null();
309 return;
310 }
311
312 trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
313
314 trace_dump_member_begin("depth");
315 trace_dump_struct_begin("pipe_depth_state");
316 trace_dump_member(bool, &state->depth, enabled);
317 trace_dump_member(bool, &state->depth, writemask);
318 trace_dump_member(uint, &state->depth, func);
319 trace_dump_struct_end();
320 trace_dump_member_end();
321
322 trace_dump_member_begin("stencil");
323 trace_dump_array_begin();
324 for(i = 0; i < Elements(state->stencil); ++i) {
325 trace_dump_elem_begin();
326 trace_dump_struct_begin("pipe_stencil_state");
327 trace_dump_member(bool, &state->stencil[i], enabled);
328 trace_dump_member(uint, &state->stencil[i], func);
329 trace_dump_member(uint, &state->stencil[i], fail_op);
330 trace_dump_member(uint, &state->stencil[i], zpass_op);
331 trace_dump_member(uint, &state->stencil[i], zfail_op);
332 trace_dump_member(uint, &state->stencil[i], valuemask);
333 trace_dump_member(uint, &state->stencil[i], writemask);
334 trace_dump_struct_end();
335 trace_dump_elem_end();
336 }
337 trace_dump_array_end();
338 trace_dump_member_end();
339
340 trace_dump_member_begin("alpha");
341 trace_dump_struct_begin("pipe_alpha_state");
342 trace_dump_member(bool, &state->alpha, enabled);
343 trace_dump_member(uint, &state->alpha, func);
344 trace_dump_member(float, &state->alpha, ref_value);
345 trace_dump_struct_end();
346 trace_dump_member_end();
347
348 trace_dump_struct_end();
349 }
350
trace_dump_rt_blend_state(const struct pipe_rt_blend_state * state)351 static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state)
352 {
353 trace_dump_struct_begin("pipe_rt_blend_state");
354
355 trace_dump_member(uint, state, blend_enable);
356
357 trace_dump_member(uint, state, rgb_func);
358 trace_dump_member(uint, state, rgb_src_factor);
359 trace_dump_member(uint, state, rgb_dst_factor);
360
361 trace_dump_member(uint, state, alpha_func);
362 trace_dump_member(uint, state, alpha_src_factor);
363 trace_dump_member(uint, state, alpha_dst_factor);
364
365 trace_dump_member(uint, state, colormask);
366
367 trace_dump_struct_end();
368 }
369
trace_dump_blend_state(const struct pipe_blend_state * state)370 void trace_dump_blend_state(const struct pipe_blend_state *state)
371 {
372 unsigned valid_entries = 1;
373
374 if (!trace_dumping_enabled_locked())
375 return;
376
377 if(!state) {
378 trace_dump_null();
379 return;
380 }
381
382 trace_dump_struct_begin("pipe_blend_state");
383
384 trace_dump_member(bool, state, dither);
385
386 trace_dump_member(bool, state, logicop_enable);
387 trace_dump_member(uint, state, logicop_func);
388
389 trace_dump_member(bool, state, independent_blend_enable);
390
391 trace_dump_member_begin("rt");
392 if (state->independent_blend_enable)
393 valid_entries = PIPE_MAX_COLOR_BUFS;
394 trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
395 trace_dump_member_end();
396
397 trace_dump_struct_end();
398 }
399
400
trace_dump_blend_color(const struct pipe_blend_color * state)401 void trace_dump_blend_color(const struct pipe_blend_color *state)
402 {
403 if (!trace_dumping_enabled_locked())
404 return;
405
406 if(!state) {
407 trace_dump_null();
408 return;
409 }
410
411 trace_dump_struct_begin("pipe_blend_color");
412
413 trace_dump_member_array(float, state, color);
414
415 trace_dump_struct_end();
416 }
417
trace_dump_stencil_ref(const struct pipe_stencil_ref * state)418 void trace_dump_stencil_ref(const struct pipe_stencil_ref *state)
419 {
420 if (!trace_dumping_enabled_locked())
421 return;
422
423 if(!state) {
424 trace_dump_null();
425 return;
426 }
427
428 trace_dump_struct_begin("pipe_stencil_ref");
429
430 trace_dump_member_array(uint, state, ref_value);
431
432 trace_dump_struct_end();
433 }
434
trace_dump_framebuffer_state(const struct pipe_framebuffer_state * state)435 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
436 {
437 if (!trace_dumping_enabled_locked())
438 return;
439
440 trace_dump_struct_begin("pipe_framebuffer_state");
441
442 trace_dump_member(uint, state, width);
443 trace_dump_member(uint, state, height);
444 trace_dump_member(uint, state, nr_cbufs);
445 trace_dump_member_array(ptr, state, cbufs);
446 trace_dump_member(ptr, state, zsbuf);
447
448 trace_dump_struct_end();
449 }
450
451
trace_dump_sampler_state(const struct pipe_sampler_state * state)452 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
453 {
454 if (!trace_dumping_enabled_locked())
455 return;
456
457 if(!state) {
458 trace_dump_null();
459 return;
460 }
461
462 trace_dump_struct_begin("pipe_sampler_state");
463
464 trace_dump_member(uint, state, wrap_s);
465 trace_dump_member(uint, state, wrap_t);
466 trace_dump_member(uint, state, wrap_r);
467 trace_dump_member(uint, state, min_img_filter);
468 trace_dump_member(uint, state, min_mip_filter);
469 trace_dump_member(uint, state, mag_img_filter);
470 trace_dump_member(uint, state, compare_mode);
471 trace_dump_member(uint, state, compare_func);
472 trace_dump_member(bool, state, normalized_coords);
473 trace_dump_member(uint, state, max_anisotropy);
474 trace_dump_member(float, state, lod_bias);
475 trace_dump_member(float, state, min_lod);
476 trace_dump_member(float, state, max_lod);
477 trace_dump_member_array(float, state, border_color.f);
478
479 trace_dump_struct_end();
480 }
481
482
trace_dump_sampler_view_template(const struct pipe_sampler_view * state,enum pipe_texture_target target)483 void trace_dump_sampler_view_template(const struct pipe_sampler_view *state,
484 enum pipe_texture_target target)
485 {
486 if (!trace_dumping_enabled_locked())
487 return;
488
489 if(!state) {
490 trace_dump_null();
491 return;
492 }
493
494 trace_dump_struct_begin("pipe_sampler_view");
495
496 trace_dump_member(format, state, format);
497
498 trace_dump_member_begin("u");
499 trace_dump_struct_begin(""); /* anonymous */
500 if (target == PIPE_BUFFER) {
501 trace_dump_member_begin("buf");
502 trace_dump_struct_begin(""); /* anonymous */
503 trace_dump_member(uint, &state->u.buf, first_element);
504 trace_dump_member(uint, &state->u.buf, last_element);
505 trace_dump_struct_end(); /* anonymous */
506 trace_dump_member_end(); /* buf */
507 } else {
508 trace_dump_member_begin("tex");
509 trace_dump_struct_begin(""); /* anonymous */
510 trace_dump_member(uint, &state->u.tex, first_layer);
511 trace_dump_member(uint, &state->u.tex, last_layer);
512 trace_dump_member(uint, &state->u.tex, first_level);
513 trace_dump_member(uint, &state->u.tex, last_level);
514 trace_dump_struct_end(); /* anonymous */
515 trace_dump_member_end(); /* tex */
516 }
517 trace_dump_struct_end(); /* anonymous */
518 trace_dump_member_end(); /* u */
519
520 trace_dump_member(uint, state, swizzle_r);
521 trace_dump_member(uint, state, swizzle_g);
522 trace_dump_member(uint, state, swizzle_b);
523 trace_dump_member(uint, state, swizzle_a);
524
525 trace_dump_struct_end();
526 }
527
528
trace_dump_surface_template(const struct pipe_surface * state,enum pipe_texture_target target)529 void trace_dump_surface_template(const struct pipe_surface *state,
530 enum pipe_texture_target target)
531 {
532 if (!trace_dumping_enabled_locked())
533 return;
534
535 if(!state) {
536 trace_dump_null();
537 return;
538 }
539
540 trace_dump_struct_begin("pipe_surface");
541
542 trace_dump_member(format, state, format);
543 trace_dump_member(uint, state, width);
544 trace_dump_member(uint, state, height);
545
546 trace_dump_member(uint, state, usage);
547
548 trace_dump_member_begin("u");
549 trace_dump_struct_begin(""); /* anonymous */
550 if (target == PIPE_BUFFER) {
551 trace_dump_member_begin("buf");
552 trace_dump_struct_begin(""); /* anonymous */
553 trace_dump_member(uint, &state->u.buf, first_element);
554 trace_dump_member(uint, &state->u.buf, last_element);
555 trace_dump_struct_end(); /* anonymous */
556 trace_dump_member_end(); /* buf */
557 } else {
558 trace_dump_member_begin("tex");
559 trace_dump_struct_begin(""); /* anonymous */
560 trace_dump_member(uint, &state->u.tex, level);
561 trace_dump_member(uint, &state->u.tex, first_layer);
562 trace_dump_member(uint, &state->u.tex, last_layer);
563 trace_dump_struct_end(); /* anonymous */
564 trace_dump_member_end(); /* tex */
565 }
566 trace_dump_struct_end(); /* anonymous */
567 trace_dump_member_end(); /* u */
568
569 trace_dump_struct_end();
570 }
571
572
trace_dump_transfer(const struct pipe_transfer * state)573 void trace_dump_transfer(const struct pipe_transfer *state)
574 {
575 if (!trace_dumping_enabled_locked())
576 return;
577
578 if(!state) {
579 trace_dump_null();
580 return;
581 }
582
583 trace_dump_struct_begin("pipe_transfer");
584
585 trace_dump_member(uint, state, box.x);
586 trace_dump_member(uint, state, box.y);
587 trace_dump_member(uint, state, box.z);
588 trace_dump_member(uint, state, box.width);
589 trace_dump_member(uint, state, box.height);
590 trace_dump_member(uint, state, box.depth);
591
592 trace_dump_member(uint, state, stride);
593 trace_dump_member(uint, state, layer_stride);
594 trace_dump_member(uint, state, usage);
595
596 trace_dump_member(ptr, state, resource);
597
598 trace_dump_struct_end();
599 }
600
601
trace_dump_vertex_buffer(const struct pipe_vertex_buffer * state)602 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
603 {
604 if (!trace_dumping_enabled_locked())
605 return;
606
607 if(!state) {
608 trace_dump_null();
609 return;
610 }
611
612 trace_dump_struct_begin("pipe_vertex_buffer");
613
614 trace_dump_member(uint, state, stride);
615 trace_dump_member(uint, state, buffer_offset);
616 trace_dump_member(resource_ptr, state, buffer);
617
618 trace_dump_struct_end();
619 }
620
621
trace_dump_index_buffer(const struct pipe_index_buffer * state)622 void trace_dump_index_buffer(const struct pipe_index_buffer *state)
623 {
624 if (!trace_dumping_enabled_locked())
625 return;
626
627 if(!state) {
628 trace_dump_null();
629 return;
630 }
631
632 trace_dump_struct_begin("pipe_index_buffer");
633
634 trace_dump_member(uint, state, index_size);
635 trace_dump_member(uint, state, offset);
636 trace_dump_member(resource_ptr, state, buffer);
637
638 trace_dump_struct_end();
639 }
640
641
trace_dump_vertex_element(const struct pipe_vertex_element * state)642 void trace_dump_vertex_element(const struct pipe_vertex_element *state)
643 {
644 if (!trace_dumping_enabled_locked())
645 return;
646
647 if(!state) {
648 trace_dump_null();
649 return;
650 }
651
652 trace_dump_struct_begin("pipe_vertex_element");
653
654 trace_dump_member(uint, state, src_offset);
655
656 trace_dump_member(uint, state, vertex_buffer_index);
657
658 trace_dump_member(format, state, src_format);
659
660 trace_dump_struct_end();
661 }
662
663
trace_dump_draw_info(const struct pipe_draw_info * state)664 void trace_dump_draw_info(const struct pipe_draw_info *state)
665 {
666 if (!trace_dumping_enabled_locked())
667 return;
668
669 if(!state) {
670 trace_dump_null();
671 return;
672 }
673
674 trace_dump_struct_begin("pipe_draw_info");
675
676 trace_dump_member(bool, state, indexed);
677
678 trace_dump_member(uint, state, mode);
679 trace_dump_member(uint, state, start);
680 trace_dump_member(uint, state, count);
681
682 trace_dump_member(uint, state, start_instance);
683 trace_dump_member(uint, state, instance_count);
684
685 trace_dump_member(int, state, index_bias);
686 trace_dump_member(uint, state, min_index);
687 trace_dump_member(uint, state, max_index);
688
689 trace_dump_member(bool, state, primitive_restart);
690 trace_dump_member(uint, state, restart_index);
691
692 trace_dump_member(ptr, state, count_from_stream_output);
693
694 trace_dump_struct_end();
695 }
696