1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "pipe/p_compiler.h"
30 #include "util/u_memory.h"
31 #include "util/u_format.h"
32 #include "tgsi/tgsi_dump.h"
35 #include "tr_dump_state.h"
38 void trace_dump_format(enum pipe_format format
)
40 if (!trace_dumping_enabled_locked())
43 trace_dump_enum(util_format_name(format
) );
47 void trace_dump_resource_template(const struct pipe_resource
*templat
)
49 if (!trace_dumping_enabled_locked())
57 trace_dump_struct_begin("pipe_resource");
59 trace_dump_member(int, templat
, target
);
60 trace_dump_member(format
, templat
, format
);
62 trace_dump_member_begin("width");
63 trace_dump_uint(templat
->width0
);
64 trace_dump_member_end();
66 trace_dump_member_begin("height");
67 trace_dump_uint(templat
->height0
);
68 trace_dump_member_end();
70 trace_dump_member_begin("depth");
71 trace_dump_uint(templat
->depth0
);
72 trace_dump_member_end();
74 trace_dump_member(uint
, templat
, last_level
);
75 trace_dump_member(uint
, templat
, usage
);
76 trace_dump_member(uint
, templat
, bind
);
77 trace_dump_member(uint
, templat
, flags
);
79 trace_dump_struct_end();
83 void trace_dump_subresource(const struct pipe_subresource
*subresource
)
85 if (!trace_dumping_enabled_locked())
93 trace_dump_struct_begin("pipe_subresource");
95 trace_dump_member(uint
, subresource
, face
);
96 trace_dump_member(uint
, subresource
, level
);
98 trace_dump_struct_end();
102 void trace_dump_box(const struct pipe_box
*box
)
104 if (!trace_dumping_enabled_locked())
112 trace_dump_struct_begin("pipe_box");
114 trace_dump_member(uint
, box
, x
);
115 trace_dump_member(uint
, box
, y
);
116 trace_dump_member(uint
, box
, z
);
117 trace_dump_member(uint
, box
, width
);
118 trace_dump_member(uint
, box
, height
);
119 trace_dump_member(uint
, box
, depth
);
121 trace_dump_struct_end();
125 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state
*state
)
127 if (!trace_dumping_enabled_locked())
135 trace_dump_struct_begin("pipe_rasterizer_state");
137 trace_dump_member(bool, state
, flatshade
);
138 trace_dump_member(bool, state
, light_twoside
);
139 trace_dump_member(uint
, state
, front_ccw
);
140 trace_dump_member(uint
, state
, cull_face
);
141 trace_dump_member(uint
, state
, fill_front
);
142 trace_dump_member(uint
, state
, fill_back
);
143 trace_dump_member(bool, state
, offset_point
);
144 trace_dump_member(bool, state
, offset_line
);
145 trace_dump_member(bool, state
, offset_tri
);
146 trace_dump_member(bool, state
, scissor
);
147 trace_dump_member(bool, state
, poly_smooth
);
148 trace_dump_member(bool, state
, poly_stipple_enable
);
149 trace_dump_member(bool, state
, point_smooth
);
150 trace_dump_member(uint
, state
, sprite_coord_enable
);
151 trace_dump_member(bool, state
, sprite_coord_mode
);
152 trace_dump_member(bool, state
, point_quad_rasterization
);
153 trace_dump_member(bool, state
, point_size_per_vertex
);
154 trace_dump_member(bool, state
, multisample
);
155 trace_dump_member(bool, state
, line_smooth
);
156 trace_dump_member(bool, state
, line_stipple_enable
);
157 trace_dump_member(uint
, state
, line_stipple_factor
);
158 trace_dump_member(uint
, state
, line_stipple_pattern
);
159 trace_dump_member(bool, state
, line_last_pixel
);
160 trace_dump_member(bool, state
, flatshade_first
);
161 trace_dump_member(bool, state
, gl_rasterization_rules
);
163 trace_dump_member(float, state
, line_width
);
164 trace_dump_member(float, state
, point_size
);
165 trace_dump_member(float, state
, offset_units
);
166 trace_dump_member(float, state
, offset_scale
);
168 trace_dump_struct_end();
172 void trace_dump_poly_stipple(const struct pipe_poly_stipple
*state
)
174 if (!trace_dumping_enabled_locked())
182 trace_dump_struct_begin("pipe_poly_stipple");
184 trace_dump_member_begin("stipple");
185 trace_dump_array(uint
,
187 Elements(state
->stipple
));
188 trace_dump_member_end();
190 trace_dump_struct_end();
194 void trace_dump_viewport_state(const struct pipe_viewport_state
*state
)
196 if (!trace_dumping_enabled_locked())
204 trace_dump_struct_begin("pipe_viewport_state");
206 trace_dump_member_array(float, state
, scale
);
207 trace_dump_member_array(float, state
, translate
);
209 trace_dump_struct_end();
213 void trace_dump_scissor_state(const struct pipe_scissor_state
*state
)
215 if (!trace_dumping_enabled_locked())
223 trace_dump_struct_begin("pipe_scissor_state");
225 trace_dump_member(uint
, state
, minx
);
226 trace_dump_member(uint
, state
, miny
);
227 trace_dump_member(uint
, state
, maxx
);
228 trace_dump_member(uint
, state
, maxy
);
230 trace_dump_struct_end();
234 void trace_dump_clip_state(const struct pipe_clip_state
*state
)
238 if (!trace_dumping_enabled_locked())
246 trace_dump_struct_begin("pipe_clip_state");
248 trace_dump_member_begin("ucp");
249 trace_dump_array_begin();
250 for(i
= 0; i
< PIPE_MAX_CLIP_PLANES
; ++i
) {
251 trace_dump_elem_begin();
252 trace_dump_array(float, state
->ucp
[i
], 4);
253 trace_dump_elem_end();
255 trace_dump_array_end();
256 trace_dump_member_end();
258 trace_dump_member(uint
, state
, nr
);
260 trace_dump_struct_end();
264 void trace_dump_shader_state(const struct pipe_shader_state
*state
)
266 static char str
[8192];
268 if (!trace_dumping_enabled_locked())
276 tgsi_dump_str(state
->tokens
, 0, str
, sizeof(str
));
278 trace_dump_struct_begin("pipe_shader_state");
280 trace_dump_member_begin("tokens");
281 trace_dump_string(str
);
282 trace_dump_member_end();
284 trace_dump_struct_end();
288 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state
*state
)
292 if (!trace_dumping_enabled_locked())
300 trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
302 trace_dump_member_begin("depth");
303 trace_dump_struct_begin("pipe_depth_state");
304 trace_dump_member(bool, &state
->depth
, enabled
);
305 trace_dump_member(bool, &state
->depth
, writemask
);
306 trace_dump_member(uint
, &state
->depth
, func
);
307 trace_dump_struct_end();
308 trace_dump_member_end();
310 trace_dump_member_begin("stencil");
311 trace_dump_array_begin();
312 for(i
= 0; i
< Elements(state
->stencil
); ++i
) {
313 trace_dump_elem_begin();
314 trace_dump_struct_begin("pipe_stencil_state");
315 trace_dump_member(bool, &state
->stencil
[i
], enabled
);
316 trace_dump_member(uint
, &state
->stencil
[i
], func
);
317 trace_dump_member(uint
, &state
->stencil
[i
], fail_op
);
318 trace_dump_member(uint
, &state
->stencil
[i
], zpass_op
);
319 trace_dump_member(uint
, &state
->stencil
[i
], zfail_op
);
320 trace_dump_member(uint
, &state
->stencil
[i
], valuemask
);
321 trace_dump_member(uint
, &state
->stencil
[i
], writemask
);
322 trace_dump_struct_end();
323 trace_dump_elem_end();
325 trace_dump_array_end();
326 trace_dump_member_end();
328 trace_dump_member_begin("alpha");
329 trace_dump_struct_begin("pipe_alpha_state");
330 trace_dump_member(bool, &state
->alpha
, enabled
);
331 trace_dump_member(uint
, &state
->alpha
, func
);
332 trace_dump_member(float, &state
->alpha
, ref_value
);
333 trace_dump_struct_end();
334 trace_dump_member_end();
336 trace_dump_struct_end();
339 void trace_dump_blend_state(const struct pipe_blend_state
*state
)
341 if (!trace_dumping_enabled_locked())
349 trace_dump_bytes(state
, sizeof *state
);
353 void trace_dump_blend_color(const struct pipe_blend_color
*state
)
355 if (!trace_dumping_enabled_locked())
363 trace_dump_struct_begin("pipe_blend_color");
365 trace_dump_member_array(float, state
, color
);
367 trace_dump_struct_end();
370 void trace_dump_stencil_ref(const struct pipe_stencil_ref
*state
)
372 if (!trace_dumping_enabled_locked())
380 trace_dump_struct_begin("pipe_stencil_ref");
382 trace_dump_member_array(uint
, state
, ref_value
);
384 trace_dump_struct_end();
387 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state
*state
)
389 if (!trace_dumping_enabled_locked())
392 trace_dump_struct_begin("pipe_framebuffer_state");
394 trace_dump_member(uint
, state
, width
);
395 trace_dump_member(uint
, state
, height
);
396 trace_dump_member(uint
, state
, nr_cbufs
);
397 trace_dump_member_array(ptr
, state
, cbufs
);
398 trace_dump_member(ptr
, state
, zsbuf
);
400 trace_dump_struct_end();
404 void trace_dump_sampler_state(const struct pipe_sampler_state
*state
)
406 if (!trace_dumping_enabled_locked())
414 trace_dump_struct_begin("pipe_sampler_state");
416 trace_dump_member(uint
, state
, wrap_s
);
417 trace_dump_member(uint
, state
, wrap_t
);
418 trace_dump_member(uint
, state
, wrap_r
);
419 trace_dump_member(uint
, state
, min_img_filter
);
420 trace_dump_member(uint
, state
, min_mip_filter
);
421 trace_dump_member(uint
, state
, mag_img_filter
);
422 trace_dump_member(uint
, state
, compare_mode
);
423 trace_dump_member(uint
, state
, compare_func
);
424 trace_dump_member(bool, state
, normalized_coords
);
425 trace_dump_member(uint
, state
, max_anisotropy
);
426 trace_dump_member(float, state
, lod_bias
);
427 trace_dump_member(float, state
, min_lod
);
428 trace_dump_member(float, state
, max_lod
);
429 trace_dump_member_array(float, state
, border_color
);
431 trace_dump_struct_end();
435 void trace_dump_sampler_view_template(const struct pipe_sampler_view
*state
)
437 if (!trace_dumping_enabled_locked())
445 trace_dump_struct_begin("pipe_sampler_view");
447 trace_dump_member(format
, state
, format
);
448 trace_dump_member(uint
, state
, first_level
);
449 trace_dump_member(uint
, state
, last_level
);
450 trace_dump_member(uint
, state
, swizzle_r
);
451 trace_dump_member(uint
, state
, swizzle_g
);
452 trace_dump_member(uint
, state
, swizzle_b
);
453 trace_dump_member(uint
, state
, swizzle_a
);
455 trace_dump_struct_end();
459 void trace_dump_surface(const struct pipe_surface
*state
)
461 if (!trace_dumping_enabled_locked())
469 trace_dump_struct_begin("pipe_surface");
471 trace_dump_member(format
, state
, format
);
472 trace_dump_member(uint
, state
, width
);
473 trace_dump_member(uint
, state
, height
);
475 trace_dump_member(uint
, state
, layout
);
476 trace_dump_member(uint
, state
, offset
);
477 trace_dump_member(uint
, state
, usage
);
479 trace_dump_member(ptr
, state
, texture
);
480 trace_dump_member(uint
, state
, face
);
481 trace_dump_member(uint
, state
, level
);
482 trace_dump_member(uint
, state
, zslice
);
484 trace_dump_struct_end();
488 void trace_dump_transfer(const struct pipe_transfer
*state
)
490 if (!trace_dumping_enabled_locked())
498 trace_dump_struct_begin("pipe_transfer");
500 trace_dump_member(uint
, state
, box
.width
);
501 trace_dump_member(uint
, state
, box
.height
);
503 trace_dump_member(uint
, state
, stride
);
504 trace_dump_member(uint
, state
, usage
);
506 trace_dump_member(ptr
, state
, resource
);
507 trace_dump_member(uint
, state
, sr
.face
);
508 trace_dump_member(uint
, state
, sr
.level
);
509 trace_dump_member(uint
, state
, box
.z
);
511 trace_dump_struct_end();
515 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer
*state
)
517 if (!trace_dumping_enabled_locked())
525 trace_dump_struct_begin("pipe_vertex_buffer");
527 trace_dump_member(uint
, state
, stride
);
528 trace_dump_member(uint
, state
, max_index
);
529 trace_dump_member(uint
, state
, buffer_offset
);
530 trace_dump_member(resource_ptr
, state
, buffer
);
532 trace_dump_struct_end();
536 void trace_dump_vertex_element(const struct pipe_vertex_element
*state
)
538 if (!trace_dumping_enabled_locked())
546 trace_dump_struct_begin("pipe_vertex_element");
548 trace_dump_member(uint
, state
, src_offset
);
550 trace_dump_member(uint
, state
, vertex_buffer_index
);
552 trace_dump_member(format
, state
, src_format
);
554 trace_dump_struct_end();