• 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/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 
38 
trace_dump_resource_template(const struct pipe_resource * templat)39 void trace_dump_resource_template(const struct pipe_resource *templat)
40 {
41    if (!trace_dumping_enabled_locked())
42       return;
43 
44    if (!templat) {
45       trace_dump_null();
46       return;
47    }
48 
49    trace_dump_struct_begin("pipe_resource");
50 
51    trace_dump_member(int, templat, target);
52    trace_dump_member(format, templat, format);
53 
54    trace_dump_member_begin("width");
55    trace_dump_uint(templat->width0);
56    trace_dump_member_end();
57 
58    trace_dump_member_begin("height");
59    trace_dump_uint(templat->height0);
60    trace_dump_member_end();
61 
62    trace_dump_member_begin("depth");
63    trace_dump_uint(templat->depth0);
64    trace_dump_member_end();
65 
66    trace_dump_member_begin("array_size");
67    trace_dump_uint(templat->array_size);
68    trace_dump_member_end();
69 
70    trace_dump_member(uint, templat, last_level);
71    trace_dump_member(uint, templat, nr_samples);
72    trace_dump_member(uint, templat, usage);
73    trace_dump_member(uint, templat, bind);
74    trace_dump_member(uint, templat, flags);
75 
76    trace_dump_struct_end();
77 }
78 
79 
trace_dump_box(const struct pipe_box * box)80 void trace_dump_box(const struct pipe_box *box)
81 {
82    if (!trace_dumping_enabled_locked())
83       return;
84 
85    if (!box) {
86       trace_dump_null();
87       return;
88    }
89 
90    trace_dump_struct_begin("pipe_box");
91 
92    trace_dump_member(int, box, x);
93    trace_dump_member(int, box, y);
94    trace_dump_member(int, box, z);
95    trace_dump_member(int, box, width);
96    trace_dump_member(int, box, height);
97    trace_dump_member(int, box, depth);
98 
99    trace_dump_struct_end();
100 }
101 
102 
trace_dump_rasterizer_state(const struct pipe_rasterizer_state * state)103 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
104 {
105    if (!trace_dumping_enabled_locked())
106       return;
107 
108    if (!state) {
109       trace_dump_null();
110       return;
111    }
112 
113    trace_dump_struct_begin("pipe_rasterizer_state");
114 
115    trace_dump_member(bool, state, flatshade);
116    trace_dump_member(bool, state, light_twoside);
117    trace_dump_member(bool, state, clamp_vertex_color);
118    trace_dump_member(bool, state, clamp_fragment_color);
119    trace_dump_member(uint, state, front_ccw);
120    trace_dump_member(uint, state, cull_face);
121    trace_dump_member(uint, state, fill_front);
122    trace_dump_member(uint, state, fill_back);
123    trace_dump_member(bool, state, offset_point);
124    trace_dump_member(bool, state, offset_line);
125    trace_dump_member(bool, state, offset_tri);
126    trace_dump_member(bool, state, scissor);
127    trace_dump_member(bool, state, poly_smooth);
128    trace_dump_member(bool, state, poly_stipple_enable);
129    trace_dump_member(bool, state, point_smooth);
130    trace_dump_member(bool, state, sprite_coord_mode);
131    trace_dump_member(bool, state, point_quad_rasterization);
132    trace_dump_member(bool, state, point_size_per_vertex);
133    trace_dump_member(bool, state, multisample);
134    trace_dump_member(bool, state, line_smooth);
135    trace_dump_member(bool, state, line_stipple_enable);
136    trace_dump_member(bool, state, line_last_pixel);
137 
138    trace_dump_member(bool, state, flatshade_first);
139 
140    trace_dump_member(bool, state, half_pixel_center);
141    trace_dump_member(bool, state, bottom_edge_rule);
142 
143    trace_dump_member(bool, state, rasterizer_discard);
144 
145    trace_dump_member(bool, state, depth_clip);
146 
147    trace_dump_member(bool, state, clip_halfz);
148 
149    trace_dump_member(uint, state, clip_plane_enable);
150 
151    trace_dump_member(uint, state, line_stipple_factor);
152    trace_dump_member(uint, state, line_stipple_pattern);
153 
154    trace_dump_member(uint, state, sprite_coord_enable);
155 
156    trace_dump_member(float, state, line_width);
157    trace_dump_member(float, state, point_size);
158    trace_dump_member(float, state, offset_units);
159    trace_dump_member(float, state, offset_scale);
160    trace_dump_member(float, state, offset_clamp);
161 
162    trace_dump_struct_end();
163 }
164 
165 
trace_dump_poly_stipple(const struct pipe_poly_stipple * state)166 void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
167 {
168    if (!trace_dumping_enabled_locked())
169       return;
170 
171    if (!state) {
172       trace_dump_null();
173       return;
174    }
175 
176    trace_dump_struct_begin("pipe_poly_stipple");
177 
178    trace_dump_member_begin("stipple");
179    trace_dump_array(uint,
180                     state->stipple,
181                     ARRAY_SIZE(state->stipple));
182    trace_dump_member_end();
183 
184    trace_dump_struct_end();
185 }
186 
187 
trace_dump_viewport_state(const struct pipe_viewport_state * state)188 void trace_dump_viewport_state(const struct pipe_viewport_state *state)
189 {
190    if (!trace_dumping_enabled_locked())
191       return;
192 
193    if (!state) {
194       trace_dump_null();
195       return;
196    }
197 
198    trace_dump_struct_begin("pipe_viewport_state");
199 
200    trace_dump_member_array(float, state, scale);
201    trace_dump_member_array(float, state, translate);
202 
203    trace_dump_struct_end();
204 }
205 
206 
trace_dump_scissor_state(const struct pipe_scissor_state * state)207 void trace_dump_scissor_state(const struct pipe_scissor_state *state)
208 {
209    if (!trace_dumping_enabled_locked())
210       return;
211 
212    if (!state) {
213       trace_dump_null();
214       return;
215    }
216 
217    trace_dump_struct_begin("pipe_scissor_state");
218 
219    trace_dump_member(uint, state, minx);
220    trace_dump_member(uint, state, miny);
221    trace_dump_member(uint, state, maxx);
222    trace_dump_member(uint, state, maxy);
223 
224    trace_dump_struct_end();
225 }
226 
227 
trace_dump_clip_state(const struct pipe_clip_state * state)228 void trace_dump_clip_state(const struct pipe_clip_state *state)
229 {
230    unsigned i;
231 
232    if (!trace_dumping_enabled_locked())
233       return;
234 
235    if (!state) {
236       trace_dump_null();
237       return;
238    }
239 
240    trace_dump_struct_begin("pipe_clip_state");
241 
242    trace_dump_member_begin("ucp");
243    trace_dump_array_begin();
244    for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
245       trace_dump_elem_begin();
246       trace_dump_array(float, state->ucp[i], 4);
247       trace_dump_elem_end();
248    }
249    trace_dump_array_end();
250    trace_dump_member_end();
251 
252    trace_dump_struct_end();
253 }
254 
255 
trace_dump_shader_state(const struct pipe_shader_state * state)256 void trace_dump_shader_state(const struct pipe_shader_state *state)
257 {
258    unsigned i;
259 
260    if (!trace_dumping_enabled_locked())
261       return;
262 
263    if (!state) {
264       trace_dump_null();
265       return;
266    }
267 
268 
269    trace_dump_struct_begin("pipe_shader_state");
270 
271    trace_dump_member_begin("tokens");
272    if (state->tokens) {
273       static char str[64 * 1024];
274       tgsi_dump_str(state->tokens, 0, str, sizeof(str));
275       trace_dump_string(str);
276    } else {
277       trace_dump_null();
278    }
279    trace_dump_member_end();
280 
281    trace_dump_member_begin("stream_output");
282    trace_dump_struct_begin("pipe_stream_output_info");
283    trace_dump_member(uint, &state->stream_output, num_outputs);
284    trace_dump_member_array(uint, &state->stream_output, stride);
285    trace_dump_member_begin("output");
286    trace_dump_array_begin();
287    for(i = 0; i < state->stream_output.num_outputs; ++i) {
288       trace_dump_elem_begin();
289       trace_dump_struct_begin(""); /* anonymous */
290       trace_dump_member(uint, &state->stream_output.output[i], register_index);
291       trace_dump_member(uint, &state->stream_output.output[i], start_component);
292       trace_dump_member(uint, &state->stream_output.output[i], num_components);
293       trace_dump_member(uint, &state->stream_output.output[i], output_buffer);
294       trace_dump_member(uint, &state->stream_output.output[i], dst_offset);
295       trace_dump_member(uint, &state->stream_output.output[i], stream);
296       trace_dump_struct_end();
297       trace_dump_elem_end();
298    }
299    trace_dump_array_end();
300    trace_dump_member_end(); // output
301    trace_dump_struct_end();
302    trace_dump_member_end(); // stream_output
303 
304    trace_dump_struct_end();
305 }
306 
307 
trace_dump_compute_state(const struct pipe_compute_state * state)308 void trace_dump_compute_state(const struct pipe_compute_state *state)
309 {
310    if (!trace_dumping_enabled_locked())
311       return;
312 
313    if (!state) {
314       trace_dump_null();
315       return;
316    }
317 
318    trace_dump_struct_begin("pipe_compute_state");
319 
320    trace_dump_member(uint, state, ir_type);
321 
322    trace_dump_member_begin("prog");
323    if (state->prog && state->ir_type == PIPE_SHADER_IR_TGSI) {
324       static char str[64 * 1024];
325       tgsi_dump_str(state->prog, 0, str, sizeof(str));
326       trace_dump_string(str);
327    } else {
328       trace_dump_null();
329    }
330    trace_dump_member_end();
331 
332    trace_dump_member(uint, state, req_local_mem);
333    trace_dump_member(uint, state, req_private_mem);
334    trace_dump_member(uint, state, req_input_mem);
335 
336    trace_dump_struct_end();
337 }
338 
339 
trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state * state)340 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
341 {
342    unsigned i;
343 
344    if (!trace_dumping_enabled_locked())
345       return;
346 
347    if (!state) {
348       trace_dump_null();
349       return;
350    }
351 
352    trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
353 
354    trace_dump_member_begin("depth");
355    trace_dump_struct_begin("pipe_depth_state");
356    trace_dump_member(bool, &state->depth, enabled);
357    trace_dump_member(bool, &state->depth, writemask);
358    trace_dump_member(uint, &state->depth, func);
359    trace_dump_struct_end();
360    trace_dump_member_end();
361 
362    trace_dump_member_begin("stencil");
363    trace_dump_array_begin();
364    for(i = 0; i < ARRAY_SIZE(state->stencil); ++i) {
365       trace_dump_elem_begin();
366       trace_dump_struct_begin("pipe_stencil_state");
367       trace_dump_member(bool, &state->stencil[i], enabled);
368       trace_dump_member(uint, &state->stencil[i], func);
369       trace_dump_member(uint, &state->stencil[i], fail_op);
370       trace_dump_member(uint, &state->stencil[i], zpass_op);
371       trace_dump_member(uint, &state->stencil[i], zfail_op);
372       trace_dump_member(uint, &state->stencil[i], valuemask);
373       trace_dump_member(uint, &state->stencil[i], writemask);
374       trace_dump_struct_end();
375       trace_dump_elem_end();
376    }
377    trace_dump_array_end();
378    trace_dump_member_end();
379 
380    trace_dump_member_begin("alpha");
381    trace_dump_struct_begin("pipe_alpha_state");
382    trace_dump_member(bool, &state->alpha, enabled);
383    trace_dump_member(uint, &state->alpha, func);
384    trace_dump_member(float, &state->alpha, ref_value);
385    trace_dump_struct_end();
386    trace_dump_member_end();
387 
388    trace_dump_struct_end();
389 }
390 
trace_dump_rt_blend_state(const struct pipe_rt_blend_state * state)391 static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state)
392 {
393    trace_dump_struct_begin("pipe_rt_blend_state");
394 
395    trace_dump_member(uint, state, blend_enable);
396 
397    trace_dump_member(uint, state, rgb_func);
398    trace_dump_member(uint, state, rgb_src_factor);
399    trace_dump_member(uint, state, rgb_dst_factor);
400 
401    trace_dump_member(uint, state, alpha_func);
402    trace_dump_member(uint, state, alpha_src_factor);
403    trace_dump_member(uint, state, alpha_dst_factor);
404 
405    trace_dump_member(uint, state, colormask);
406 
407    trace_dump_struct_end();
408 }
409 
trace_dump_blend_state(const struct pipe_blend_state * state)410 void trace_dump_blend_state(const struct pipe_blend_state *state)
411 {
412    unsigned valid_entries = 1;
413 
414    if (!trace_dumping_enabled_locked())
415       return;
416 
417    if (!state) {
418       trace_dump_null();
419       return;
420    }
421 
422    trace_dump_struct_begin("pipe_blend_state");
423 
424    trace_dump_member(bool, state, dither);
425 
426    trace_dump_member(bool, state, logicop_enable);
427    trace_dump_member(uint, state, logicop_func);
428 
429    trace_dump_member(bool, state, independent_blend_enable);
430 
431    trace_dump_member_begin("rt");
432    if (state->independent_blend_enable)
433       valid_entries = PIPE_MAX_COLOR_BUFS;
434    trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
435    trace_dump_member_end();
436 
437    trace_dump_struct_end();
438 }
439 
440 
trace_dump_blend_color(const struct pipe_blend_color * state)441 void trace_dump_blend_color(const struct pipe_blend_color *state)
442 {
443    if (!trace_dumping_enabled_locked())
444       return;
445 
446    if (!state) {
447       trace_dump_null();
448       return;
449    }
450 
451    trace_dump_struct_begin("pipe_blend_color");
452 
453    trace_dump_member_array(float, state, color);
454 
455    trace_dump_struct_end();
456 }
457 
trace_dump_stencil_ref(const struct pipe_stencil_ref * state)458 void trace_dump_stencil_ref(const struct pipe_stencil_ref *state)
459 {
460    if (!trace_dumping_enabled_locked())
461       return;
462 
463    if (!state) {
464       trace_dump_null();
465       return;
466    }
467 
468    trace_dump_struct_begin("pipe_stencil_ref");
469 
470    trace_dump_member_array(uint, state, ref_value);
471 
472    trace_dump_struct_end();
473 }
474 
trace_dump_framebuffer_state(const struct pipe_framebuffer_state * state)475 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
476 {
477    if (!trace_dumping_enabled_locked())
478       return;
479 
480    trace_dump_struct_begin("pipe_framebuffer_state");
481 
482    trace_dump_member(uint, state, width);
483    trace_dump_member(uint, state, height);
484    trace_dump_member(uint, state, samples);
485    trace_dump_member(uint, state, layers);
486    trace_dump_member(uint, state, nr_cbufs);
487    trace_dump_member_array(ptr, state, cbufs);
488    trace_dump_member(ptr, state, zsbuf);
489 
490    trace_dump_struct_end();
491 }
492 
493 
trace_dump_sampler_state(const struct pipe_sampler_state * state)494 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
495 {
496    if (!trace_dumping_enabled_locked())
497       return;
498 
499    if (!state) {
500       trace_dump_null();
501       return;
502    }
503 
504    trace_dump_struct_begin("pipe_sampler_state");
505 
506    trace_dump_member(uint, state, wrap_s);
507    trace_dump_member(uint, state, wrap_t);
508    trace_dump_member(uint, state, wrap_r);
509    trace_dump_member(uint, state, min_img_filter);
510    trace_dump_member(uint, state, min_mip_filter);
511    trace_dump_member(uint, state, mag_img_filter);
512    trace_dump_member(uint, state, compare_mode);
513    trace_dump_member(uint, state, compare_func);
514    trace_dump_member(bool, state, normalized_coords);
515    trace_dump_member(uint, state, max_anisotropy);
516    trace_dump_member(bool, state, seamless_cube_map);
517    trace_dump_member(float, state, lod_bias);
518    trace_dump_member(float, state, min_lod);
519    trace_dump_member(float, state, max_lod);
520    trace_dump_member_array(float, state, border_color.f);
521 
522    trace_dump_struct_end();
523 }
524 
525 
trace_dump_sampler_view_template(const struct pipe_sampler_view * state,enum pipe_texture_target target)526 void trace_dump_sampler_view_template(const struct pipe_sampler_view *state,
527                                       enum pipe_texture_target target)
528 {
529    if (!trace_dumping_enabled_locked())
530       return;
531 
532    if (!state) {
533       trace_dump_null();
534       return;
535    }
536 
537    trace_dump_struct_begin("pipe_sampler_view");
538 
539    trace_dump_member(format, state, format);
540 
541    trace_dump_member_begin("u");
542    trace_dump_struct_begin(""); /* anonymous */
543    if (target == PIPE_BUFFER) {
544       trace_dump_member_begin("buf");
545       trace_dump_struct_begin(""); /* anonymous */
546       trace_dump_member(uint, &state->u.buf, offset);
547       trace_dump_member(uint, &state->u.buf, size);
548       trace_dump_struct_end(); /* anonymous */
549       trace_dump_member_end(); /* buf */
550    } else {
551       trace_dump_member_begin("tex");
552       trace_dump_struct_begin(""); /* anonymous */
553       trace_dump_member(uint, &state->u.tex, first_layer);
554       trace_dump_member(uint, &state->u.tex, last_layer);
555       trace_dump_member(uint, &state->u.tex, first_level);
556       trace_dump_member(uint, &state->u.tex, last_level);
557       trace_dump_struct_end(); /* anonymous */
558       trace_dump_member_end(); /* tex */
559    }
560    trace_dump_struct_end(); /* anonymous */
561    trace_dump_member_end(); /* u */
562 
563    trace_dump_member(uint, state, swizzle_r);
564    trace_dump_member(uint, state, swizzle_g);
565    trace_dump_member(uint, state, swizzle_b);
566    trace_dump_member(uint, state, swizzle_a);
567 
568    trace_dump_struct_end();
569 }
570 
571 
trace_dump_surface_template(const struct pipe_surface * state,enum pipe_texture_target target)572 void trace_dump_surface_template(const struct pipe_surface *state,
573                                  enum pipe_texture_target target)
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_surface");
584 
585    trace_dump_member(format, state, format);
586    trace_dump_member(uint, state, width);
587    trace_dump_member(uint, state, height);
588 
589    trace_dump_member_begin("u");
590    trace_dump_struct_begin(""); /* anonymous */
591    if (target == PIPE_BUFFER) {
592       trace_dump_member_begin("buf");
593       trace_dump_struct_begin(""); /* anonymous */
594       trace_dump_member(uint, &state->u.buf, first_element);
595       trace_dump_member(uint, &state->u.buf, last_element);
596       trace_dump_struct_end(); /* anonymous */
597       trace_dump_member_end(); /* buf */
598    } else {
599       trace_dump_member_begin("tex");
600       trace_dump_struct_begin(""); /* anonymous */
601       trace_dump_member(uint, &state->u.tex, level);
602       trace_dump_member(uint, &state->u.tex, first_layer);
603       trace_dump_member(uint, &state->u.tex, last_layer);
604       trace_dump_struct_end(); /* anonymous */
605       trace_dump_member_end(); /* tex */
606    }
607    trace_dump_struct_end(); /* anonymous */
608    trace_dump_member_end(); /* u */
609 
610    trace_dump_struct_end();
611 }
612 
613 
trace_dump_transfer(const struct pipe_transfer * state)614 void trace_dump_transfer(const struct pipe_transfer *state)
615 {
616    if (!trace_dumping_enabled_locked())
617       return;
618 
619    if (!state) {
620       trace_dump_null();
621       return;
622    }
623 
624    trace_dump_struct_begin("pipe_transfer");
625 
626    trace_dump_member(uint, state, box.x);
627    trace_dump_member(uint, state, box.y);
628    trace_dump_member(uint, state, box.z);
629    trace_dump_member(uint, state, box.width);
630    trace_dump_member(uint, state, box.height);
631    trace_dump_member(uint, state, box.depth);
632 
633    trace_dump_member(uint, state, stride);
634    trace_dump_member(uint, state, layer_stride);
635    trace_dump_member(uint, state, usage);
636 
637    trace_dump_member(ptr, state, resource);
638 
639    trace_dump_struct_end();
640 }
641 
642 
trace_dump_vertex_buffer(const struct pipe_vertex_buffer * state)643 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
644 {
645    if (!trace_dumping_enabled_locked())
646       return;
647 
648    if (!state) {
649       trace_dump_null();
650       return;
651    }
652 
653    trace_dump_struct_begin("pipe_vertex_buffer");
654 
655    trace_dump_member(uint, state, stride);
656    trace_dump_member(bool, state, is_user_buffer);
657    trace_dump_member(uint, state, buffer_offset);
658    trace_dump_member(ptr, state, buffer.resource);
659 
660    trace_dump_struct_end();
661 }
662 
663 
trace_dump_vertex_element(const struct pipe_vertex_element * state)664 void trace_dump_vertex_element(const struct pipe_vertex_element *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_vertex_element");
675 
676    trace_dump_member(uint, state, src_offset);
677 
678    trace_dump_member(uint, state, vertex_buffer_index);
679 
680    trace_dump_member(format, state, src_format);
681 
682    trace_dump_struct_end();
683 }
684 
685 
trace_dump_constant_buffer(const struct pipe_constant_buffer * state)686 void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
687 {
688    if (!trace_dumping_enabled_locked())
689       return;
690 
691    if (!state) {
692       trace_dump_null();
693       return;
694    }
695 
696    trace_dump_struct_begin("pipe_constant_buffer");
697    trace_dump_member(ptr, state, buffer);
698    trace_dump_member(uint, state, buffer_offset);
699    trace_dump_member(uint, state, buffer_size);
700    trace_dump_struct_end();
701 }
702 
703 
trace_dump_shader_buffer(const struct pipe_shader_buffer * state)704 void trace_dump_shader_buffer(const struct pipe_shader_buffer *state)
705 {
706    if (!trace_dumping_enabled_locked())
707       return;
708 
709    if(!state) {
710       trace_dump_null();
711       return;
712    }
713 
714    trace_dump_struct_begin("pipe_shader_buffer");
715    trace_dump_member(ptr, state, buffer);
716    trace_dump_member(uint, state, buffer_offset);
717    trace_dump_member(uint, state, buffer_size);
718    trace_dump_struct_end();
719 }
720 
721 
trace_dump_image_view(const struct pipe_image_view * state)722 void trace_dump_image_view(const struct pipe_image_view *state)
723 {
724    if (!trace_dumping_enabled_locked())
725       return;
726 
727    if(!state) {
728       trace_dump_null();
729       return;
730    }
731 
732    trace_dump_struct_begin("pipe_image_view");
733    trace_dump_member(ptr, state, resource);
734    trace_dump_member(uint, state, format);
735    trace_dump_member(uint, state, access);
736 
737    trace_dump_member_begin("u");
738    trace_dump_struct_begin(""); /* anonymous */
739    if (state->resource->target == PIPE_BUFFER) {
740       trace_dump_member_begin("buf");
741       trace_dump_struct_begin(""); /* anonymous */
742       trace_dump_member(uint, &state->u.buf, offset);
743       trace_dump_member(uint, &state->u.buf, size);
744       trace_dump_struct_end(); /* anonymous */
745       trace_dump_member_end(); /* buf */
746    } else {
747       trace_dump_member_begin("tex");
748       trace_dump_struct_begin(""); /* anonymous */
749       trace_dump_member(uint, &state->u.tex, first_layer);
750       trace_dump_member(uint, &state->u.tex, last_layer);
751       trace_dump_member(uint, &state->u.tex, level);
752       trace_dump_struct_end(); /* anonymous */
753       trace_dump_member_end(); /* tex */
754    }
755    trace_dump_struct_end(); /* anonymous */
756    trace_dump_member_end(); /* u */
757 
758    trace_dump_struct_end();
759 }
760 
761 
trace_dump_draw_info(const struct pipe_draw_info * state)762 void trace_dump_draw_info(const struct pipe_draw_info *state)
763 {
764    if (!trace_dumping_enabled_locked())
765       return;
766 
767    if (!state) {
768       trace_dump_null();
769       return;
770    }
771 
772    trace_dump_struct_begin("pipe_draw_info");
773 
774    trace_dump_member(uint, state, index_size);
775    trace_dump_member(uint, state, has_user_indices);
776 
777    trace_dump_member(uint, state, mode);
778    trace_dump_member(uint, state, start);
779    trace_dump_member(uint, state, count);
780 
781    trace_dump_member(uint, state, start_instance);
782    trace_dump_member(uint, state, instance_count);
783 
784    trace_dump_member(uint, state, vertices_per_patch);
785 
786    trace_dump_member(int,  state, index_bias);
787    trace_dump_member(uint, state, min_index);
788    trace_dump_member(uint, state, max_index);
789 
790    trace_dump_member(bool, state, primitive_restart);
791    trace_dump_member(uint, state, restart_index);
792 
793    trace_dump_member(ptr, state, index.resource);
794    trace_dump_member(ptr, state, count_from_stream_output);
795 
796    if (!state->indirect) {
797       trace_dump_member(ptr, state, indirect);
798    } else {
799       trace_dump_member(uint, state, indirect->offset);
800       trace_dump_member(uint, state, indirect->stride);
801       trace_dump_member(uint, state, indirect->draw_count);
802       trace_dump_member(uint, state, indirect->indirect_draw_count_offset);
803       trace_dump_member(ptr, state, indirect->buffer);
804       trace_dump_member(ptr, state, indirect->indirect_draw_count);
805    }
806 
807    trace_dump_struct_end();
808 }
809 
trace_dump_blit_info(const struct pipe_blit_info * info)810 void trace_dump_blit_info(const struct pipe_blit_info *info)
811 {
812    char mask[7];
813 
814    if (!trace_dumping_enabled_locked())
815       return;
816 
817    if (!info) {
818       trace_dump_null();
819       return;
820    }
821 
822    trace_dump_struct_begin("pipe_blit_info");
823 
824    trace_dump_member_begin("dst");
825    trace_dump_struct_begin("dst");
826    trace_dump_member(ptr, &info->dst, resource);
827    trace_dump_member(uint, &info->dst, level);
828    trace_dump_member(format, &info->dst, format);
829    trace_dump_member_begin("box");
830    trace_dump_box(&info->dst.box);
831    trace_dump_member_end();
832    trace_dump_struct_end();
833    trace_dump_member_end();
834 
835    trace_dump_member_begin("src");
836    trace_dump_struct_begin("src");
837    trace_dump_member(ptr, &info->src, resource);
838    trace_dump_member(uint, &info->src, level);
839    trace_dump_member(format, &info->src, format);
840    trace_dump_member_begin("box");
841    trace_dump_box(&info->src.box);
842    trace_dump_member_end();
843    trace_dump_struct_end();
844    trace_dump_member_end();
845 
846    mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-';
847    mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-';
848    mask[2] = (info->mask & PIPE_MASK_B) ? 'B' : '-';
849    mask[3] = (info->mask & PIPE_MASK_A) ? 'A' : '-';
850    mask[4] = (info->mask & PIPE_MASK_Z) ? 'Z' : '-';
851    mask[5] = (info->mask & PIPE_MASK_S) ? 'S' : '-';
852    mask[6] = 0;
853 
854    trace_dump_member_begin("mask");
855    trace_dump_string(mask);
856    trace_dump_member_end();
857    trace_dump_member(uint, info, filter);
858 
859    trace_dump_member(bool, info, scissor_enable);
860    trace_dump_member_begin("scissor");
861    trace_dump_scissor_state(&info->scissor);
862    trace_dump_member_end();
863 
864    trace_dump_struct_end();
865 }
866 
867 void
trace_dump_query_result(unsigned query_type,const union pipe_query_result * result)868 trace_dump_query_result(unsigned query_type,
869                         const union pipe_query_result *result)
870 {
871    if (!trace_dumping_enabled_locked())
872       return;
873 
874    if (!result) {
875       trace_dump_null();
876       return;
877    }
878 
879    switch (query_type) {
880    case PIPE_QUERY_OCCLUSION_PREDICATE:
881    case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
882    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
883    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
884    case PIPE_QUERY_GPU_FINISHED:
885       trace_dump_bool(result->b);
886       break;
887 
888    case PIPE_QUERY_OCCLUSION_COUNTER:
889    case PIPE_QUERY_TIMESTAMP:
890    case PIPE_QUERY_TIME_ELAPSED:
891    case PIPE_QUERY_PRIMITIVES_GENERATED:
892    case PIPE_QUERY_PRIMITIVES_EMITTED:
893       trace_dump_uint(result->u64);
894       break;
895 
896    case PIPE_QUERY_SO_STATISTICS:
897       trace_dump_struct_begin("pipe_query_data_so_statistics");
898       trace_dump_member(uint, &result->so_statistics, num_primitives_written);
899       trace_dump_member(uint, &result->so_statistics, primitives_storage_needed);
900       trace_dump_struct_end();
901       break;
902 
903    case PIPE_QUERY_TIMESTAMP_DISJOINT:
904       trace_dump_struct_begin("pipe_query_data_timestamp_disjoint");
905       trace_dump_member(uint, &result->timestamp_disjoint, frequency);
906       trace_dump_member(bool, &result->timestamp_disjoint, disjoint);
907       trace_dump_struct_end();
908       break;
909 
910    case PIPE_QUERY_PIPELINE_STATISTICS:
911       trace_dump_struct_begin("pipe_query_data_pipeline_statistics");
912       trace_dump_member(uint, &result->pipeline_statistics, ia_vertices);
913       trace_dump_member(uint, &result->pipeline_statistics, ia_primitives);
914       trace_dump_member(uint, &result->pipeline_statistics, vs_invocations);
915       trace_dump_member(uint, &result->pipeline_statistics, gs_invocations);
916       trace_dump_member(uint, &result->pipeline_statistics, gs_primitives);
917       trace_dump_member(uint, &result->pipeline_statistics, c_invocations);
918       trace_dump_member(uint, &result->pipeline_statistics, c_primitives);
919       trace_dump_member(uint, &result->pipeline_statistics, ps_invocations);
920       trace_dump_member(uint, &result->pipeline_statistics, hs_invocations);
921       trace_dump_member(uint, &result->pipeline_statistics, ds_invocations);
922       trace_dump_member(uint, &result->pipeline_statistics, cs_invocations);
923       trace_dump_struct_end();
924       break;
925 
926    default:
927       assert(query_type >= PIPE_QUERY_DRIVER_SPECIFIC);
928       trace_dump_uint(result->u64);
929       break;
930    }
931 }
932 
trace_dump_grid_info(const struct pipe_grid_info * state)933 void trace_dump_grid_info(const struct pipe_grid_info *state)
934 {
935    if (!trace_dumping_enabled_locked())
936       return;
937 
938    if (!state) {
939       trace_dump_null();
940       return;
941    }
942 
943    trace_dump_struct_begin("pipe_grid_info");
944 
945    trace_dump_member(uint, state, pc);
946    trace_dump_member(ptr, state, input);
947 
948    trace_dump_member_begin("block");
949    trace_dump_array(uint, state->block, ARRAY_SIZE(state->block));
950    trace_dump_member_end();
951 
952    trace_dump_member_begin("grid");
953    trace_dump_array(uint, state->grid, ARRAY_SIZE(state->grid));
954    trace_dump_member_end();
955 
956    trace_dump_member(ptr, state, indirect);
957    trace_dump_member(uint, state, indirect_offset);
958 
959    trace_dump_struct_end();
960 }
961 
962