"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/auxiliary/util/u_dump_state.c" (16 Sep 2020, 30075 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "u_dump_state.c" see the Fossies "Dox" file reference documentation.

    1 /**************************************************************************
    2  *
    3  * Copyright 2008-2010 VMware, Inc.
    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 VMWARE 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 "util/u_string.h"
   32 #include "util/format/u_format.h"
   33 #include "tgsi/tgsi_dump.h"
   34 
   35 #include <inttypes.h>
   36 
   37 #include "u_dump.h"
   38 
   39 
   40 /*
   41  * Dump primitives
   42  */
   43 
   44 static inline void
   45 util_stream_writef(FILE *stream, const char *format, ...)
   46 {
   47    static char buf[1024];
   48    unsigned len;
   49    va_list ap;
   50    va_start(ap, format);
   51    len = vsnprintf(buf, sizeof(buf), format, ap);
   52    va_end(ap);
   53    fwrite(buf, len, 1, stream);
   54 }
   55 
   56 static void
   57 util_dump_bool(FILE *stream, int value)
   58 {
   59    util_stream_writef(stream, "%c", value ? '1' : '0');
   60 }
   61 
   62 static void
   63 util_dump_int(FILE *stream, long long int value)
   64 {
   65    util_stream_writef(stream, "%lli", value);
   66 }
   67 
   68 static void
   69 util_dump_uint(FILE *stream, long long unsigned value)
   70 {
   71    util_stream_writef(stream, "%llu", value);
   72 }
   73 
   74 static void
   75 util_dump_float(FILE *stream, double value)
   76 {
   77    util_stream_writef(stream, "%g", value);
   78 }
   79 
   80 void
   81 util_dump_ns(FILE *f, uint64_t time)
   82 {
   83    uint64_t secs = time / (1000*1000*1000);
   84    unsigned usecs = (time % (1000*1000*1000)) / 1000;
   85    fprintf(f, "%"PRIu64".%06us", secs, usecs);
   86 }
   87 
   88 static void
   89 util_dump_string(FILE *stream, const char *str)
   90 {
   91    fputs("\"", stream);
   92    fputs(str, stream);
   93    fputs("\"", stream);
   94 }
   95 
   96 static void
   97 util_dump_enum(FILE *stream, const char *value)
   98 {
   99    fputs(value, stream);
  100 }
  101 
  102 static void
  103 util_dump_array_begin(FILE *stream)
  104 {
  105    fputs("{", stream);
  106 }
  107 
  108 static void
  109 util_dump_array_end(FILE *stream)
  110 {
  111    fputs("}", stream);
  112 }
  113 
  114 static void
  115 util_dump_elem_begin(UNUSED FILE *stream)
  116 {
  117 }
  118 
  119 static void
  120 util_dump_elem_end(FILE *stream)
  121 {
  122    fputs(", ", stream);
  123 }
  124 
  125 static void
  126 util_dump_struct_begin(FILE *stream, UNUSED const char *name)
  127 {
  128    fputs("{", stream);
  129 }
  130 
  131 static void
  132 util_dump_struct_end(FILE *stream)
  133 {
  134    fputs("}", stream);
  135 }
  136 
  137 static void
  138 util_dump_member_begin(FILE *stream, const char *name)
  139 {
  140    util_stream_writef(stream, "%s = ", name);
  141 }
  142 
  143 static void
  144 util_dump_member_end(FILE *stream)
  145 {
  146    fputs(", ", stream);
  147 }
  148 
  149 static void
  150 util_dump_null(FILE *stream)
  151 {
  152    fputs("NULL", stream);
  153 }
  154 
  155 void
  156 util_dump_ptr(FILE *stream, const void *value)
  157 {
  158    if(value)
  159       util_stream_writef(stream, "%p", value);
  160    else
  161       util_dump_null(stream);
  162 }
  163 
  164 
  165 /*
  166  * Code saving macros.
  167  */
  168 
  169 #define util_dump_arg(_stream, _type, _arg) \
  170    do { \
  171       util_dump_arg_begin(_stream, #_arg); \
  172       util_dump_##_type(_stream, _arg); \
  173       util_dump_arg_end(_stream); \
  174    } while(0)
  175 
  176 #define util_dump_ret(_stream, _type, _arg) \
  177    do { \
  178       util_dump_ret_begin(_stream); \
  179       util_dump_##_type(_stream, _arg); \
  180       util_dump_ret_end(_stream); \
  181    } while(0)
  182 
  183 #define util_dump_array(_stream, _type, _obj, _size) \
  184    do { \
  185       size_t idx; \
  186       util_dump_array_begin(_stream); \
  187       for(idx = 0; idx < (_size); ++idx) { \
  188          util_dump_elem_begin(_stream); \
  189          util_dump_##_type(_stream, (_obj)[idx]); \
  190          util_dump_elem_end(_stream); \
  191       } \
  192       util_dump_array_end(_stream); \
  193    } while(0)
  194 
  195 #define util_dump_struct_array(_stream, _type, _obj, _size) \
  196    do { \
  197       size_t idx; \
  198       util_dump_array_begin(_stream); \
  199       for(idx = 0; idx < (_size); ++idx) { \
  200          util_dump_elem_begin(_stream); \
  201          util_dump_##_type(_stream, &(_obj)[idx]); \
  202          util_dump_elem_end(_stream); \
  203       } \
  204       util_dump_array_end(_stream); \
  205    } while(0)
  206 
  207 #define util_dump_member(_stream, _type, _obj, _member) \
  208    do { \
  209       util_dump_member_begin(_stream, #_member); \
  210       util_dump_##_type(_stream, (_obj)->_member); \
  211       util_dump_member_end(_stream); \
  212    } while(0)
  213 
  214 #define util_dump_arg_array(_stream, _type, _arg, _size) \
  215    do { \
  216       util_dump_arg_begin(_stream, #_arg); \
  217       util_dump_array(_stream, _type, _arg, _size); \
  218       util_dump_arg_end(_stream); \
  219    } while(0)
  220 
  221 #define util_dump_member_array(_stream, _type, _obj, _member) \
  222    do { \
  223       util_dump_member_begin(_stream, #_member); \
  224       util_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
  225       util_dump_member_end(_stream); \
  226    } while(0)
  227 
  228 
  229 
  230 /*
  231  * Wrappers for enum -> string dumpers.
  232  */
  233 
  234 
  235 static void
  236 util_dump_format(FILE *stream, enum pipe_format format)
  237 {
  238    util_dump_enum(stream, util_format_name(format));
  239 }
  240 
  241 
  242 static void
  243 util_dump_enum_blend_factor(FILE *stream, unsigned value)
  244 {
  245    util_dump_enum(stream, util_str_blend_factor(value, TRUE));
  246 }
  247 
  248 static void
  249 util_dump_enum_blend_func(FILE *stream, unsigned value)
  250 {
  251    util_dump_enum(stream, util_str_blend_func(value, TRUE));
  252 }
  253 
  254 static void
  255 util_dump_enum_func(FILE *stream, unsigned value)
  256 {
  257    util_dump_enum(stream, util_str_func(value, TRUE));
  258 }
  259 
  260 static void
  261 util_dump_enum_prim_mode(FILE *stream, unsigned value)
  262 {
  263    util_dump_enum(stream, util_str_prim_mode(value, TRUE));
  264 }
  265 
  266 static void
  267 util_dump_enum_tex_target(FILE *stream, unsigned value)
  268 {
  269    util_dump_enum(stream, util_str_tex_target(value, TRUE));
  270 }
  271 
  272 static void
  273 util_dump_enum_tex_filter(FILE *stream, unsigned value)
  274 {
  275    util_dump_enum(stream, util_str_tex_filter(value, TRUE));
  276 }
  277 
  278 static void
  279 util_dump_enum_tex_mipfilter(FILE *stream, unsigned value)
  280 {
  281    util_dump_enum(stream, util_str_tex_mipfilter(value, TRUE));
  282 }
  283 
  284 static void
  285 util_dump_enum_tex_wrap(FILE *stream, unsigned value)
  286 {
  287    util_dump_enum(stream, util_str_tex_wrap(value, TRUE));
  288 }
  289 
  290 static void
  291 util_dump_enum_stencil_op(FILE *stream, unsigned value)
  292 {
  293    util_dump_enum(stream, util_str_stencil_op(value, TRUE));
  294 }
  295 
  296 
  297 /*
  298  * Public functions
  299  */
  300 
  301 
  302 void
  303 util_dump_resource(FILE *stream, const struct pipe_resource *state)
  304 {
  305    if (!state) {
  306       util_dump_null(stream);
  307       return;
  308    }
  309 
  310    util_dump_struct_begin(stream, "pipe_resource");
  311 
  312    util_dump_member(stream, enum_tex_target, state, target);
  313    util_dump_member(stream, format, state, format);
  314 
  315    util_dump_member(stream, uint, state, width0);
  316    util_dump_member(stream, uint, state, height0);
  317    util_dump_member(stream, uint, state, depth0);
  318    util_dump_member(stream, uint, state, array_size);
  319 
  320    util_dump_member(stream, uint, state, last_level);
  321    util_dump_member(stream, uint, state, nr_samples);
  322    util_dump_member(stream, uint, state, nr_storage_samples);
  323    util_dump_member(stream, uint, state, usage);
  324    util_dump_member(stream, uint, state, bind);
  325    util_dump_member(stream, uint, state, flags);
  326 
  327    util_dump_struct_end(stream);
  328 }
  329 
  330 
  331 void
  332 util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *state)
  333 {
  334    if (!state) {
  335       util_dump_null(stream);
  336       return;
  337    }
  338 
  339    util_dump_struct_begin(stream, "pipe_rasterizer_state");
  340 
  341    util_dump_member(stream, bool, state, flatshade);
  342    util_dump_member(stream, bool, state, light_twoside);
  343    util_dump_member(stream, bool, state, clamp_vertex_color);
  344    util_dump_member(stream, bool, state, clamp_fragment_color);
  345    util_dump_member(stream, uint, state, front_ccw);
  346    util_dump_member(stream, uint, state, cull_face);
  347    util_dump_member(stream, uint, state, fill_front);
  348    util_dump_member(stream, uint, state, fill_back);
  349    util_dump_member(stream, bool, state, offset_point);
  350    util_dump_member(stream, bool, state, offset_line);
  351    util_dump_member(stream, bool, state, offset_tri);
  352    util_dump_member(stream, bool, state, scissor);
  353    util_dump_member(stream, bool, state, poly_smooth);
  354    util_dump_member(stream, bool, state, poly_stipple_enable);
  355    util_dump_member(stream, bool, state, point_smooth);
  356    util_dump_member(stream, uint, state, sprite_coord_enable);
  357    util_dump_member(stream, bool, state, sprite_coord_mode);
  358    util_dump_member(stream, bool, state, point_quad_rasterization);
  359    util_dump_member(stream, bool, state, point_tri_clip);
  360    util_dump_member(stream, bool, state, point_size_per_vertex);
  361    util_dump_member(stream, bool, state, multisample);
  362    util_dump_member(stream, bool, state, line_smooth);
  363    util_dump_member(stream, bool, state, line_stipple_enable);
  364    util_dump_member(stream, uint, state, line_stipple_factor);
  365    util_dump_member(stream, uint, state, line_stipple_pattern);
  366    util_dump_member(stream, bool, state, line_last_pixel);
  367    util_dump_member(stream, bool, state, flatshade_first);
  368    util_dump_member(stream, bool, state, half_pixel_center);
  369    util_dump_member(stream, bool, state, bottom_edge_rule);
  370    util_dump_member(stream, bool, state, rasterizer_discard);
  371    util_dump_member(stream, bool, state, depth_clip_near);
  372    util_dump_member(stream, bool, state, depth_clip_far);
  373    util_dump_member(stream, bool, state, clip_halfz);
  374    util_dump_member(stream, uint, state, clip_plane_enable);
  375 
  376    util_dump_member(stream, float, state, line_width);
  377    util_dump_member(stream, float, state, point_size);
  378    util_dump_member(stream, float, state, offset_units);
  379    util_dump_member(stream, float, state, offset_scale);
  380    util_dump_member(stream, float, state, offset_clamp);
  381 
  382    util_dump_struct_end(stream);
  383 }
  384 
  385 
  386 void
  387 util_dump_poly_stipple(FILE *stream, const struct pipe_poly_stipple *state)
  388 {
  389    if (!state) {
  390       util_dump_null(stream);
  391       return;
  392    }
  393 
  394    util_dump_struct_begin(stream, "pipe_poly_stipple");
  395 
  396    util_dump_member_begin(stream, "stipple");
  397    util_dump_member_array(stream, uint, state, stipple);
  398    util_dump_member_end(stream);
  399 
  400    util_dump_struct_end(stream);
  401 }
  402 
  403 
  404 void
  405 util_dump_viewport_state(FILE *stream, const struct pipe_viewport_state *state)
  406 {
  407    if (!state) {
  408       util_dump_null(stream);
  409       return;
  410    }
  411 
  412    util_dump_struct_begin(stream, "pipe_viewport_state");
  413 
  414    util_dump_member_array(stream, float, state, scale);
  415    util_dump_member_array(stream, float, state, translate);
  416 
  417    util_dump_struct_end(stream);
  418 }
  419 
  420 
  421 void
  422 util_dump_scissor_state(FILE *stream, const struct pipe_scissor_state *state)
  423 {
  424    if (!state) {
  425       util_dump_null(stream);
  426       return;
  427    }
  428 
  429    util_dump_struct_begin(stream, "pipe_scissor_state");
  430 
  431    util_dump_member(stream, uint, state, minx);
  432    util_dump_member(stream, uint, state, miny);
  433    util_dump_member(stream, uint, state, maxx);
  434    util_dump_member(stream, uint, state, maxy);
  435 
  436    util_dump_struct_end(stream);
  437 }
  438 
  439 
  440 void
  441 util_dump_clip_state(FILE *stream, const struct pipe_clip_state *state)
  442 {
  443    unsigned i;
  444 
  445    if (!state) {
  446       util_dump_null(stream);
  447       return;
  448    }
  449 
  450    util_dump_struct_begin(stream, "pipe_clip_state");
  451 
  452    util_dump_member_begin(stream, "ucp");
  453    util_dump_array_begin(stream);
  454    for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
  455       util_dump_elem_begin(stream);
  456       util_dump_array(stream, float, state->ucp[i], 4);
  457       util_dump_elem_end(stream);
  458    }
  459    util_dump_array_end(stream);
  460    util_dump_member_end(stream);
  461 
  462    util_dump_struct_end(stream);
  463 }
  464 
  465 
  466 void
  467 util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state)
  468 {
  469    unsigned i;
  470 
  471    if (!state) {
  472       util_dump_null(stream);
  473       return;
  474    }
  475 
  476    util_dump_struct_begin(stream, "pipe_shader_state");
  477 
  478    if (state->type == PIPE_SHADER_IR_TGSI) {
  479       util_dump_member_begin(stream, "tokens");
  480       fprintf(stream, "\"\n");
  481       tgsi_dump_to_file(state->tokens, 0, stream);
  482       fprintf(stream, "\"");
  483       util_dump_member_end(stream);
  484    }
  485 
  486    if (state->stream_output.num_outputs) {
  487       util_dump_member_begin(stream, "stream_output");
  488       util_dump_struct_begin(stream, "pipe_stream_output_info");
  489       util_dump_member(stream, uint, &state->stream_output, num_outputs);
  490       util_dump_array(stream, uint, state->stream_output.stride,
  491                       ARRAY_SIZE(state->stream_output.stride));
  492       util_dump_array_begin(stream);
  493       for(i = 0; i < state->stream_output.num_outputs; ++i) {
  494          util_dump_elem_begin(stream);
  495          util_dump_struct_begin(stream, ""); /* anonymous */
  496          util_dump_member(stream, uint, &state->stream_output.output[i], register_index);
  497          util_dump_member(stream, uint, &state->stream_output.output[i], start_component);
  498          util_dump_member(stream, uint, &state->stream_output.output[i], num_components);
  499          util_dump_member(stream, uint, &state->stream_output.output[i], output_buffer);
  500          util_dump_struct_end(stream);
  501          util_dump_elem_end(stream);
  502       }
  503       util_dump_array_end(stream);
  504       util_dump_struct_end(stream);
  505       util_dump_member_end(stream);
  506    }
  507 
  508    util_dump_struct_end(stream);
  509 }
  510 
  511 
  512 void
  513 util_dump_depth_stencil_alpha_state(FILE *stream, const struct pipe_depth_stencil_alpha_state *state)
  514 {
  515    unsigned i;
  516 
  517    if (!state) {
  518       util_dump_null(stream);
  519       return;
  520    }
  521 
  522    util_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state");
  523 
  524    util_dump_member_begin(stream, "depth");
  525    util_dump_struct_begin(stream, "pipe_depth_state");
  526    util_dump_member(stream, bool, &state->depth, enabled);
  527    if (state->depth.enabled) {
  528       util_dump_member(stream, bool, &state->depth, writemask);
  529       util_dump_member(stream, enum_func, &state->depth, func);
  530    }
  531    util_dump_struct_end(stream);
  532    util_dump_member_end(stream);
  533 
  534    util_dump_member_begin(stream, "stencil");
  535    util_dump_array_begin(stream);
  536    for(i = 0; i < ARRAY_SIZE(state->stencil); ++i) {
  537       util_dump_elem_begin(stream);
  538       util_dump_struct_begin(stream, "pipe_stencil_state");
  539       util_dump_member(stream, bool, &state->stencil[i], enabled);
  540       if (state->stencil[i].enabled) {
  541          util_dump_member(stream, enum_func, &state->stencil[i], func);
  542          util_dump_member(stream, enum_stencil_op,
  543                           &state->stencil[i], fail_op);
  544          util_dump_member(stream, enum_stencil_op,
  545                           &state->stencil[i], zpass_op);
  546          util_dump_member(stream, enum_stencil_op,
  547                           &state->stencil[i], zfail_op);
  548          util_dump_member(stream, uint, &state->stencil[i], valuemask);
  549          util_dump_member(stream, uint, &state->stencil[i], writemask);
  550       }
  551       util_dump_struct_end(stream);
  552       util_dump_elem_end(stream);
  553    }
  554    util_dump_array_end(stream);
  555    util_dump_member_end(stream);
  556 
  557    util_dump_member_begin(stream, "alpha");
  558    util_dump_struct_begin(stream, "pipe_alpha_state");
  559    util_dump_member(stream, bool, &state->alpha, enabled);
  560    if (state->alpha.enabled) {
  561       util_dump_member(stream, enum_func, &state->alpha, func);
  562       util_dump_member(stream, float, &state->alpha, ref_value);
  563    }
  564    util_dump_struct_end(stream);
  565    util_dump_member_end(stream);
  566 
  567    util_dump_struct_end(stream);
  568 }
  569 
  570 void
  571 util_dump_rt_blend_state(FILE *stream, const struct pipe_rt_blend_state *state)
  572 {
  573    util_dump_struct_begin(stream, "pipe_rt_blend_state");
  574 
  575    util_dump_member(stream, uint, state, blend_enable);
  576    if (state->blend_enable) {
  577       util_dump_member(stream, enum_blend_func, state, rgb_func);
  578       util_dump_member(stream, enum_blend_factor, state, rgb_src_factor);
  579       util_dump_member(stream, enum_blend_factor, state, rgb_dst_factor);
  580 
  581       util_dump_member(stream, enum_blend_func, state, alpha_func);
  582       util_dump_member(stream, enum_blend_factor, state, alpha_src_factor);
  583       util_dump_member(stream, enum_blend_factor, state, alpha_dst_factor);
  584    }
  585 
  586    util_dump_member(stream, uint, state, colormask);
  587 
  588    util_dump_struct_end(stream);
  589 }
  590 
  591 void
  592 util_dump_blend_state(FILE *stream, const struct pipe_blend_state *state)
  593 {
  594    unsigned valid_entries = 1;
  595 
  596    if (!state) {
  597       util_dump_null(stream);
  598       return;
  599    }
  600 
  601    util_dump_struct_begin(stream, "pipe_blend_state");
  602 
  603    util_dump_member(stream, bool, state, dither);
  604    util_dump_member(stream, bool, state, alpha_to_coverage);
  605    util_dump_member(stream, bool, state, alpha_to_one);
  606    util_dump_member(stream, uint, state, max_rt);
  607 
  608    util_dump_member(stream, bool, state, logicop_enable);
  609    if (state->logicop_enable) {
  610       util_dump_member(stream, enum_func, state, logicop_func);
  611    }
  612    else {
  613       util_dump_member(stream, bool, state, independent_blend_enable);
  614 
  615       util_dump_member_begin(stream, "rt");
  616       if (state->independent_blend_enable)
  617          valid_entries = state->max_rt + 1;
  618       util_dump_struct_array(stream, rt_blend_state, state->rt, valid_entries);
  619       util_dump_member_end(stream);
  620    }
  621 
  622    util_dump_struct_end(stream);
  623 }
  624 
  625 
  626 void
  627 util_dump_blend_color(FILE *stream, const struct pipe_blend_color *state)
  628 {
  629    if (!state) {
  630       util_dump_null(stream);
  631       return;
  632    }
  633 
  634    util_dump_struct_begin(stream, "pipe_blend_color");
  635 
  636    util_dump_member_array(stream, float, state, color);
  637 
  638    util_dump_struct_end(stream);
  639 }
  640 
  641 void
  642 util_dump_stencil_ref(FILE *stream, const struct pipe_stencil_ref *state)
  643 {
  644    if (!state) {
  645       util_dump_null(stream);
  646       return;
  647    }
  648 
  649    util_dump_struct_begin(stream, "pipe_stencil_ref");
  650 
  651    util_dump_member_array(stream, uint, state, ref_value);
  652 
  653    util_dump_struct_end(stream);
  654 }
  655 
  656 void
  657 util_dump_framebuffer_state(FILE *stream, const struct pipe_framebuffer_state *state)
  658 {
  659    util_dump_struct_begin(stream, "pipe_framebuffer_state");
  660 
  661    util_dump_member(stream, uint, state, width);
  662    util_dump_member(stream, uint, state, height);
  663    util_dump_member(stream, uint, state, samples);
  664    util_dump_member(stream, uint, state, layers);
  665    util_dump_member(stream, uint, state, nr_cbufs);
  666    util_dump_member_array(stream, ptr, state, cbufs);
  667    util_dump_member(stream, ptr, state, zsbuf);
  668 
  669    util_dump_struct_end(stream);
  670 }
  671 
  672 
  673 void
  674 util_dump_sampler_state(FILE *stream, const struct pipe_sampler_state *state)
  675 {
  676    if (!state) {
  677       util_dump_null(stream);
  678       return;
  679    }
  680 
  681    util_dump_struct_begin(stream, "pipe_sampler_state");
  682 
  683    util_dump_member(stream, enum_tex_wrap, state, wrap_s);
  684    util_dump_member(stream, enum_tex_wrap, state, wrap_t);
  685    util_dump_member(stream, enum_tex_wrap, state, wrap_r);
  686    util_dump_member(stream, enum_tex_filter, state, min_img_filter);
  687    util_dump_member(stream, enum_tex_mipfilter, state, min_mip_filter);
  688    util_dump_member(stream, enum_tex_filter, state, mag_img_filter);
  689    util_dump_member(stream, uint, state, compare_mode);
  690    util_dump_member(stream, enum_func, state, compare_func);
  691    util_dump_member(stream, bool, state, normalized_coords);
  692    util_dump_member(stream, uint, state, max_anisotropy);
  693    util_dump_member(stream, bool, state, seamless_cube_map);
  694    util_dump_member(stream, float, state, lod_bias);
  695    util_dump_member(stream, float, state, min_lod);
  696    util_dump_member(stream, float, state, max_lod);
  697    util_dump_member_array(stream, float, state, border_color.f);
  698 
  699    util_dump_struct_end(stream);
  700 }
  701 
  702 
  703 void
  704 util_dump_surface(FILE *stream, const struct pipe_surface *state)
  705 {
  706    if (!state) {
  707       util_dump_null(stream);
  708       return;
  709    }
  710 
  711    util_dump_struct_begin(stream, "pipe_surface");
  712 
  713    util_dump_member(stream, format, state, format);
  714    util_dump_member(stream, uint, state, width);
  715    util_dump_member(stream, uint, state, height);
  716 
  717    util_dump_member(stream, ptr, state, texture);
  718    util_dump_member(stream, uint, state, u.tex.level);
  719    util_dump_member(stream, uint, state, u.tex.first_layer);
  720    util_dump_member(stream, uint, state, u.tex.last_layer);
  721 
  722    util_dump_struct_end(stream);
  723 }
  724 
  725 
  726 void
  727 util_dump_image_view(FILE *stream, const struct pipe_image_view *state)
  728 {
  729    if (!state) {
  730       util_dump_null(stream);
  731       return;
  732    }
  733 
  734    util_dump_struct_begin(stream, "pipe_image_view");
  735 
  736    util_dump_member(stream, ptr, state, resource);
  737    util_dump_member(stream, format, state, format);
  738 
  739    if (state->resource->target == PIPE_BUFFER) {
  740       util_dump_member(stream, uint, state, u.buf.offset);
  741       util_dump_member(stream, uint, state, u.buf.size);
  742    }
  743    else {
  744       util_dump_member(stream, uint, state, u.tex.first_layer);
  745       util_dump_member(stream, uint, state, u.tex.last_layer);
  746       util_dump_member(stream, uint, state, u.tex.level);
  747    }
  748 
  749    util_dump_struct_end(stream);
  750 }
  751 
  752 
  753 void
  754 util_dump_shader_buffer(FILE *stream, const struct pipe_shader_buffer *state)
  755 {
  756    if (!state) {
  757       util_dump_null(stream);
  758       return;
  759    }
  760 
  761    util_dump_struct_begin(stream, "pipe_shader_buffer");
  762 
  763    util_dump_member(stream, ptr, state, buffer);
  764    util_dump_member(stream, uint, state, buffer_offset);
  765    util_dump_member(stream, uint, state, buffer_size);
  766 
  767    util_dump_struct_end(stream);
  768 
  769 }
  770 
  771 
  772 void
  773 util_dump_sampler_view(FILE *stream, const struct pipe_sampler_view *state)
  774 {
  775    if (!state) {
  776       util_dump_null(stream);
  777       return;
  778    }
  779 
  780    util_dump_struct_begin(stream, "pipe_sampler_view");
  781 
  782    util_dump_member(stream, enum_tex_target, state, target);
  783    util_dump_member(stream, format, state, format);
  784    util_dump_member(stream, ptr, state, texture);
  785 
  786    if (state->target == PIPE_BUFFER) {
  787       util_dump_member(stream, uint, state, u.buf.offset);
  788       util_dump_member(stream, uint, state, u.buf.size);
  789    }
  790    else {
  791       util_dump_member(stream, uint, state, u.tex.first_layer);
  792       util_dump_member(stream, uint, state, u.tex.last_layer);
  793       util_dump_member(stream, uint, state, u.tex.first_level);
  794       util_dump_member(stream, uint, state, u.tex.last_level);
  795    }
  796 
  797    util_dump_member(stream, uint, state, swizzle_r);
  798    util_dump_member(stream, uint, state, swizzle_g);
  799    util_dump_member(stream, uint, state, swizzle_b);
  800    util_dump_member(stream, uint, state, swizzle_a);
  801 
  802    util_dump_struct_end(stream);
  803 }
  804 
  805 
  806 void
  807 util_dump_transfer(FILE *stream, const struct pipe_transfer *state)
  808 {
  809    if (!state) {
  810       util_dump_null(stream);
  811       return;
  812    }
  813 
  814    util_dump_struct_begin(stream, "pipe_transfer");
  815 
  816    util_dump_member(stream, ptr, state, resource);
  817    util_dump_member(stream, uint, state, level);
  818    util_dump_member(stream, transfer_usage, state, usage);
  819    util_dump_member_begin(stream, "box");
  820    util_dump_box(stream, &state->box);
  821    util_dump_member_end(stream);
  822    util_dump_member(stream, uint, state, stride);
  823    util_dump_member(stream, uint, state, layer_stride);
  824 
  825    util_dump_struct_end(stream);
  826 }
  827 
  828 
  829 void
  830 util_dump_constant_buffer(FILE *stream,
  831                           const struct pipe_constant_buffer *state)
  832 {
  833    if (!state) {
  834       util_dump_null(stream);
  835       return;
  836    }
  837 
  838    util_dump_struct_begin(stream, "pipe_constant_buffer");
  839 
  840    util_dump_member(stream, ptr, state, buffer);
  841    util_dump_member(stream, uint, state, buffer_offset);
  842    util_dump_member(stream, uint, state, buffer_size);
  843    util_dump_member(stream, ptr, state, user_buffer);
  844 
  845    util_dump_struct_end(stream);
  846 }
  847 
  848 
  849 void
  850 util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state)
  851 {
  852    if (!state) {
  853       util_dump_null(stream);
  854       return;
  855    }
  856 
  857    util_dump_struct_begin(stream, "pipe_vertex_buffer");
  858 
  859    util_dump_member(stream, uint, state, stride);
  860    util_dump_member(stream, bool, state, is_user_buffer);
  861    util_dump_member(stream, uint, state, buffer_offset);
  862    util_dump_member(stream, ptr, state, buffer.resource);
  863 
  864    util_dump_struct_end(stream);
  865 }
  866 
  867 
  868 void
  869 util_dump_vertex_element(FILE *stream, const struct pipe_vertex_element *state)
  870 {
  871    if (!state) {
  872       util_dump_null(stream);
  873       return;
  874    }
  875 
  876    util_dump_struct_begin(stream, "pipe_vertex_element");
  877 
  878    util_dump_member(stream, uint, state, src_offset);
  879    util_dump_member(stream, uint, state, instance_divisor);
  880    util_dump_member(stream, uint, state, vertex_buffer_index);
  881    util_dump_member(stream, format, state, src_format);
  882 
  883    util_dump_struct_end(stream);
  884 }
  885 
  886 
  887 void
  888 util_dump_stream_output_target(FILE *stream,
  889                                const struct pipe_stream_output_target *state)
  890 {
  891    if (!state) {
  892       util_dump_null(stream);
  893       return;
  894    }
  895 
  896    util_dump_struct_begin(stream, "pipe_stream_output_target");
  897 
  898    util_dump_member(stream, ptr, state, buffer);
  899    util_dump_member(stream, uint, state, buffer_offset);
  900    util_dump_member(stream, uint, state, buffer_size);
  901 
  902    util_dump_struct_end(stream);
  903 }
  904 
  905 
  906 void
  907 util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
  908 {
  909    if (!state) {
  910       util_dump_null(stream);
  911       return;
  912    }
  913 
  914    util_dump_struct_begin(stream, "pipe_draw_info");
  915 
  916    util_dump_member(stream, uint, state, index_size);
  917    util_dump_member(stream, uint, state, has_user_indices);
  918 
  919    util_dump_member(stream, enum_prim_mode, state, mode);
  920    util_dump_member(stream, uint, state, start);
  921    util_dump_member(stream, uint, state, count);
  922 
  923    util_dump_member(stream, uint, state, start_instance);
  924    util_dump_member(stream, uint, state, instance_count);
  925 
  926    util_dump_member(stream, uint, state, drawid);
  927 
  928    util_dump_member(stream, uint, state, vertices_per_patch);
  929 
  930    util_dump_member(stream, int,  state, index_bias);
  931    util_dump_member(stream, uint, state, min_index);
  932    util_dump_member(stream, uint, state, max_index);
  933 
  934    util_dump_member(stream, bool, state, primitive_restart);
  935    if (state->primitive_restart)
  936       util_dump_member(stream, uint, state, restart_index);
  937 
  938    if (state->index_size) {
  939       if (state->has_user_indices)
  940          util_dump_member(stream, ptr, state, index.user);
  941       else
  942          util_dump_member(stream, ptr, state, index.resource);
  943    }
  944    util_dump_member(stream, ptr, state, count_from_stream_output);
  945 
  946    if (!state->indirect) {
  947       util_dump_member(stream, ptr, state, indirect);
  948    } else {
  949       util_dump_member(stream, uint, state, indirect->offset);
  950       util_dump_member(stream, uint, state, indirect->stride);
  951       util_dump_member(stream, uint, state, indirect->draw_count);
  952       util_dump_member(stream, uint, state, indirect->indirect_draw_count_offset);
  953       util_dump_member(stream, ptr, state, indirect->buffer);
  954       util_dump_member(stream, ptr, state, indirect->indirect_draw_count);
  955    }
  956 
  957    util_dump_struct_end(stream);
  958 }
  959 
  960 void util_dump_grid_info(FILE *stream, const struct pipe_grid_info *state)
  961 {
  962    if (!state) {
  963       util_dump_null(stream);
  964       return;
  965    }
  966 
  967    util_dump_struct_begin(stream, "pipe_grid_info");
  968 
  969    util_dump_member(stream, uint, state, pc);
  970    util_dump_member(stream, ptr, state, input);
  971    util_dump_member(stream, uint, state, work_dim);
  972 
  973    util_dump_member_begin(stream, "block");
  974    util_dump_array(stream, uint, state->block, ARRAY_SIZE(state->block));
  975    util_dump_member_end(stream);
  976 
  977    util_dump_member_begin(stream, "grid");
  978    util_dump_array(stream, uint, state->grid, ARRAY_SIZE(state->grid));
  979    util_dump_member_end(stream);
  980 
  981    util_dump_member(stream, ptr, state, indirect);
  982    util_dump_member(stream, uint, state, indirect_offset);
  983 
  984    util_dump_struct_end(stream);
  985 }
  986 
  987 void util_dump_box(FILE *stream, const struct pipe_box *box)
  988 {
  989    if (!box) {
  990       util_dump_null(stream);
  991       return;
  992    }
  993 
  994    util_dump_struct_begin(stream, "pipe_box");
  995 
  996    util_dump_member(stream, int, box, x);
  997    util_dump_member(stream, int, box, y);
  998    util_dump_member(stream, int, box, z);
  999    util_dump_member(stream, int, box, width);
 1000    util_dump_member(stream, int, box, height);
 1001    util_dump_member(stream, int, box, depth);
 1002 
 1003    util_dump_struct_end(stream);
 1004 }
 1005 
 1006 void util_dump_blit_info(FILE *stream, const struct pipe_blit_info *info)
 1007 {
 1008    char mask[7];
 1009 
 1010    if (!info) {
 1011       util_dump_null(stream);
 1012       return;
 1013    }
 1014 
 1015    util_dump_struct_begin(stream, "pipe_blit_info");
 1016 
 1017    util_dump_member_begin(stream, "dst");
 1018    util_dump_struct_begin(stream, "dst");
 1019    util_dump_member(stream, ptr, &info->dst, resource);
 1020    util_dump_member(stream, uint, &info->dst, level);
 1021    util_dump_member(stream, format, &info->dst, format);
 1022    util_dump_member_begin(stream, "box");
 1023    util_dump_box(stream, &info->dst.box);
 1024    util_dump_member_end(stream);
 1025    util_dump_struct_end(stream);
 1026    util_dump_member_end(stream);
 1027 
 1028    util_dump_member_begin(stream, "src");
 1029    util_dump_struct_begin(stream, "src");
 1030    util_dump_member(stream, ptr, &info->src, resource);
 1031    util_dump_member(stream, uint, &info->src, level);
 1032    util_dump_member(stream, format, &info->src, format);
 1033    util_dump_member_begin(stream, "box");
 1034    util_dump_box(stream, &info->src.box);
 1035    util_dump_member_end(stream);
 1036    util_dump_struct_end(stream);
 1037    util_dump_member_end(stream);
 1038 
 1039    mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-';
 1040    mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-';
 1041    mask[2] = (info->mask & PIPE_MASK_B) ? 'B' : '-';
 1042    mask[3] = (info->mask & PIPE_MASK_A) ? 'A' : '-';
 1043    mask[4] = (info->mask & PIPE_MASK_Z) ? 'Z' : '-';
 1044    mask[5] = (info->mask & PIPE_MASK_S) ? 'S' : '-';
 1045    mask[6] = 0;
 1046 
 1047    util_dump_member_begin(stream, "mask");
 1048    util_dump_string(stream, mask);
 1049    util_dump_member_end(stream);
 1050    util_dump_member(stream, enum_tex_filter, info, filter);
 1051 
 1052    util_dump_member(stream, bool, info, scissor_enable);
 1053    util_dump_member_begin(stream, "scissor");
 1054    util_dump_scissor_state(stream, &info->scissor);
 1055    util_dump_member_end(stream);
 1056 
 1057    util_dump_member(stream, bool, info, render_condition_enable);
 1058 
 1059    util_dump_struct_end(stream);
 1060 }