• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2008 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 
29 #include "pipe/p_compiler.h"
30 #include "util/u_memory.h"
31 #include "util/format/u_format.h"
32 #include "tgsi/tgsi_dump.h"
33 
34 #include "tr_dump.h"
35 #include "tr_dump_defines.h"
36 #include "tr_dump_state.h"
37 #include "tr_util.h"
38 
39 
trace_dump_resource_template(const struct pipe_resource * templat)40 void trace_dump_resource_template(const struct pipe_resource *templat)
41 {
42    if (!trace_dumping_enabled_locked())
43       return;
44 
45    if (!templat) {
46       trace_dump_null();
47       return;
48    }
49 
50    trace_dump_struct_begin("pipe_resource");
51 
52    trace_dump_member_begin("target");
53    trace_dump_enum(tr_util_pipe_texture_target_name(templat->target));
54    trace_dump_member_end();
55 
56    trace_dump_member(format, templat, format);
57 
58    trace_dump_member_begin("width");
59    trace_dump_uint(templat->width0);
60    trace_dump_member_end();
61 
62    trace_dump_member_begin("height");
63    trace_dump_uint(templat->height0);
64    trace_dump_member_end();
65 
66    trace_dump_member_begin("depth");
67    trace_dump_uint(templat->depth0);
68    trace_dump_member_end();
69 
70    trace_dump_member_begin("array_size");
71    trace_dump_uint(templat->array_size);
72    trace_dump_member_end();
73 
74    trace_dump_member(uint, templat, last_level);
75    trace_dump_member(uint, templat, nr_samples);
76    trace_dump_member(uint, templat, nr_storage_samples);
77    trace_dump_member(uint, templat, usage);
78    trace_dump_member(uint, templat, bind);
79    trace_dump_member(uint, templat, flags);
80 
81    trace_dump_struct_end();
82 }
83 
84 
trace_dump_box(const struct pipe_box * box)85 void trace_dump_box(const struct pipe_box *box)
86 {
87    if (!trace_dumping_enabled_locked())
88       return;
89 
90    if (!box) {
91       trace_dump_null();
92       return;
93    }
94 
95    trace_dump_struct_begin("pipe_box");
96 
97    trace_dump_member(int, box, x);
98    trace_dump_member(int, box, y);
99    trace_dump_member(int, box, z);
100    trace_dump_member(int, box, width);
101    trace_dump_member(int, box, height);
102    trace_dump_member(int, box, depth);
103 
104    trace_dump_struct_end();
105 }
106 
107 
trace_dump_rasterizer_state(const struct pipe_rasterizer_state * state)108 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
109 {
110    if (!trace_dumping_enabled_locked())
111       return;
112 
113    if (!state) {
114       trace_dump_null();
115       return;
116    }
117 
118    trace_dump_struct_begin("pipe_rasterizer_state");
119 
120    trace_dump_member(bool, state, flatshade);
121    trace_dump_member(bool, state, light_twoside);
122    trace_dump_member(bool, state, clamp_vertex_color);
123    trace_dump_member(bool, state, clamp_fragment_color);
124    trace_dump_member(uint, state, front_ccw);
125    trace_dump_member(uint, state, cull_face);
126    trace_dump_member(uint, state, fill_front);
127    trace_dump_member(uint, state, fill_back);
128    trace_dump_member(bool, state, offset_point);
129    trace_dump_member(bool, state, offset_line);
130    trace_dump_member(bool, state, offset_tri);
131    trace_dump_member(bool, state, scissor);
132    trace_dump_member(bool, state, poly_smooth);
133    trace_dump_member(bool, state, poly_stipple_enable);
134    trace_dump_member(bool, state, point_smooth);
135    trace_dump_member(bool, state, sprite_coord_mode);
136    trace_dump_member(bool, state, point_quad_rasterization);
137    trace_dump_member(bool, state, point_size_per_vertex);
138    trace_dump_member(bool, state, multisample);
139    trace_dump_member(bool, state, no_ms_sample_mask_out);
140    trace_dump_member(bool, state, force_persample_interp);
141    trace_dump_member(bool, state, line_smooth);
142    trace_dump_member(bool, state, line_stipple_enable);
143    trace_dump_member(bool, state, line_last_pixel);
144 
145    trace_dump_member(bool, state, flatshade_first);
146 
147    trace_dump_member(bool, state, half_pixel_center);
148    trace_dump_member(bool, state, bottom_edge_rule);
149 
150    trace_dump_member(bool, state, rasterizer_discard);
151 
152    trace_dump_member(bool, state, depth_clamp);
153    trace_dump_member(bool, state, depth_clip_near);
154    trace_dump_member(bool, state, depth_clip_far);
155 
156    trace_dump_member(bool, state, clip_halfz);
157 
158    trace_dump_member(uint, state, clip_plane_enable);
159 
160    trace_dump_member(uint, state, line_stipple_factor);
161    trace_dump_member(uint, state, line_stipple_pattern);
162 
163    trace_dump_member(uint, state, sprite_coord_enable);
164 
165    trace_dump_member(float, state, line_width);
166    trace_dump_member(float, state, point_size);
167    trace_dump_member(float, state, offset_units);
168    trace_dump_member(float, state, offset_scale);
169    trace_dump_member(float, state, offset_clamp);
170 
171    trace_dump_struct_end();
172 }
173 
174 
trace_dump_poly_stipple(const struct pipe_poly_stipple * state)175 void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
176 {
177    if (!trace_dumping_enabled_locked())
178       return;
179 
180    if (!state) {
181       trace_dump_null();
182       return;
183    }
184 
185    trace_dump_struct_begin("pipe_poly_stipple");
186 
187    trace_dump_member_begin("stipple");
188    trace_dump_array(uint,
189                     state->stipple,
190                     ARRAY_SIZE(state->stipple));
191    trace_dump_member_end();
192 
193    trace_dump_struct_end();
194 }
195 
196 
trace_dump_viewport_state(const struct pipe_viewport_state * state)197 void trace_dump_viewport_state(const struct pipe_viewport_state *state)
198 {
199    if (!trace_dumping_enabled_locked())
200       return;
201 
202    if (!state) {
203       trace_dump_null();
204       return;
205    }
206 
207    trace_dump_struct_begin("pipe_viewport_state");
208 
209    trace_dump_member_array(float, state, scale);
210    trace_dump_member_array(float, state, translate);
211 
212    trace_dump_struct_end();
213 }
214 
215 
trace_dump_scissor_state(const struct pipe_scissor_state * state)216 void trace_dump_scissor_state(const struct pipe_scissor_state *state)
217 {
218    if (!trace_dumping_enabled_locked())
219       return;
220 
221    if (!state) {
222       trace_dump_null();
223       return;
224    }
225 
226    trace_dump_struct_begin("pipe_scissor_state");
227 
228    trace_dump_member(uint, state, minx);
229    trace_dump_member(uint, state, miny);
230    trace_dump_member(uint, state, maxx);
231    trace_dump_member(uint, state, maxy);
232 
233    trace_dump_struct_end();
234 }
235 
236 
trace_dump_clip_state(const struct pipe_clip_state * state)237 void trace_dump_clip_state(const struct pipe_clip_state *state)
238 {
239    unsigned i;
240 
241    if (!trace_dumping_enabled_locked())
242       return;
243 
244    if (!state) {
245       trace_dump_null();
246       return;
247    }
248 
249    trace_dump_struct_begin("pipe_clip_state");
250 
251    trace_dump_member_begin("ucp");
252    trace_dump_array_begin();
253    for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
254       trace_dump_elem_begin();
255       trace_dump_array(float, state->ucp[i], 4);
256       trace_dump_elem_end();
257    }
258    trace_dump_array_end();
259    trace_dump_member_end();
260 
261    trace_dump_struct_end();
262 }
263 
264 
trace_dump_shader_state(const struct pipe_shader_state * state)265 void trace_dump_shader_state(const struct pipe_shader_state *state)
266 {
267    unsigned i;
268 
269    if (!trace_dumping_enabled_locked())
270       return;
271 
272    if (!state) {
273       trace_dump_null();
274       return;
275    }
276 
277 
278    trace_dump_struct_begin("pipe_shader_state");
279 
280    trace_dump_member(uint, state, type);
281 
282    trace_dump_member_begin("tokens");
283    if (state->tokens) {
284       static char str[64 * 1024];
285       tgsi_dump_str(state->tokens, 0, str, sizeof(str));
286       trace_dump_string(str);
287    } else {
288       trace_dump_null();
289    }
290    trace_dump_member_end();
291 
292    trace_dump_member_begin("ir");
293    if (state->type == PIPE_SHADER_IR_NIR) {
294       trace_dump_nir(state->ir.nir);
295    } else {
296       trace_dump_null();
297    }
298    trace_dump_member_end();
299 
300    trace_dump_member_begin("stream_output");
301    trace_dump_struct_begin("pipe_stream_output_info");
302    trace_dump_member(uint, &state->stream_output, num_outputs);
303    trace_dump_member_array(uint, &state->stream_output, stride);
304    trace_dump_member_begin("output");
305    trace_dump_array_begin();
306    for(i = 0; i < state->stream_output.num_outputs; ++i) {
307       trace_dump_elem_begin();
308       trace_dump_struct_begin(""); /* anonymous */
309       trace_dump_member(uint, &state->stream_output.output[i], register_index);
310       trace_dump_member(uint, &state->stream_output.output[i], start_component);
311       trace_dump_member(uint, &state->stream_output.output[i], num_components);
312       trace_dump_member(uint, &state->stream_output.output[i], output_buffer);
313       trace_dump_member(uint, &state->stream_output.output[i], dst_offset);
314       trace_dump_member(uint, &state->stream_output.output[i], stream);
315       trace_dump_struct_end();
316       trace_dump_elem_end();
317    }
318    trace_dump_array_end();
319    trace_dump_member_end(); // output
320    trace_dump_struct_end();
321    trace_dump_member_end(); // stream_output
322 
323    trace_dump_struct_end();
324 }
325 
326 
trace_dump_compute_state(const struct pipe_compute_state * state)327 void trace_dump_compute_state(const struct pipe_compute_state *state)
328 {
329    if (!trace_dumping_enabled_locked())
330       return;
331 
332    if (!state) {
333       trace_dump_null();
334       return;
335    }
336 
337    trace_dump_struct_begin("pipe_compute_state");
338 
339    trace_dump_member(uint, state, ir_type);
340 
341    trace_dump_member_begin("prog");
342    if (state->prog && state->ir_type == PIPE_SHADER_IR_TGSI) {
343       static char str[64 * 1024];
344       tgsi_dump_str(state->prog, 0, str, sizeof(str));
345       trace_dump_string(str);
346    } else {
347       trace_dump_null();
348    }
349    trace_dump_member_end();
350 
351    trace_dump_member(uint, state, req_local_mem);
352    trace_dump_member(uint, state, req_private_mem);
353    trace_dump_member(uint, state, req_input_mem);
354 
355    trace_dump_struct_end();
356 }
357 
358 
trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state * state)359 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
360 {
361    unsigned i;
362 
363    if (!trace_dumping_enabled_locked())
364       return;
365 
366    if (!state) {
367       trace_dump_null();
368       return;
369    }
370 
371    trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
372 
373    trace_dump_member(bool, state, depth_enabled);
374    trace_dump_member(bool, state, depth_writemask);
375    trace_dump_member(uint, state, depth_func);
376 
377    trace_dump_member_begin("stencil");
378    trace_dump_array_begin();
379    for(i = 0; i < ARRAY_SIZE(state->stencil); ++i) {
380       trace_dump_elem_begin();
381       trace_dump_struct_begin("pipe_stencil_state");
382       trace_dump_member(bool, &state->stencil[i], enabled);
383       trace_dump_member(uint, &state->stencil[i], func);
384       trace_dump_member(uint, &state->stencil[i], fail_op);
385       trace_dump_member(uint, &state->stencil[i], zpass_op);
386       trace_dump_member(uint, &state->stencil[i], zfail_op);
387       trace_dump_member(uint, &state->stencil[i], valuemask);
388       trace_dump_member(uint, &state->stencil[i], writemask);
389       trace_dump_struct_end();
390       trace_dump_elem_end();
391    }
392    trace_dump_array_end();
393    trace_dump_member_end();
394 
395    trace_dump_member(bool, state, alpha_enabled);
396    trace_dump_member(uint, state, alpha_func);
397    trace_dump_member(float, state, alpha_ref_value);
398 
399    trace_dump_struct_end();
400 }
401 
trace_dump_rt_blend_state(const struct pipe_rt_blend_state * state)402 static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state)
403 {
404    trace_dump_struct_begin("pipe_rt_blend_state");
405 
406    trace_dump_member(uint, state, blend_enable);
407 
408    trace_dump_member(uint, state, rgb_func);
409    trace_dump_member(uint, state, rgb_src_factor);
410    trace_dump_member(uint, state, rgb_dst_factor);
411 
412    trace_dump_member(uint, state, alpha_func);
413    trace_dump_member(uint, state, alpha_src_factor);
414    trace_dump_member(uint, state, alpha_dst_factor);
415 
416    trace_dump_member(uint, state, colormask);
417 
418    trace_dump_struct_end();
419 }
420 
trace_dump_blend_state(const struct pipe_blend_state * state)421 void trace_dump_blend_state(const struct pipe_blend_state *state)
422 {
423    unsigned valid_entries = 1;
424 
425    if (!trace_dumping_enabled_locked())
426       return;
427 
428    if (!state) {
429       trace_dump_null();
430       return;
431    }
432 
433    trace_dump_struct_begin("pipe_blend_state");
434 
435    trace_dump_member(bool, state, independent_blend_enable);
436    trace_dump_member(bool, state, logicop_enable);
437    trace_dump_member(uint, state, logicop_func);
438    trace_dump_member(bool, state, dither);
439    trace_dump_member(bool, state, alpha_to_coverage);
440    trace_dump_member(bool, state, alpha_to_coverage_dither);
441    trace_dump_member(bool, state, alpha_to_one);
442    trace_dump_member(uint, state, max_rt);
443    trace_dump_member(uint, state, advanced_blend_func);
444 
445    trace_dump_member_begin("rt");
446    if (state->independent_blend_enable)
447       valid_entries = state->max_rt + 1;
448    trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
449    trace_dump_member_end();
450 
451    trace_dump_struct_end();
452 }
453 
454 
trace_dump_blend_color(const struct pipe_blend_color * state)455 void trace_dump_blend_color(const struct pipe_blend_color *state)
456 {
457    if (!trace_dumping_enabled_locked())
458       return;
459 
460    if (!state) {
461       trace_dump_null();
462       return;
463    }
464 
465    trace_dump_struct_begin("pipe_blend_color");
466 
467    trace_dump_member_array(float, state, color);
468 
469    trace_dump_struct_end();
470 }
471 
trace_dump_stencil_ref(const struct pipe_stencil_ref * state)472 void trace_dump_stencil_ref(const struct pipe_stencil_ref *state)
473 {
474    if (!trace_dumping_enabled_locked())
475       return;
476 
477    if (!state) {
478       trace_dump_null();
479       return;
480    }
481 
482    trace_dump_struct_begin("pipe_stencil_ref");
483 
484    trace_dump_member_array(uint, state, ref_value);
485 
486    trace_dump_struct_end();
487 }
488 
trace_dump_framebuffer_state(const struct pipe_framebuffer_state * state)489 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
490 {
491    if (!trace_dumping_enabled_locked())
492       return;
493 
494    trace_dump_struct_begin("pipe_framebuffer_state");
495 
496    trace_dump_member(uint, state, width);
497    trace_dump_member(uint, state, height);
498    trace_dump_member(uint, state, samples);
499    trace_dump_member(uint, state, layers);
500    trace_dump_member(uint, state, nr_cbufs);
501    trace_dump_member_array(ptr, state, cbufs);
502    trace_dump_member(ptr, state, zsbuf);
503 
504    trace_dump_struct_end();
505 }
506 
trace_dump_framebuffer_state_deep(const struct pipe_framebuffer_state * state)507 void trace_dump_framebuffer_state_deep(const struct pipe_framebuffer_state *state)
508 {
509    if (!trace_dumping_enabled_locked())
510       return;
511 
512    trace_dump_struct_begin("pipe_framebuffer_state");
513 
514    trace_dump_member(uint, state, width);
515    trace_dump_member(uint, state, height);
516    trace_dump_member(uint, state, samples);
517    trace_dump_member(uint, state, layers);
518    trace_dump_member(uint, state, nr_cbufs);
519    trace_dump_member_array(surface, state, cbufs);
520    trace_dump_member(surface, state, zsbuf);
521 
522    trace_dump_struct_end();
523 }
524 
525 
trace_dump_sampler_state(const struct pipe_sampler_state * state)526 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
527 {
528    if (!trace_dumping_enabled_locked())
529       return;
530 
531    if (!state) {
532       trace_dump_null();
533       return;
534    }
535 
536    trace_dump_struct_begin("pipe_sampler_state");
537 
538    trace_dump_member(uint, state, wrap_s);
539    trace_dump_member(uint, state, wrap_t);
540    trace_dump_member(uint, state, wrap_r);
541    trace_dump_member(uint, state, min_img_filter);
542    trace_dump_member(uint, state, min_mip_filter);
543    trace_dump_member(uint, state, mag_img_filter);
544    trace_dump_member(uint, state, compare_mode);
545    trace_dump_member(uint, state, compare_func);
546    trace_dump_member(bool, state, normalized_coords);
547    trace_dump_member(uint, state, max_anisotropy);
548    trace_dump_member(bool, state, seamless_cube_map);
549    trace_dump_member(float, state, lod_bias);
550    trace_dump_member(float, state, min_lod);
551    trace_dump_member(float, state, max_lod);
552    trace_dump_member_array(float, state, border_color.f);
553    trace_dump_member(format, state, border_color_format);
554 
555    trace_dump_struct_end();
556 }
557 
558 
trace_dump_sampler_view_template(const struct pipe_sampler_view * state)559 void trace_dump_sampler_view_template(const struct pipe_sampler_view *state)
560 {
561    if (!trace_dumping_enabled_locked())
562       return;
563 
564    if (!state) {
565       trace_dump_null();
566       return;
567    }
568 
569    trace_dump_struct_begin("pipe_sampler_view");
570 
571    trace_dump_member(format, state, format);
572 
573    trace_dump_member_begin("target");
574    trace_dump_enum(tr_util_pipe_texture_target_name(state->target));
575    trace_dump_member_end();
576 
577    trace_dump_member(ptr, state, texture);
578 
579    trace_dump_member_begin("u");
580    trace_dump_struct_begin(""); /* anonymous */
581    if (state->target == PIPE_BUFFER) {
582       trace_dump_member_begin("buf");
583       trace_dump_struct_begin(""); /* anonymous */
584       trace_dump_member(uint, &state->u.buf, offset);
585       trace_dump_member(uint, &state->u.buf, size);
586       trace_dump_struct_end(); /* anonymous */
587       trace_dump_member_end(); /* buf */
588    } else {
589       trace_dump_member_begin("tex");
590       trace_dump_struct_begin(""); /* anonymous */
591       trace_dump_member(uint, &state->u.tex, first_layer);
592       trace_dump_member(uint, &state->u.tex, last_layer);
593       trace_dump_member(uint, &state->u.tex, first_level);
594       trace_dump_member(uint, &state->u.tex, last_level);
595       trace_dump_struct_end(); /* anonymous */
596       trace_dump_member_end(); /* tex */
597    }
598    trace_dump_struct_end(); /* anonymous */
599    trace_dump_member_end(); /* u */
600 
601    trace_dump_member(uint, state, swizzle_r);
602    trace_dump_member(uint, state, swizzle_g);
603    trace_dump_member(uint, state, swizzle_b);
604    trace_dump_member(uint, state, swizzle_a);
605 
606    trace_dump_struct_end();
607 }
608 
609 
trace_dump_surface(const struct pipe_surface * surface)610 void trace_dump_surface(const struct pipe_surface *surface)
611 {
612    trace_dump_surface_template(surface, surface ? surface->texture->target : 0);
613 }
614 
615 
trace_dump_surface_template(const struct pipe_surface * state,enum pipe_texture_target target)616 void trace_dump_surface_template(const struct pipe_surface *state,
617                                  enum pipe_texture_target target)
618 {
619    if (!trace_dumping_enabled_locked())
620       return;
621 
622    if (!state) {
623       trace_dump_null();
624       return;
625    }
626 
627    trace_dump_struct_begin("pipe_surface");
628 
629    trace_dump_member(format, state, format);
630    trace_dump_member(ptr, state, texture);
631    trace_dump_member(uint, state, width);
632    trace_dump_member(uint, state, height);
633 
634    trace_dump_member_begin("target");
635    trace_dump_enum(tr_util_pipe_texture_target_name(target));
636    trace_dump_member_end();
637 
638    trace_dump_member_begin("u");
639    trace_dump_struct_begin(""); /* anonymous */
640    if (target == PIPE_BUFFER) {
641       trace_dump_member_begin("buf");
642       trace_dump_struct_begin(""); /* anonymous */
643       trace_dump_member(uint, &state->u.buf, first_element);
644       trace_dump_member(uint, &state->u.buf, last_element);
645       trace_dump_struct_end(); /* anonymous */
646       trace_dump_member_end(); /* buf */
647    } else {
648       trace_dump_member_begin("tex");
649       trace_dump_struct_begin(""); /* anonymous */
650       trace_dump_member(uint, &state->u.tex, level);
651       trace_dump_member(uint, &state->u.tex, first_layer);
652       trace_dump_member(uint, &state->u.tex, last_layer);
653       trace_dump_struct_end(); /* anonymous */
654       trace_dump_member_end(); /* tex */
655    }
656    trace_dump_struct_end(); /* anonymous */
657    trace_dump_member_end(); /* u */
658 
659    trace_dump_struct_end();
660 }
661 
662 
trace_dump_transfer(const struct pipe_transfer * state)663 void trace_dump_transfer(const struct pipe_transfer *state)
664 {
665    if (!trace_dumping_enabled_locked())
666       return;
667 
668    if (!state) {
669       trace_dump_null();
670       return;
671    }
672 
673    trace_dump_struct_begin("pipe_transfer");
674 
675    trace_dump_member(uint, state, box.x);
676    trace_dump_member(uint, state, box.y);
677    trace_dump_member(uint, state, box.z);
678    trace_dump_member(uint, state, box.width);
679    trace_dump_member(uint, state, box.height);
680    trace_dump_member(uint, state, box.depth);
681 
682    trace_dump_member(uint, state, stride);
683    trace_dump_member(uint, state, layer_stride);
684    trace_dump_member(uint, state, usage);
685 
686    trace_dump_member(ptr, state, resource);
687 
688    trace_dump_struct_end();
689 }
690 
691 
trace_dump_vertex_buffer(const struct pipe_vertex_buffer * state)692 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
693 {
694    if (!trace_dumping_enabled_locked())
695       return;
696 
697    if (!state) {
698       trace_dump_null();
699       return;
700    }
701 
702    trace_dump_struct_begin("pipe_vertex_buffer");
703 
704    trace_dump_member(uint, state, stride);
705    trace_dump_member(bool, state, is_user_buffer);
706    trace_dump_member(uint, state, buffer_offset);
707    trace_dump_member(ptr, state, buffer.resource);
708 
709    trace_dump_struct_end();
710 }
711 
712 
trace_dump_vertex_element(const struct pipe_vertex_element * state)713 void trace_dump_vertex_element(const struct pipe_vertex_element *state)
714 {
715    if (!trace_dumping_enabled_locked())
716       return;
717 
718    if (!state) {
719       trace_dump_null();
720       return;
721    }
722 
723    trace_dump_struct_begin("pipe_vertex_element");
724 
725    trace_dump_member(uint, state, src_offset);
726 
727    trace_dump_member(uint, state, vertex_buffer_index);
728 
729    trace_dump_member(uint, state, instance_divisor);
730 
731    trace_dump_member(bool, state, dual_slot);
732 
733    trace_dump_member(format, state, src_format);
734 
735    trace_dump_struct_end();
736 }
737 
738 
trace_dump_constant_buffer(const struct pipe_constant_buffer * state)739 void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
740 {
741    if (!trace_dumping_enabled_locked())
742       return;
743 
744    if (!state) {
745       trace_dump_null();
746       return;
747    }
748 
749    trace_dump_struct_begin("pipe_constant_buffer");
750    trace_dump_member(ptr, state, buffer);
751    trace_dump_member(uint, state, buffer_offset);
752    trace_dump_member(uint, state, buffer_size);
753    trace_dump_struct_end();
754 }
755 
756 
trace_dump_shader_buffer(const struct pipe_shader_buffer * state)757 void trace_dump_shader_buffer(const struct pipe_shader_buffer *state)
758 {
759    if (!trace_dumping_enabled_locked())
760       return;
761 
762    if(!state) {
763       trace_dump_null();
764       return;
765    }
766 
767    trace_dump_struct_begin("pipe_shader_buffer");
768    trace_dump_member(ptr, state, buffer);
769    trace_dump_member(uint, state, buffer_offset);
770    trace_dump_member(uint, state, buffer_size);
771    trace_dump_struct_end();
772 }
773 
774 
trace_dump_image_view(const struct pipe_image_view * state)775 void trace_dump_image_view(const struct pipe_image_view *state)
776 {
777    if (!trace_dumping_enabled_locked())
778       return;
779 
780    if (!state || !state->resource) {
781       trace_dump_null();
782       return;
783    }
784 
785    trace_dump_struct_begin("pipe_image_view");
786    trace_dump_member(ptr, state, resource);
787    trace_dump_member(format, state, format);
788    trace_dump_member(uint, state, access);
789 
790    trace_dump_member_begin("u");
791    trace_dump_struct_begin(""); /* anonymous */
792    if (state->resource->target == PIPE_BUFFER) {
793       trace_dump_member_begin("buf");
794       trace_dump_struct_begin(""); /* anonymous */
795       trace_dump_member(uint, &state->u.buf, offset);
796       trace_dump_member(uint, &state->u.buf, size);
797       trace_dump_struct_end(); /* anonymous */
798       trace_dump_member_end(); /* buf */
799    } else {
800       trace_dump_member_begin("tex");
801       trace_dump_struct_begin(""); /* anonymous */
802       trace_dump_member(uint, &state->u.tex, first_layer);
803       trace_dump_member(uint, &state->u.tex, last_layer);
804       trace_dump_member(uint, &state->u.tex, level);
805       trace_dump_struct_end(); /* anonymous */
806       trace_dump_member_end(); /* tex */
807    }
808    trace_dump_struct_end(); /* anonymous */
809    trace_dump_member_end(); /* u */
810 
811    trace_dump_struct_end();
812 }
813 
814 
trace_dump_memory_info(const struct pipe_memory_info * state)815 void trace_dump_memory_info(const struct pipe_memory_info *state)
816 {
817    if (!trace_dumping_enabled_locked())
818       return;
819 
820    if (!state) {
821       trace_dump_null();
822       return;
823    }
824 
825    trace_dump_struct_begin("pipe_memory_info");
826    trace_dump_member(uint, state, total_device_memory);
827    trace_dump_member(uint, state, avail_device_memory);
828    trace_dump_member(uint, state, total_staging_memory);
829    trace_dump_member(uint, state, avail_staging_memory);
830    trace_dump_member(uint, state, device_memory_evicted);
831    trace_dump_member(uint, state, nr_device_memory_evictions);
832    trace_dump_struct_end();
833 }
834 
trace_dump_draw_info(const struct pipe_draw_info * state)835 void trace_dump_draw_info(const struct pipe_draw_info *state)
836 {
837    if (!trace_dumping_enabled_locked())
838       return;
839 
840    if (!state) {
841       trace_dump_null();
842       return;
843    }
844 
845    trace_dump_struct_begin("pipe_draw_info");
846 
847    trace_dump_member(uint, state, index_size);
848    trace_dump_member(uint, state, has_user_indices);
849    trace_dump_member(uint, state, mode);
850    trace_dump_member(uint, state, start_instance);
851    trace_dump_member(uint, state, instance_count);
852 
853    trace_dump_member(uint, state, min_index);
854    trace_dump_member(uint, state, max_index);
855 
856    trace_dump_member(bool, state, primitive_restart);
857    trace_dump_member(uint, state, restart_index);
858 
859    trace_dump_member(ptr, state, index.resource);
860    trace_dump_struct_end();
861 }
862 
trace_dump_draw_vertex_state_info(struct pipe_draw_vertex_state_info state)863 void trace_dump_draw_vertex_state_info(struct pipe_draw_vertex_state_info state)
864 {
865    if (!trace_dumping_enabled_locked())
866       return;
867 
868    trace_dump_struct_begin("pipe_draw_vertex_state_info");
869    trace_dump_member(uint, &state, mode);
870    trace_dump_member(uint, &state, take_vertex_state_ownership);
871    trace_dump_struct_end();
872 }
873 
trace_dump_draw_start_count(const struct pipe_draw_start_count_bias * state)874 void trace_dump_draw_start_count(const struct pipe_draw_start_count_bias *state)
875 {
876    if (!trace_dumping_enabled_locked())
877       return;
878 
879    trace_dump_struct_begin("pipe_draw_start_count_bias");
880    trace_dump_member(uint, state, start);
881    trace_dump_member(uint, state, count);
882    trace_dump_member(int,  state, index_bias);
883    trace_dump_struct_end();
884 }
885 
trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info * state)886 void trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info *state)
887 {
888    if (!trace_dumping_enabled_locked())
889       return;
890 
891    if (!state) {
892       trace_dump_null();
893       return;
894    }
895 
896    trace_dump_struct_begin("pipe_draw_indirect_info");
897    trace_dump_member(uint, state, offset);
898    trace_dump_member(uint, state, stride);
899    trace_dump_member(uint, state, draw_count);
900    trace_dump_member(uint, state, indirect_draw_count_offset);
901    trace_dump_member(ptr, state, buffer);
902    trace_dump_member(ptr, state, indirect_draw_count);
903    trace_dump_member(ptr, state, count_from_stream_output);
904    trace_dump_struct_end();
905 }
906 
trace_dump_blit_info(const struct pipe_blit_info * info)907 void trace_dump_blit_info(const struct pipe_blit_info *info)
908 {
909    char mask[7];
910 
911    if (!trace_dumping_enabled_locked())
912       return;
913 
914    if (!info) {
915       trace_dump_null();
916       return;
917    }
918 
919    trace_dump_struct_begin("pipe_blit_info");
920 
921    trace_dump_member_begin("dst");
922    trace_dump_struct_begin("dst");
923    trace_dump_member(ptr, &info->dst, resource);
924    trace_dump_member(uint, &info->dst, level);
925    trace_dump_member(format, &info->dst, format);
926    trace_dump_member_begin("box");
927    trace_dump_box(&info->dst.box);
928    trace_dump_member_end();
929    trace_dump_struct_end();
930    trace_dump_member_end();
931 
932    trace_dump_member_begin("src");
933    trace_dump_struct_begin("src");
934    trace_dump_member(ptr, &info->src, resource);
935    trace_dump_member(uint, &info->src, level);
936    trace_dump_member(format, &info->src, format);
937    trace_dump_member_begin("box");
938    trace_dump_box(&info->src.box);
939    trace_dump_member_end();
940    trace_dump_struct_end();
941    trace_dump_member_end();
942 
943    mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-';
944    mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-';
945    mask[2] = (info->mask & PIPE_MASK_B) ? 'B' : '-';
946    mask[3] = (info->mask & PIPE_MASK_A) ? 'A' : '-';
947    mask[4] = (info->mask & PIPE_MASK_Z) ? 'Z' : '-';
948    mask[5] = (info->mask & PIPE_MASK_S) ? 'S' : '-';
949    mask[6] = 0;
950 
951    trace_dump_member_begin("mask");
952    trace_dump_string(mask);
953    trace_dump_member_end();
954    trace_dump_member(uint, info, filter);
955 
956    trace_dump_member(bool, info, scissor_enable);
957    trace_dump_member_begin("scissor");
958    trace_dump_scissor_state(&info->scissor);
959    trace_dump_member_end();
960 
961    trace_dump_struct_end();
962 }
963 
964 void
trace_dump_query_result(unsigned query_type,unsigned index,const union pipe_query_result * result)965 trace_dump_query_result(unsigned query_type, unsigned index,
966                         const union pipe_query_result *result)
967 {
968    if (!trace_dumping_enabled_locked())
969       return;
970 
971    if (!result) {
972       trace_dump_null();
973       return;
974    }
975 
976    switch (query_type) {
977    case PIPE_QUERY_OCCLUSION_PREDICATE:
978    case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
979    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
980    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
981    case PIPE_QUERY_GPU_FINISHED:
982       trace_dump_bool(result->b);
983       break;
984 
985    case PIPE_QUERY_OCCLUSION_COUNTER:
986    case PIPE_QUERY_TIMESTAMP:
987    case PIPE_QUERY_TIME_ELAPSED:
988    case PIPE_QUERY_PRIMITIVES_GENERATED:
989    case PIPE_QUERY_PRIMITIVES_EMITTED:
990       trace_dump_uint(result->u64);
991       break;
992 
993    case PIPE_QUERY_SO_STATISTICS:
994       trace_dump_struct_begin("pipe_query_data_so_statistics");
995       trace_dump_member(uint, &result->so_statistics, num_primitives_written);
996       trace_dump_member(uint, &result->so_statistics, primitives_storage_needed);
997       trace_dump_struct_end();
998       break;
999 
1000    case PIPE_QUERY_TIMESTAMP_DISJOINT:
1001       trace_dump_struct_begin("pipe_query_data_timestamp_disjoint");
1002       trace_dump_member(uint, &result->timestamp_disjoint, frequency);
1003       trace_dump_member(bool, &result->timestamp_disjoint, disjoint);
1004       trace_dump_struct_end();
1005       break;
1006 
1007    case PIPE_QUERY_PIPELINE_STATISTICS:
1008       trace_dump_struct_begin("pipe_query_data_pipeline_statistics");
1009       trace_dump_member(uint, &result->pipeline_statistics, ia_vertices);
1010       trace_dump_member(uint, &result->pipeline_statistics, ia_primitives);
1011       trace_dump_member(uint, &result->pipeline_statistics, vs_invocations);
1012       trace_dump_member(uint, &result->pipeline_statistics, gs_invocations);
1013       trace_dump_member(uint, &result->pipeline_statistics, gs_primitives);
1014       trace_dump_member(uint, &result->pipeline_statistics, c_invocations);
1015       trace_dump_member(uint, &result->pipeline_statistics, c_primitives);
1016       trace_dump_member(uint, &result->pipeline_statistics, ps_invocations);
1017       trace_dump_member(uint, &result->pipeline_statistics, hs_invocations);
1018       trace_dump_member(uint, &result->pipeline_statistics, ds_invocations);
1019       trace_dump_member(uint, &result->pipeline_statistics, cs_invocations);
1020       trace_dump_struct_end();
1021       break;
1022 
1023    case PIPE_QUERY_PIPELINE_STATISTICS_SINGLE:
1024       trace_dump_struct_begin("pipe_query_data_pipeline_statistics");
1025       switch (index) {
1026       case PIPE_STAT_QUERY_IA_VERTICES:
1027          trace_dump_member(uint, &result->pipeline_statistics, ia_vertices);
1028          break;
1029       case PIPE_STAT_QUERY_IA_PRIMITIVES:
1030          trace_dump_member(uint, &result->pipeline_statistics, ia_primitives);
1031          break;
1032       case PIPE_STAT_QUERY_VS_INVOCATIONS:
1033          trace_dump_member(uint, &result->pipeline_statistics, vs_invocations);
1034          break;
1035       case PIPE_STAT_QUERY_GS_INVOCATIONS:
1036          trace_dump_member(uint, &result->pipeline_statistics, gs_invocations);
1037          break;
1038       case PIPE_STAT_QUERY_GS_PRIMITIVES:
1039          trace_dump_member(uint, &result->pipeline_statistics, gs_primitives);
1040          break;
1041       case PIPE_STAT_QUERY_C_INVOCATIONS:
1042          trace_dump_member(uint, &result->pipeline_statistics, c_invocations);
1043          break;
1044       case PIPE_STAT_QUERY_C_PRIMITIVES:
1045          trace_dump_member(uint, &result->pipeline_statistics, c_primitives);
1046          break;
1047       case PIPE_STAT_QUERY_PS_INVOCATIONS:
1048          trace_dump_member(uint, &result->pipeline_statistics, ps_invocations);
1049          break;
1050       case PIPE_STAT_QUERY_HS_INVOCATIONS:
1051          trace_dump_member(uint, &result->pipeline_statistics, hs_invocations);
1052          break;
1053       case PIPE_STAT_QUERY_DS_INVOCATIONS:
1054          trace_dump_member(uint, &result->pipeline_statistics, ds_invocations);
1055          break;
1056       case PIPE_STAT_QUERY_CS_INVOCATIONS:
1057          trace_dump_member(uint, &result->pipeline_statistics, cs_invocations);
1058          break;
1059       }
1060       trace_dump_struct_end();
1061       break;
1062 
1063    default:
1064       assert(query_type >= PIPE_QUERY_DRIVER_SPECIFIC);
1065       trace_dump_uint(result->u64);
1066       break;
1067    }
1068 }
1069 
trace_dump_grid_info(const struct pipe_grid_info * state)1070 void trace_dump_grid_info(const struct pipe_grid_info *state)
1071 {
1072    if (!trace_dumping_enabled_locked())
1073       return;
1074 
1075    if (!state) {
1076       trace_dump_null();
1077       return;
1078    }
1079 
1080    trace_dump_struct_begin("pipe_grid_info");
1081 
1082    trace_dump_member(uint, state, pc);
1083    trace_dump_member(ptr, state, input);
1084 
1085    trace_dump_member_begin("block");
1086    trace_dump_array(uint, state->block, ARRAY_SIZE(state->block));
1087    trace_dump_member_end();
1088 
1089    trace_dump_member_begin("grid");
1090    trace_dump_array(uint, state->grid, ARRAY_SIZE(state->grid));
1091    trace_dump_member_end();
1092 
1093    trace_dump_member(ptr, state, indirect);
1094    trace_dump_member(uint, state, indirect_offset);
1095 
1096    trace_dump_struct_end();
1097 }
1098 
1099