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