Merge branch 'gallium-noblocks'
[mesa.git] / src / gallium / drivers / trace / tr_dump_state.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
25 *
26 **************************************************************************/
27
28
29 #include "pipe/p_compiler.h"
30 #include "util/u_memory.h"
31 #include "tgsi/tgsi_dump.h"
32
33 #include "tr_dump.h"
34 #include "tr_dump_state.h"
35
36
37 void trace_dump_format(enum pipe_format format)
38 {
39 if (!trace_dumping_enabled_locked())
40 return;
41
42 trace_dump_enum(pf_name(format) );
43 }
44
45
46 static void trace_dump_reference(const struct pipe_reference *reference)
47 {
48 if (!trace_dumping_enabled_locked())
49 return;
50
51 trace_dump_struct_begin("pipe_reference");
52 trace_dump_member(int, &reference->count, count);
53 trace_dump_struct_end();
54 }
55
56
57 void trace_dump_template(const struct pipe_texture *templat)
58 {
59 if (!trace_dumping_enabled_locked())
60 return;
61
62 if(!templat) {
63 trace_dump_null();
64 return;
65 }
66
67 trace_dump_struct_begin("pipe_texture");
68
69 trace_dump_member(int, templat, target);
70 trace_dump_member(format, templat, format);
71
72 trace_dump_member_begin("width");
73 trace_dump_uint(templat->width0);
74 trace_dump_member_end();
75
76 trace_dump_member_begin("height");
77 trace_dump_uint(templat->height0);
78 trace_dump_member_end();
79
80 trace_dump_member_begin("depth");
81 trace_dump_uint(templat->depth0);
82 trace_dump_member_end();
83
84 trace_dump_member(uint, templat, last_level);
85 trace_dump_member(uint, templat, tex_usage);
86
87 trace_dump_struct_end();
88 }
89
90
91 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
92 {
93 if (!trace_dumping_enabled_locked())
94 return;
95
96 if(!state) {
97 trace_dump_null();
98 return;
99 }
100
101 trace_dump_struct_begin("pipe_rasterizer_state");
102
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);
126
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);
133
134 trace_dump_member_array(uint, state, sprite_coord_mode);
135
136 trace_dump_struct_end();
137 }
138
139
140 void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
141 {
142 if (!trace_dumping_enabled_locked())
143 return;
144
145 if(!state) {
146 trace_dump_null();
147 return;
148 }
149
150 trace_dump_struct_begin("pipe_poly_stipple");
151
152 trace_dump_member_begin("stipple");
153 trace_dump_array(uint,
154 state->stipple,
155 Elements(state->stipple));
156 trace_dump_member_end();
157
158 trace_dump_struct_end();
159 }
160
161
162 void trace_dump_viewport_state(const struct pipe_viewport_state *state)
163 {
164 if (!trace_dumping_enabled_locked())
165 return;
166
167 if(!state) {
168 trace_dump_null();
169 return;
170 }
171
172 trace_dump_struct_begin("pipe_viewport_state");
173
174 trace_dump_member_array(float, state, scale);
175 trace_dump_member_array(float, state, translate);
176
177 trace_dump_struct_end();
178 }
179
180
181 void trace_dump_scissor_state(const struct pipe_scissor_state *state)
182 {
183 if (!trace_dumping_enabled_locked())
184 return;
185
186 if(!state) {
187 trace_dump_null();
188 return;
189 }
190
191 trace_dump_struct_begin("pipe_scissor_state");
192
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);
197
198 trace_dump_struct_end();
199 }
200
201
202 void trace_dump_clip_state(const struct pipe_clip_state *state)
203 {
204 unsigned i;
205
206 if (!trace_dumping_enabled_locked())
207 return;
208
209 if(!state) {
210 trace_dump_null();
211 return;
212 }
213
214 trace_dump_struct_begin("pipe_clip_state");
215
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();
222 }
223 trace_dump_array_end();
224 trace_dump_member_end();
225
226 trace_dump_member(uint, state, nr);
227
228 trace_dump_struct_end();
229 }
230
231
232 void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
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_constant_buffer");
243
244 trace_dump_member(buffer_ptr, state, buffer);
245
246 trace_dump_struct_end();
247 }
248
249
250 void trace_dump_shader_state(const struct pipe_shader_state *state)
251 {
252 static char str[8192];
253
254 if (!trace_dumping_enabled_locked())
255 return;
256
257 if(!state) {
258 trace_dump_null();
259 return;
260 }
261
262 tgsi_dump_str(state->tokens, 0, str, sizeof(str));
263
264 trace_dump_struct_begin("pipe_shader_state");
265
266 trace_dump_member_begin("tokens");
267 trace_dump_string(str);
268 trace_dump_member_end();
269
270 trace_dump_struct_end();
271 }
272
273
274 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
275 {
276 unsigned i;
277
278 if (!trace_dumping_enabled_locked())
279 return;
280
281 if(!state) {
282 trace_dump_null();
283 return;
284 }
285
286 trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
287
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();
295
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();
311 }
312 trace_dump_array_end();
313 trace_dump_member_end();
314
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();
322
323 trace_dump_struct_end();
324 }
325
326
327 void trace_dump_blend_state(const struct pipe_blend_state *state)
328 {
329 if (!trace_dumping_enabled_locked())
330 return;
331
332 if(!state) {
333 trace_dump_null();
334 return;
335 }
336
337 trace_dump_struct_begin("pipe_blend_state");
338
339 trace_dump_member(bool, state, blend_enable);
340
341 trace_dump_member(uint, state, rgb_func);
342 trace_dump_member(uint, state, rgb_src_factor);
343 trace_dump_member(uint, state, rgb_dst_factor);
344
345 trace_dump_member(uint, state, alpha_func);
346 trace_dump_member(uint, state, alpha_src_factor);
347 trace_dump_member(uint, state, alpha_dst_factor);
348
349 trace_dump_member(bool, state, logicop_enable);
350 trace_dump_member(uint, state, logicop_func);
351
352 trace_dump_member(uint, state, colormask);
353 trace_dump_member(bool, state, dither);
354
355 trace_dump_struct_end();
356 }
357
358
359 void trace_dump_blend_color(const struct pipe_blend_color *state)
360 {
361 if (!trace_dumping_enabled_locked())
362 return;
363
364 if(!state) {
365 trace_dump_null();
366 return;
367 }
368
369 trace_dump_struct_begin("pipe_blend_color");
370
371 trace_dump_member_array(float, state, color);
372
373 trace_dump_struct_end();
374 }
375
376
377 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
378 {
379 if (!trace_dumping_enabled_locked())
380 return;
381
382 trace_dump_struct_begin("pipe_framebuffer_state");
383
384 trace_dump_member(uint, state, width);
385 trace_dump_member(uint, state, height);
386 trace_dump_member(uint, state, nr_cbufs);
387 trace_dump_member_array(ptr, state, cbufs);
388 trace_dump_member(ptr, state, zsbuf);
389
390 trace_dump_struct_end();
391 }
392
393
394 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
395 {
396 if (!trace_dumping_enabled_locked())
397 return;
398
399 if(!state) {
400 trace_dump_null();
401 return;
402 }
403
404 trace_dump_struct_begin("pipe_sampler_state");
405
406 trace_dump_member(uint, state, wrap_s);
407 trace_dump_member(uint, state, wrap_t);
408 trace_dump_member(uint, state, wrap_r);
409 trace_dump_member(uint, state, min_img_filter);
410 trace_dump_member(uint, state, min_mip_filter);
411 trace_dump_member(uint, state, mag_img_filter);
412 trace_dump_member(bool, state, compare_mode);
413 trace_dump_member(uint, state, compare_func);
414 trace_dump_member(bool, state, normalized_coords);
415 trace_dump_member(uint, state, prefilter);
416 trace_dump_member(float, state, lod_bias);
417 trace_dump_member(float, state, min_lod);
418 trace_dump_member(float, state, max_lod);
419 trace_dump_member_array(float, state, border_color);
420 trace_dump_member(float, state, max_anisotropy);
421
422 trace_dump_struct_end();
423 }
424
425
426 void trace_dump_surface(const struct pipe_surface *state)
427 {
428 if (!trace_dumping_enabled_locked())
429 return;
430
431 if(!state) {
432 trace_dump_null();
433 return;
434 }
435
436 trace_dump_struct_begin("pipe_surface");
437
438 trace_dump_reference(&state->reference);
439
440 trace_dump_member(format, state, format);
441 trace_dump_member(uint, state, width);
442 trace_dump_member(uint, state, height);
443
444 trace_dump_member(uint, state, layout);
445 trace_dump_member(uint, state, offset);
446 trace_dump_member(uint, state, usage);
447
448 trace_dump_member(ptr, state, texture);
449 trace_dump_member(uint, state, face);
450 trace_dump_member(uint, state, level);
451 trace_dump_member(uint, state, zslice);
452
453 trace_dump_struct_end();
454 }
455
456
457 void trace_dump_transfer(const struct pipe_transfer *state)
458 {
459 if (!trace_dumping_enabled_locked())
460 return;
461
462 if(!state) {
463 trace_dump_null();
464 return;
465 }
466
467 trace_dump_struct_begin("pipe_transfer");
468
469 trace_dump_member(uint, state, width);
470 trace_dump_member(uint, state, height);
471
472 trace_dump_member(uint, state, stride);
473 trace_dump_member(uint, state, usage);
474
475 trace_dump_member(ptr, state, texture);
476 trace_dump_member(uint, state, face);
477 trace_dump_member(uint, state, level);
478 trace_dump_member(uint, state, zslice);
479
480 trace_dump_struct_end();
481 }
482
483
484 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
485 {
486 if (!trace_dumping_enabled_locked())
487 return;
488
489 if(!state) {
490 trace_dump_null();
491 return;
492 }
493
494 trace_dump_struct_begin("pipe_vertex_buffer");
495
496 trace_dump_member(uint, state, stride);
497 trace_dump_member(uint, state, max_index);
498 trace_dump_member(uint, state, buffer_offset);
499 trace_dump_member(buffer_ptr, state, buffer);
500
501 trace_dump_struct_end();
502 }
503
504
505 void trace_dump_vertex_element(const struct pipe_vertex_element *state)
506 {
507 if (!trace_dumping_enabled_locked())
508 return;
509
510 if(!state) {
511 trace_dump_null();
512 return;
513 }
514
515 trace_dump_struct_begin("pipe_vertex_element");
516
517 trace_dump_member(uint, state, src_offset);
518
519 trace_dump_member(uint, state, vertex_buffer_index);
520 trace_dump_member(uint, state, nr_components);
521
522 trace_dump_member(format, state, src_format);
523
524 trace_dump_struct_end();
525 }