gallium: Remove prefilter member from pipe_sampler_state struct.
[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);
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_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_reference(&state->reference);
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 static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state)
327 {
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);
331
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);
335
336 trace_dump_member(uint, state, colormask);
337
338 }
339
340 void trace_dump_blend_state(const struct pipe_blend_state *state)
341 {
342 unsigned valid_entries = 1;
343 if (!trace_dumping_enabled_locked())
344 return;
345
346 if(!state) {
347 trace_dump_null();
348 return;
349 }
350
351 trace_dump_struct_begin("pipe_blend_state");
352
353 trace_dump_member(bool, state, dither);
354
355 trace_dump_member(bool, state, logicop_enable);
356 trace_dump_member(uint, state, logicop_func);
357
358 trace_dump_member(bool, state, independent_blend_enable);
359
360 if (state->independent_blend_enable)
361 valid_entries = PIPE_MAX_COLOR_BUFS;
362
363 trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
364
365 trace_dump_struct_end();
366 }
367
368
369 void trace_dump_blend_color(const struct pipe_blend_color *state)
370 {
371 if (!trace_dumping_enabled_locked())
372 return;
373
374 if(!state) {
375 trace_dump_null();
376 return;
377 }
378
379 trace_dump_struct_begin("pipe_blend_color");
380
381 trace_dump_member_array(float, state, color);
382
383 trace_dump_struct_end();
384 }
385
386
387 void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
388 {
389 if (!trace_dumping_enabled_locked())
390 return;
391
392 trace_dump_struct_begin("pipe_framebuffer_state");
393
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);
399
400 trace_dump_struct_end();
401 }
402
403
404 void trace_dump_sampler_state(const struct pipe_sampler_state *state)
405 {
406 if (!trace_dumping_enabled_locked())
407 return;
408
409 if(!state) {
410 trace_dump_null();
411 return;
412 }
413
414 trace_dump_struct_begin("pipe_sampler_state");
415
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);
430
431 trace_dump_struct_end();
432 }
433
434
435 void trace_dump_surface(const struct pipe_surface *state)
436 {
437 if (!trace_dumping_enabled_locked())
438 return;
439
440 if(!state) {
441 trace_dump_null();
442 return;
443 }
444
445 trace_dump_struct_begin("pipe_surface");
446
447 trace_dump_reference(&state->reference);
448
449 trace_dump_member(format, state, format);
450 trace_dump_member(uint, state, width);
451 trace_dump_member(uint, state, height);
452
453 trace_dump_member(uint, state, layout);
454 trace_dump_member(uint, state, offset);
455 trace_dump_member(uint, state, usage);
456
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);
461
462 trace_dump_struct_end();
463 }
464
465
466 void trace_dump_transfer(const struct pipe_transfer *state)
467 {
468 if (!trace_dumping_enabled_locked())
469 return;
470
471 if(!state) {
472 trace_dump_null();
473 return;
474 }
475
476 trace_dump_struct_begin("pipe_transfer");
477
478 trace_dump_member(uint, state, width);
479 trace_dump_member(uint, state, height);
480
481 trace_dump_member(uint, state, stride);
482 trace_dump_member(uint, state, usage);
483
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);
488
489 trace_dump_struct_end();
490 }
491
492
493 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
494 {
495 if (!trace_dumping_enabled_locked())
496 return;
497
498 if(!state) {
499 trace_dump_null();
500 return;
501 }
502
503 trace_dump_struct_begin("pipe_vertex_buffer");
504
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);
509
510 trace_dump_struct_end();
511 }
512
513
514 void trace_dump_vertex_element(const struct pipe_vertex_element *state)
515 {
516 if (!trace_dumping_enabled_locked())
517 return;
518
519 if(!state) {
520 trace_dump_null();
521 return;
522 }
523
524 trace_dump_struct_begin("pipe_vertex_element");
525
526 trace_dump_member(uint, state, src_offset);
527
528 trace_dump_member(uint, state, vertex_buffer_index);
529 trace_dump_member(uint, state, nr_components);
530
531 trace_dump_member(format, state, src_format);
532
533 trace_dump_struct_end();
534 }