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_template(const struct pipe_texture *templat)
49 if (!trace_dumping_enabled_locked())
57 trace_dump_struct_begin("pipe_texture");
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, tex_usage);
77 trace_dump_struct_end();
81 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
83 if (!trace_dumping_enabled_locked())
91 trace_dump_struct_begin("pipe_rasterizer_state");
93 trace_dump_member(bool, state, flatshade);
94 trace_dump_member(bool, state, light_twoside);
95 trace_dump_member(uint, state, front_winding);
96 trace_dump_member(uint, state, cull_mode);
97 trace_dump_member(uint, state, fill_cw);
98 trace_dump_member(uint, state, fill_ccw);
99 trace_dump_member(bool, state, offset_cw);
100 trace_dump_member(bool, state, offset_ccw);
101 trace_dump_member(bool, state, scissor);
102 trace_dump_member(bool, state, poly_smooth);
103 trace_dump_member(bool, state, poly_stipple_enable);
104 trace_dump_member(bool, state, point_smooth);
105 trace_dump_member(uint, state, sprite_coord_enable);
106 trace_dump_member(bool, state, sprite_coord_mode);
107 trace_dump_member(bool, state, point_quad_rasterization);
108 trace_dump_member(bool, state, point_size_per_vertex);
109 trace_dump_member(bool, state, multisample);
110 trace_dump_member(bool, state, line_smooth);
111 trace_dump_member(bool, state, line_stipple_enable);
112 trace_dump_member(uint, state, line_stipple_factor);
113 trace_dump_member(uint, state, line_stipple_pattern);
114 trace_dump_member(bool, state, line_last_pixel);
115 trace_dump_member(bool, state, flatshade_first);
116 trace_dump_member(bool, state, gl_rasterization_rules);
118 trace_dump_member(float, state, line_width);
119 trace_dump_member(float, state, point_size);
120 trace_dump_member(float, state, offset_units);
121 trace_dump_member(float, state, offset_scale);
123 trace_dump_struct_end();
127 void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
129 if (!trace_dumping_enabled_locked())
137 trace_dump_struct_begin("pipe_poly_stipple");
139 trace_dump_member_begin("stipple");
140 trace_dump_array(uint,
142 Elements(state->stipple));
143 trace_dump_member_end();
145 trace_dump_struct_end();
149 void trace_dump_viewport_state(const struct pipe_viewport_state *state)
151 if (!trace_dumping_enabled_locked())
159 trace_dump_struct_begin("pipe_viewport_state");
161 trace_dump_member_array(float, state, scale);
162 trace_dump_member_array(float, state, translate);
164 trace_dump_struct_end();
168 void trace_dump_scissor_state(const struct pipe_scissor_state *state)
170 if (!trace_dumping_enabled_locked())
178 trace_dump_struct_begin("pipe_scissor_state");
180 trace_dump_member(uint, state, minx);
181 trace_dump_member(uint, state, miny);
182 trace_dump_member(uint, state, maxx);
183 trace_dump_member(uint, state, maxy);
185 trace_dump_struct_end();
189 void trace_dump_clip_state(const struct pipe_clip_state *state)
193 if (!trace_dumping_enabled_locked())
201 trace_dump_struct_begin("pipe_clip_state");
203 trace_dump_member_begin("ucp");
204 trace_dump_array_begin();
205 for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
206 trace_dump_elem_begin();
207 trace_dump_array(float, state->ucp[i], 4);
208 trace_dump_elem_end();
210 trace_dump_array_end();
211 trace_dump_member_end();
213 trace_dump_member(uint, state, nr);
215 trace_dump_struct_end();
219 void trace_dump_shader_state(const struct pipe_shader_state *state)
221 static char str[8192];
223 if (!trace_dumping_enabled_locked())
231 tgsi_dump_str(state->tokens, 0, str, sizeof(str));
233 trace_dump_struct_begin("pipe_shader_state");
235 trace_dump_member_begin("tokens");
236 trace_dump_string(str);
237 trace_dump_member_end();
239 trace_dump_struct_end();
243 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
247 if (!trace_dumping_enabled_locked())
255 trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
257 trace_dump_member_begin("depth");
258 trace_dump_struct_begin("pipe_depth_state");
259 trace_dump_member(bool, &state->depth, enabled);
260 trace_dump_member(bool, &state->depth, writemask);
261 trace_dump_member(uint, &state->depth, func);
262 trace_dump_struct_end();
263 trace_dump_member_end();
265 trace_dump_member_begin("stencil");
266 trace_dump_array_begin();
267 for(i = 0; i < Elements(state->stencil); ++i) {
268 trace_dump_elem_begin();
269 trace_dump_struct_begin("pipe_stencil_state");
270 trace_dump_member(bool, &state->stencil[i], enabled);
271 trace_dump_member(uint, &state->stencil[i], func);
272 trace_dump_member(uint, &state->stencil[i], fail_op);
273 trace_dump_member(uint, &state->stencil[i], zpass_op);
274 trace_dump_member(uint, &state->stencil[i], zfail_op);
275 trace_dump_member(uint, &state->stencil[i], valuemask);
276 trace_dump_member(uint, &state->stencil[i], writemask);
277 trace_dump_struct_end();
278 trace_dump_elem_end();
280 trace_dump_array_end();
281 trace_dump_member_end();
283 trace_dump_member_begin("alpha");
284 trace_dump_struct_begin("pipe_alpha_state");
285 trace_dump_member(bool, &state->alpha, enabled);
286 trace_dump_member(uint, &state->alpha, func);
287 trace_dump_member(float, &state->alpha, ref_value);
288 trace_dump_struct_end();
289 trace_dump_member_end();
291 trace_dump_struct_end();
294 void trace_dump_blend_state(const struct pipe_blend_state *state)
296 if (!trace_dumping_enabled_locked())
304 trace_dump_bytes(state, sizeof *state);
308 void trace_dump_blend_color(const struct pipe_blend_color *state)
310 if (!trace_dumping_enabled_locked())
318 trace_dump_struct_begin("pipe_blend_color");
320 trace_dump_member_array(float, state, color);
322 trace_dump_struct_end();
325 void trace_dump_stencil_ref(const struct pipe_stencil_ref *state)
327 if (!trace_dumping_enabled_locked())
335 trace_dump_struct_begin("pipe_stencil_ref");
337 trace_dump_member_array(uint, state, ref_value);
339 trace_dump_struct_end();
342 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
344 if (!trace_dumping_enabled_locked())
347 trace_dump_struct_begin("pipe_framebuffer_state");
349 trace_dump_member(uint, state, width);
350 trace_dump_member(uint, state, height);
351 trace_dump_member(uint, state, nr_cbufs);
352 trace_dump_member_array(ptr, state, cbufs);
353 trace_dump_member(ptr, state, zsbuf);
355 trace_dump_struct_end();
359 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
361 if (!trace_dumping_enabled_locked())
369 trace_dump_struct_begin("pipe_sampler_state");
371 trace_dump_member(uint, state, wrap_s);
372 trace_dump_member(uint, state, wrap_t);
373 trace_dump_member(uint, state, wrap_r);
374 trace_dump_member(uint, state, min_img_filter);
375 trace_dump_member(uint, state, min_mip_filter);
376 trace_dump_member(uint, state, mag_img_filter);
377 trace_dump_member(uint, state, compare_mode);
378 trace_dump_member(uint, state, compare_func);
379 trace_dump_member(bool, state, normalized_coords);
380 trace_dump_member(uint, state, max_anisotropy);
381 trace_dump_member(float, state, lod_bias);
382 trace_dump_member(float, state, min_lod);
383 trace_dump_member(float, state, max_lod);
384 trace_dump_member_array(float, state, border_color);
386 trace_dump_struct_end();
390 void trace_dump_surface(const struct pipe_surface *state)
392 if (!trace_dumping_enabled_locked())
400 trace_dump_struct_begin("pipe_surface");
402 trace_dump_member(format, state, format);
403 trace_dump_member(uint, state, width);
404 trace_dump_member(uint, state, height);
406 trace_dump_member(uint, state, layout);
407 trace_dump_member(uint, state, offset);
408 trace_dump_member(uint, state, usage);
410 trace_dump_member(ptr, state, texture);
411 trace_dump_member(uint, state, face);
412 trace_dump_member(uint, state, level);
413 trace_dump_member(uint, state, zslice);
415 trace_dump_struct_end();
419 void trace_dump_transfer(const struct pipe_transfer *state)
421 if (!trace_dumping_enabled_locked())
429 trace_dump_struct_begin("pipe_transfer");
431 trace_dump_member(uint, state, width);
432 trace_dump_member(uint, state, height);
434 trace_dump_member(uint, state, stride);
435 trace_dump_member(uint, state, usage);
437 trace_dump_member(ptr, state, texture);
438 trace_dump_member(uint, state, face);
439 trace_dump_member(uint, state, level);
440 trace_dump_member(uint, state, zslice);
442 trace_dump_struct_end();
446 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
448 if (!trace_dumping_enabled_locked())
456 trace_dump_struct_begin("pipe_vertex_buffer");
458 trace_dump_member(uint, state, stride);
459 trace_dump_member(uint, state, max_index);
460 trace_dump_member(uint, state, buffer_offset);
461 trace_dump_member(buffer_ptr, state, buffer);
463 trace_dump_struct_end();
467 void trace_dump_vertex_element(const struct pipe_vertex_element *state)
469 if (!trace_dumping_enabled_locked())
477 trace_dump_struct_begin("pipe_vertex_element");
479 trace_dump_member(uint, state, src_offset);
481 trace_dump_member(uint, state, vertex_buffer_index);
483 trace_dump_member(format, state, src_format);
485 trace_dump_struct_end();