[Mesa-dev] [PATCH 04/12] gallium/util: improve dump functions
Marek Olšák
maraeo at gmail.com
Thu Jul 16 09:54:41 PDT 2015
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_dump.h | 20 ++-
src/gallium/auxiliary/util/u_dump_defines.c | 41 +++++
src/gallium/auxiliary/util/u_dump_state.c | 233 ++++++++++++++++++++++------
3 files changed, 241 insertions(+), 53 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 3ddf518..1c0e879 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -88,14 +88,16 @@ util_dump_tex_filter(unsigned value, boolean shortened);
const char *
util_dump_query_type(unsigned value, boolean shortened);
+const char *
+util_dump_mode(unsigned value, boolean shortened);
+
/*
* p_state.h, through a FILE
*/
void
-util_dump_template(FILE *stream,
- const struct pipe_resource *templat);
+util_dump_resource(FILE *stream, const struct pipe_resource *state);
void
util_dump_rasterizer_state(FILE *stream,
@@ -157,10 +159,20 @@ void
util_dump_image_view(FILE *stream, const struct pipe_image_view *state);
void
+util_dump_sampler_view(FILE *stream, const struct pipe_sampler_view *state);
+
+void
util_dump_transfer(FILE *stream,
const struct pipe_transfer *state);
void
+util_dump_constant_buffer(FILE *stream,
+ const struct pipe_constant_buffer *state);
+
+void
+util_dump_index_buffer(FILE *stream, const struct pipe_index_buffer *state);
+
+void
util_dump_vertex_buffer(FILE *stream,
const struct pipe_vertex_buffer *state);
@@ -169,6 +181,10 @@ util_dump_vertex_element(FILE *stream,
const struct pipe_vertex_element *state);
void
+util_dump_stream_output_target(FILE *stream,
+ const struct pipe_stream_output_target *state);
+
+void
util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state);
void
diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
index 03fd15d..9021887 100644
--- a/src/gallium/auxiliary/util/u_dump_defines.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -392,3 +392,44 @@ util_dump_query_type_short_names[] = {
};
DEFINE_UTIL_DUMP_CONTINUOUS(query_type)
+
+
+static const char *
+util_dump_mode_names[] = {
+ "PIPE_PRIM_POINTS",
+ "PIPE_PRIM_LINES",
+ "PIPE_PRIM_LINE_LOOP",
+ "PIPE_PRIM_LINE_STRIP",
+ "PIPE_PRIM_TRIANGLES",
+ "PIPE_PRIM_TRIANGLE_STRIP",
+ "PIPE_PRIM_TRIANGLE_FAN",
+ "PIPE_PRIM_QUADS",
+ "PIPE_PRIM_QUAD_STRIP",
+ "PIPE_PRIM_POLYGON",
+ "PIPE_PRIM_LINES_ADJACENCY",
+ "PIPE_PRIM_LINE_STRIP_ADJACENCY",
+ "PIPE_PRIM_TRIANGLES_ADJACENCY",
+ "PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY",
+ "PIPE_PRIM_PATCHES",
+};
+
+static const char *
+util_dump_mode_short_names[] = {
+ "points",
+ "lines",
+ "line_loop",
+ "line_strip",
+ "triangles",
+ "triangle_strip",
+ "triangle_fan",
+ "quads",
+ "quad_strip",
+ "polygon",
+ "lines_adjacency",
+ "line_strip_adjacency",
+ "triangles_adjacency",
+ "triangle_strip_adjacency",
+ "patches",
+};
+
+DEFINE_UTIL_DUMP_CONTINUOUS(mode)
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index b4c92f0..58f8cbe 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -247,6 +247,42 @@ util_dump_enum_func(FILE *stream, unsigned value)
util_dump_enum(stream, util_dump_func(value, TRUE));
}
+static void
+util_dump_enum_mode(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_mode(value, TRUE));
+}
+
+static void
+util_dump_enum_tex_target(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_tex_target(value, TRUE));
+}
+
+static void
+util_dump_enum_tex_filter(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_tex_filter(value, TRUE));
+}
+
+static void
+util_dump_enum_tex_mipfilter(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_tex_mipfilter(value, TRUE));
+}
+
+static void
+util_dump_enum_tex_wrap(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_tex_wrap(value, TRUE));
+}
+
+static void
+util_dump_enum_stencil_op(FILE *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_stencil_op(value, TRUE));
+}
+
/*
* Public functions
@@ -254,38 +290,28 @@ util_dump_enum_func(FILE *stream, unsigned value)
void
-util_dump_template(FILE *stream, const struct pipe_resource *templat)
+util_dump_resource(FILE *stream, const struct pipe_resource *state)
{
- if(!templat) {
+ if(!state) {
util_dump_null(stream);
return;
}
util_dump_struct_begin(stream, "pipe_resource");
- util_dump_member(stream, int, templat, target);
- util_dump_member(stream, format, templat, format);
-
- util_dump_member_begin(stream, "width");
- util_dump_uint(stream, templat->width0);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "height");
- util_dump_uint(stream, templat->height0);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "depth");
- util_dump_uint(stream, templat->depth0);
- util_dump_member_end(stream);
+ util_dump_member(stream, enum_tex_target, state, target);
+ util_dump_member(stream, format, state, format);
- util_dump_member_begin(stream, "array_size");
- util_dump_uint(stream, templat->array_size);
- util_dump_member_end(stream);
+ util_dump_member(stream, uint, state, width0);
+ util_dump_member(stream, uint, state, height0);
+ util_dump_member(stream, uint, state, depth0);
+ util_dump_member(stream, uint, state, array_size);
- util_dump_member(stream, uint, templat, last_level);
- util_dump_member(stream, uint, templat, usage);
- util_dump_member(stream, uint, templat, bind);
- util_dump_member(stream, uint, templat, flags);
+ util_dump_member(stream, uint, state, last_level);
+ util_dump_member(stream, uint, state, nr_samples);
+ util_dump_member(stream, uint, state, usage);
+ util_dump_member(stream, uint, state, bind);
+ util_dump_member(stream, uint, state, flags);
util_dump_struct_end(stream);
}
@@ -319,6 +345,7 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta
util_dump_member(stream, uint, state, sprite_coord_enable);
util_dump_member(stream, bool, state, sprite_coord_mode);
util_dump_member(stream, bool, state, point_quad_rasterization);
+ util_dump_member(stream, bool, state, point_tri_clip);
util_dump_member(stream, bool, state, point_size_per_vertex);
util_dump_member(stream, bool, state, multisample);
util_dump_member(stream, bool, state, line_smooth);
@@ -331,6 +358,7 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta
util_dump_member(stream, bool, state, bottom_edge_rule);
util_dump_member(stream, bool, state, rasterizer_discard);
util_dump_member(stream, bool, state, depth_clip);
+ util_dump_member(stream, bool, state, clip_halfz);
util_dump_member(stream, uint, state, clip_plane_enable);
util_dump_member(stream, float, state, line_width);
@@ -441,25 +469,27 @@ util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state)
fprintf(stream, "\"");
util_dump_member_end(stream);
- util_dump_member_begin(stream, "stream_output");
- util_dump_struct_begin(stream, "pipe_stream_output_info");
- util_dump_member(stream, uint, &state->stream_output, num_outputs);
- util_dump_array(stream, uint, state->stream_output.stride,
- Elements(state->stream_output.stride));
- util_dump_array_begin(stream);
- for(i = 0; i < state->stream_output.num_outputs; ++i) {
- util_dump_elem_begin(stream);
- util_dump_struct_begin(stream, ""); /* anonymous */
- util_dump_member(stream, uint, &state->stream_output.output[i], register_index);
- util_dump_member(stream, uint, &state->stream_output.output[i], start_component);
- util_dump_member(stream, uint, &state->stream_output.output[i], num_components);
- util_dump_member(stream, uint, &state->stream_output.output[i], output_buffer);
+ if (state->stream_output.num_outputs) {
+ util_dump_member_begin(stream, "stream_output");
+ util_dump_struct_begin(stream, "pipe_stream_output_info");
+ util_dump_member(stream, uint, &state->stream_output, num_outputs);
+ util_dump_array(stream, uint, state->stream_output.stride,
+ Elements(state->stream_output.stride));
+ util_dump_array_begin(stream);
+ for(i = 0; i < state->stream_output.num_outputs; ++i) {
+ util_dump_elem_begin(stream);
+ util_dump_struct_begin(stream, ""); /* anonymous */
+ util_dump_member(stream, uint, &state->stream_output.output[i], register_index);
+ util_dump_member(stream, uint, &state->stream_output.output[i], start_component);
+ util_dump_member(stream, uint, &state->stream_output.output[i], num_components);
+ util_dump_member(stream, uint, &state->stream_output.output[i], output_buffer);
+ util_dump_struct_end(stream);
+ util_dump_elem_end(stream);
+ }
+ util_dump_array_end(stream);
util_dump_struct_end(stream);
- util_dump_elem_end(stream);
+ util_dump_member_end(stream);
}
- util_dump_array_end(stream);
- util_dump_struct_end(stream);
- util_dump_member_end(stream);
util_dump_struct_end(stream);
}
@@ -495,9 +525,12 @@ util_dump_depth_stencil_alpha_state(FILE *stream, const struct pipe_depth_stenci
util_dump_member(stream, bool, &state->stencil[i], enabled);
if (state->stencil[i].enabled) {
util_dump_member(stream, enum_func, &state->stencil[i], func);
- util_dump_member(stream, uint, &state->stencil[i], fail_op);
- util_dump_member(stream, uint, &state->stencil[i], zpass_op);
- util_dump_member(stream, uint, &state->stencil[i], zfail_op);
+ util_dump_member(stream, enum_stencil_op,
+ &state->stencil[i], fail_op);
+ util_dump_member(stream, enum_stencil_op,
+ &state->stencil[i], zpass_op);
+ util_dump_member(stream, enum_stencil_op,
+ &state->stencil[i], zfail_op);
util_dump_member(stream, uint, &state->stencil[i], valuemask);
util_dump_member(stream, uint, &state->stencil[i], writemask);
}
@@ -554,6 +587,8 @@ util_dump_blend_state(FILE *stream, const struct pipe_blend_state *state)
util_dump_struct_begin(stream, "pipe_blend_state");
util_dump_member(stream, bool, state, dither);
+ util_dump_member(stream, bool, state, alpha_to_coverage);
+ util_dump_member(stream, bool, state, alpha_to_one);
util_dump_member(stream, bool, state, logicop_enable);
if (state->logicop_enable) {
@@ -628,16 +663,17 @@ util_dump_sampler_state(FILE *stream, const struct pipe_sampler_state *state)
util_dump_struct_begin(stream, "pipe_sampler_state");
- util_dump_member(stream, uint, state, wrap_s);
- util_dump_member(stream, uint, state, wrap_t);
- util_dump_member(stream, uint, state, wrap_r);
- util_dump_member(stream, uint, state, min_img_filter);
- util_dump_member(stream, uint, state, min_mip_filter);
- util_dump_member(stream, uint, state, mag_img_filter);
+ util_dump_member(stream, enum_tex_wrap, state, wrap_s);
+ util_dump_member(stream, enum_tex_wrap, state, wrap_t);
+ util_dump_member(stream, enum_tex_wrap, state, wrap_r);
+ util_dump_member(stream, enum_tex_filter, state, min_img_filter);
+ util_dump_member(stream, enum_tex_mipfilter, state, min_mip_filter);
+ util_dump_member(stream, enum_tex_filter, state, mag_img_filter);
util_dump_member(stream, uint, state, compare_mode);
util_dump_member(stream, enum_func, state, compare_func);
util_dump_member(stream, bool, state, normalized_coords);
util_dump_member(stream, uint, state, max_anisotropy);
+ util_dump_member(stream, bool, state, seamless_cube_map);
util_dump_member(stream, float, state, lod_bias);
util_dump_member(stream, float, state, min_lod);
util_dump_member(stream, float, state, max_lod);
@@ -698,6 +734,40 @@ util_dump_image_view(FILE *stream, const struct pipe_image_view *state)
void
+util_dump_sampler_view(FILE *stream, const struct pipe_sampler_view *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_sampler_view");
+
+ util_dump_member(stream, enum_tex_target, state, target);
+ util_dump_member(stream, format, state, format);
+ util_dump_member(stream, ptr, state, texture);
+
+ if (state->target == PIPE_BUFFER) {
+ util_dump_member(stream, uint, state, u.buf.first_element);
+ util_dump_member(stream, uint, state, u.buf.last_element);
+ }
+ else {
+ util_dump_member(stream, uint, state, u.tex.first_layer);
+ util_dump_member(stream, uint, state, u.tex.last_layer);
+ util_dump_member(stream, uint, state, u.tex.last_level);
+ util_dump_member(stream, uint, state, u.tex.last_level);
+ }
+
+ util_dump_member(stream, uint, state, swizzle_r);
+ util_dump_member(stream, uint, state, swizzle_g);
+ util_dump_member(stream, uint, state, swizzle_b);
+ util_dump_member(stream, uint, state, swizzle_a);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
util_dump_transfer(FILE *stream, const struct pipe_transfer *state)
{
if(!state) {
@@ -721,6 +791,45 @@ util_dump_transfer(FILE *stream, const struct pipe_transfer *state)
void
+util_dump_constant_buffer(FILE *stream,
+ const struct pipe_constant_buffer *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_constant_buffer");
+
+ util_dump_member(stream, ptr, state, buffer);
+ util_dump_member(stream, uint, state, buffer_offset);
+ util_dump_member(stream, uint, state, buffer_size);
+ util_dump_member(stream, ptr, state, user_buffer);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_index_buffer(FILE *stream, const struct pipe_index_buffer *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_index_buffer");
+
+ util_dump_member(stream, uint, state, index_size);
+ util_dump_member(stream, uint, state, offset);
+ util_dump_member(stream, ptr, state, buffer);
+ util_dump_member(stream, ptr, state, user_buffer);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state)
{
if(!state) {
@@ -733,6 +842,7 @@ util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state)
util_dump_member(stream, uint, state, stride);
util_dump_member(stream, uint, state, buffer_offset);
util_dump_member(stream, ptr, state, buffer);
+ util_dump_member(stream, ptr, state, user_buffer);
util_dump_struct_end(stream);
}
@@ -758,6 +868,25 @@ util_dump_vertex_element(FILE *stream, const struct pipe_vertex_element *state)
void
+util_dump_stream_output_target(FILE *stream,
+ const struct pipe_stream_output_target *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_stream_output_target");
+
+ util_dump_member(stream, ptr, state, buffer);
+ util_dump_member(stream, uint, state, buffer_offset);
+ util_dump_member(stream, uint, state, buffer_size);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
{
if(!state) {
@@ -769,7 +898,7 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
util_dump_member(stream, bool, state, indexed);
- util_dump_member(stream, uint, state, mode);
+ util_dump_member(stream, enum_mode, state, mode);
util_dump_member(stream, uint, state, start);
util_dump_member(stream, uint, state, count);
@@ -856,12 +985,14 @@ void util_dump_blit_info(FILE *stream, const struct pipe_blit_info *info)
util_dump_member_begin(stream, "mask");
util_dump_string(stream, mask);
util_dump_member_end(stream);
- util_dump_member(stream, uint, info, filter);
+ util_dump_member(stream, enum_tex_filter, info, filter);
util_dump_member(stream, bool, info, scissor_enable);
util_dump_member_begin(stream, "scissor");
util_dump_scissor_state(stream, &info->scissor);
util_dump_member_end(stream);
+ util_dump_member(stream, bool, info, render_condition_enable);
+
util_dump_struct_end(stream);
}
--
2.1.0
More information about the mesa-dev
mailing list