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 "tgsi/tgsi_dump.h"
34 #include "tr_dump_state.h"
37 void trace_dump_format(enum pipe_format format
)
39 if (!trace_dumping_enabled_locked())
42 trace_dump_enum(pf_name(format
) );
46 static void trace_dump_reference(const struct pipe_reference
*reference
)
48 if (!trace_dumping_enabled_locked())
51 trace_dump_struct_begin("pipe_reference");
52 trace_dump_member(int, reference
, count
);
53 trace_dump_struct_end();
57 void trace_dump_template(const struct pipe_texture
*templat
)
59 if (!trace_dumping_enabled_locked())
67 trace_dump_struct_begin("pipe_texture");
69 trace_dump_member(int, templat
, target
);
70 trace_dump_member(format
, templat
, format
);
72 trace_dump_member_begin("width");
73 trace_dump_uint(templat
->width0
);
74 trace_dump_member_end();
76 trace_dump_member_begin("height");
77 trace_dump_uint(templat
->height0
);
78 trace_dump_member_end();
80 trace_dump_member_begin("depth");
81 trace_dump_uint(templat
->depth0
);
82 trace_dump_member_end();
84 trace_dump_member(uint
, templat
, last_level
);
85 trace_dump_member(uint
, templat
, tex_usage
);
87 trace_dump_struct_end();
91 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state
*state
)
93 if (!trace_dumping_enabled_locked())
101 trace_dump_struct_begin("pipe_rasterizer_state");
103 trace_dump_member(bool, state
, flatshade
);
104 trace_dump_member(bool, state
, light_twoside
);
105 trace_dump_member(uint
, state
, front_winding
);
106 trace_dump_member(uint
, state
, cull_mode
);
107 trace_dump_member(uint
, state
, fill_cw
);
108 trace_dump_member(uint
, state
, fill_ccw
);
109 trace_dump_member(bool, state
, offset_cw
);
110 trace_dump_member(bool, state
, offset_ccw
);
111 trace_dump_member(bool, state
, scissor
);
112 trace_dump_member(bool, state
, poly_smooth
);
113 trace_dump_member(bool, state
, poly_stipple_enable
);
114 trace_dump_member(bool, state
, point_smooth
);
115 trace_dump_member(bool, state
, point_sprite
);
116 trace_dump_member(bool, state
, point_size_per_vertex
);
117 trace_dump_member(bool, state
, multisample
);
118 trace_dump_member(bool, state
, line_smooth
);
119 trace_dump_member(bool, state
, line_stipple_enable
);
120 trace_dump_member(uint
, state
, line_stipple_factor
);
121 trace_dump_member(uint
, state
, line_stipple_pattern
);
122 trace_dump_member(bool, state
, line_last_pixel
);
123 trace_dump_member(bool, state
, bypass_vs_clip_and_viewport
);
124 trace_dump_member(bool, state
, flatshade_first
);
125 trace_dump_member(bool, state
, gl_rasterization_rules
);
127 trace_dump_member(float, state
, line_width
);
128 trace_dump_member(float, state
, point_size
);
129 trace_dump_member(float, state
, point_size_min
);
130 trace_dump_member(float, state
, point_size_max
);
131 trace_dump_member(float, state
, offset_units
);
132 trace_dump_member(float, state
, offset_scale
);
134 trace_dump_member_array(uint
, state
, sprite_coord_mode
);
136 trace_dump_struct_end();
140 void trace_dump_poly_stipple(const struct pipe_poly_stipple
*state
)
142 if (!trace_dumping_enabled_locked())
150 trace_dump_struct_begin("pipe_poly_stipple");
152 trace_dump_member_begin("stipple");
153 trace_dump_array(uint
,
155 Elements(state
->stipple
));
156 trace_dump_member_end();
158 trace_dump_struct_end();
162 void trace_dump_viewport_state(const struct pipe_viewport_state
*state
)
164 if (!trace_dumping_enabled_locked())
172 trace_dump_struct_begin("pipe_viewport_state");
174 trace_dump_member_array(float, state
, scale
);
175 trace_dump_member_array(float, state
, translate
);
177 trace_dump_struct_end();
181 void trace_dump_scissor_state(const struct pipe_scissor_state
*state
)
183 if (!trace_dumping_enabled_locked())
191 trace_dump_struct_begin("pipe_scissor_state");
193 trace_dump_member(uint
, state
, minx
);
194 trace_dump_member(uint
, state
, miny
);
195 trace_dump_member(uint
, state
, maxx
);
196 trace_dump_member(uint
, state
, maxy
);
198 trace_dump_struct_end();
202 void trace_dump_clip_state(const struct pipe_clip_state
*state
)
206 if (!trace_dumping_enabled_locked())
214 trace_dump_struct_begin("pipe_clip_state");
216 trace_dump_member_begin("ucp");
217 trace_dump_array_begin();
218 for(i
= 0; i
< PIPE_MAX_CLIP_PLANES
; ++i
) {
219 trace_dump_elem_begin();
220 trace_dump_array(float, state
->ucp
[i
], 4);
221 trace_dump_elem_end();
223 trace_dump_array_end();
224 trace_dump_member_end();
226 trace_dump_member(uint
, state
, nr
);
228 trace_dump_struct_end();
232 void trace_dump_constant_buffer(const struct pipe_buffer
*state
)
234 if (!trace_dumping_enabled_locked())
242 trace_dump_struct_begin("pipe_constant_buffer");
244 trace_dump_reference(&state
->reference
);
246 trace_dump_struct_end();
250 void trace_dump_shader_state(const struct pipe_shader_state
*state
)
252 static char str
[8192];
254 if (!trace_dumping_enabled_locked())
262 tgsi_dump_str(state
->tokens
, 0, str
, sizeof(str
));
264 trace_dump_struct_begin("pipe_shader_state");
266 trace_dump_member_begin("tokens");
267 trace_dump_string(str
);
268 trace_dump_member_end();
270 trace_dump_struct_end();
274 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state
*state
)
278 if (!trace_dumping_enabled_locked())
286 trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
288 trace_dump_member_begin("depth");
289 trace_dump_struct_begin("pipe_depth_state");
290 trace_dump_member(bool, &state
->depth
, enabled
);
291 trace_dump_member(bool, &state
->depth
, writemask
);
292 trace_dump_member(uint
, &state
->depth
, func
);
293 trace_dump_struct_end();
294 trace_dump_member_end();
296 trace_dump_member_begin("stencil");
297 trace_dump_array_begin();
298 for(i
= 0; i
< Elements(state
->stencil
); ++i
) {
299 trace_dump_elem_begin();
300 trace_dump_struct_begin("pipe_stencil_state");
301 trace_dump_member(bool, &state
->stencil
[i
], enabled
);
302 trace_dump_member(uint
, &state
->stencil
[i
], func
);
303 trace_dump_member(uint
, &state
->stencil
[i
], fail_op
);
304 trace_dump_member(uint
, &state
->stencil
[i
], zpass_op
);
305 trace_dump_member(uint
, &state
->stencil
[i
], zfail_op
);
306 trace_dump_member(uint
, &state
->stencil
[i
], ref_value
);
307 trace_dump_member(uint
, &state
->stencil
[i
], valuemask
);
308 trace_dump_member(uint
, &state
->stencil
[i
], writemask
);
309 trace_dump_struct_end();
310 trace_dump_elem_end();
312 trace_dump_array_end();
313 trace_dump_member_end();
315 trace_dump_member_begin("alpha");
316 trace_dump_struct_begin("pipe_alpha_state");
317 trace_dump_member(bool, &state
->alpha
, enabled
);
318 trace_dump_member(uint
, &state
->alpha
, func
);
319 trace_dump_member(float, &state
->alpha
, ref_value
);
320 trace_dump_struct_end();
321 trace_dump_member_end();
323 trace_dump_struct_end();
326 static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state
*state
)
328 trace_dump_member(uint
, state
, rgb_func
);
329 trace_dump_member(uint
, state
, rgb_src_factor
);
330 trace_dump_member(uint
, state
, rgb_dst_factor
);
332 trace_dump_member(uint
, state
, alpha_func
);
333 trace_dump_member(uint
, state
, alpha_src_factor
);
334 trace_dump_member(uint
, state
, alpha_dst_factor
);
336 trace_dump_member(uint
, state
, colormask
);
340 void trace_dump_blend_state(const struct pipe_blend_state
*state
)
342 unsigned valid_entries
= 1;
343 if (!trace_dumping_enabled_locked())
351 trace_dump_struct_begin("pipe_blend_state");
353 trace_dump_member(bool, state
, dither
);
355 trace_dump_member(bool, state
, logicop_enable
);
356 trace_dump_member(uint
, state
, logicop_func
);
358 trace_dump_member(bool, state
, independent_blend_enable
);
360 if (state
->independent_blend_enable
)
361 valid_entries
= PIPE_MAX_COLOR_BUFS
;
363 trace_dump_struct_array(rt_blend_state
, state
->rt
, valid_entries
);
365 trace_dump_struct_end();
369 void trace_dump_blend_color(const struct pipe_blend_color
*state
)
371 if (!trace_dumping_enabled_locked())
379 trace_dump_struct_begin("pipe_blend_color");
381 trace_dump_member_array(float, state
, color
);
383 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(float, state
, lod_bias
);
426 trace_dump_member(float, state
, min_lod
);
427 trace_dump_member(float, state
, max_lod
);
428 trace_dump_member_array(float, state
, border_color
);
429 trace_dump_member(float, state
, max_anisotropy
);
431 trace_dump_struct_end();
435 void trace_dump_surface(const struct pipe_surface
*state
)
437 if (!trace_dumping_enabled_locked())
445 trace_dump_struct_begin("pipe_surface");
447 trace_dump_reference(&state
->reference
);
449 trace_dump_member(format
, state
, format
);
450 trace_dump_member(uint
, state
, width
);
451 trace_dump_member(uint
, state
, height
);
453 trace_dump_member(uint
, state
, layout
);
454 trace_dump_member(uint
, state
, offset
);
455 trace_dump_member(uint
, state
, usage
);
457 trace_dump_member(ptr
, state
, texture
);
458 trace_dump_member(uint
, state
, face
);
459 trace_dump_member(uint
, state
, level
);
460 trace_dump_member(uint
, state
, zslice
);
462 trace_dump_struct_end();
466 void trace_dump_transfer(const struct pipe_transfer
*state
)
468 if (!trace_dumping_enabled_locked())
476 trace_dump_struct_begin("pipe_transfer");
478 trace_dump_member(uint
, state
, width
);
479 trace_dump_member(uint
, state
, height
);
481 trace_dump_member(uint
, state
, stride
);
482 trace_dump_member(uint
, state
, usage
);
484 trace_dump_member(ptr
, state
, texture
);
485 trace_dump_member(uint
, state
, face
);
486 trace_dump_member(uint
, state
, level
);
487 trace_dump_member(uint
, state
, zslice
);
489 trace_dump_struct_end();
493 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer
*state
)
495 if (!trace_dumping_enabled_locked())
503 trace_dump_struct_begin("pipe_vertex_buffer");
505 trace_dump_member(uint
, state
, stride
);
506 trace_dump_member(uint
, state
, max_index
);
507 trace_dump_member(uint
, state
, buffer_offset
);
508 trace_dump_member(buffer_ptr
, state
, buffer
);
510 trace_dump_struct_end();
514 void trace_dump_vertex_element(const struct pipe_vertex_element
*state
)
516 if (!trace_dumping_enabled_locked())
524 trace_dump_struct_begin("pipe_vertex_element");
526 trace_dump_member(uint
, state
, src_offset
);
528 trace_dump_member(uint
, state
, vertex_buffer_index
);
529 trace_dump_member(uint
, state
, nr_components
);
531 trace_dump_member(format
, state
, src_format
);
533 trace_dump_struct_end();