summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c78
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h8
-rw-r--r--src/gallium/auxiliary/util/u_debug.c121
-rw-r--r--src/gallium/auxiliary/util/u_debug_dump.h77
-rw-r--r--src/gallium/auxiliary/util/u_dump.h173
-rw-r--r--src/gallium/auxiliary/util/u_dump_defines.c (renamed from src/gallium/auxiliary/util/u_debug_dump.c)93
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c709
-rw-r--r--src/gallium/auxiliary/util/u_format.h13
8 files changed, 979 insertions, 293 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index f3b4491d17..18f8606818 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -60,13 +60,12 @@ struct blitter_context_priv
float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */
/* Templates for various state objects. */
- struct pipe_depth_stencil_alpha_state template_dsa;
struct pipe_sampler_state template_sampler_state;
/* Constant state objects. */
/* Vertex shaders. */
void *vs_col; /**< Vertex shader which passes {pos, color} to the output */
- void *vs_tex; /**<Vertex shader which passes {pos, texcoord} to the output.*/
+ void *vs_tex; /**< Vertex shader which passes {pos, texcoord} to the output.*/
/* Fragment shaders. */
/* FS which outputs a color to multiple color buffers. */
@@ -85,7 +84,7 @@ struct blitter_context_priv
void *blend_keep_color; /**< blend state with writemask of 0 */
/* Depth stencil alpha state. */
- void *dsa_write_depth_stencil[0xff]; /**< indices are stencil clear values */
+ void *dsa_write_depth_stencil;
void *dsa_write_depth_keep_stencil;
void *dsa_keep_depth_stencil;
@@ -99,9 +98,9 @@ struct blitter_context_priv
struct blitter_context *util_blitter_create(struct pipe_context *pipe)
{
struct blitter_context_priv *ctx;
- struct pipe_blend_state blend;
- struct pipe_depth_stencil_alpha_state *dsa;
- struct pipe_rasterizer_state rs_state;
+ struct pipe_blend_state blend = { 0 };
+ struct pipe_depth_stencil_alpha_state dsa = { { 0 } };
+ struct pipe_rasterizer_state rs_state = { 0 };
struct pipe_sampler_state *sampler_state;
unsigned i;
@@ -122,30 +121,30 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
ctx->blitter.saved_num_sampler_states = ~0;
/* blend state objects */
- memset(&blend, 0, sizeof(blend));
ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
blend.rt[0].colormask = PIPE_MASK_RGBA;
ctx->blend_write_color = pipe->create_blend_state(pipe, &blend);
/* depth stencil alpha state objects */
- dsa = &ctx->template_dsa;
ctx->dsa_keep_depth_stencil =
- pipe->create_depth_stencil_alpha_state(pipe, dsa);
+ pipe->create_depth_stencil_alpha_state(pipe, &dsa);
- dsa->depth.enabled = 1;
- dsa->depth.writemask = 1;
- dsa->depth.func = PIPE_FUNC_ALWAYS;
+ dsa.depth.enabled = 1;
+ dsa.depth.writemask = 1;
+ dsa.depth.func = PIPE_FUNC_ALWAYS;
ctx->dsa_write_depth_keep_stencil =
- pipe->create_depth_stencil_alpha_state(pipe, dsa);
-
- dsa->stencil[0].enabled = 1;
- dsa->stencil[0].func = PIPE_FUNC_ALWAYS;
- dsa->stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
- dsa->stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
- dsa->stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
- dsa->stencil[0].valuemask = 0xff;
- dsa->stencil[0].writemask = 0xff;
+ pipe->create_depth_stencil_alpha_state(pipe, &dsa);
+
+ dsa.stencil[0].enabled = 1;
+ dsa.stencil[0].func = PIPE_FUNC_ALWAYS;
+ dsa.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+ dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+ dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+ dsa.stencil[0].valuemask = 0xff;
+ dsa.stencil[0].writemask = 0xff;
+ ctx->dsa_write_depth_stencil =
+ pipe->create_depth_stencil_alpha_state(pipe, &dsa);
/* The DSA state objects which write depth and stencil are created
* on-demand. */
@@ -210,11 +209,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
pipe->delete_depth_stencil_alpha_state(pipe,
ctx->dsa_write_depth_keep_stencil);
-
- for (i = 0; i < 0xff; i++)
- if (ctx->dsa_write_depth_stencil[i])
- pipe->delete_depth_stencil_alpha_state(pipe,
- ctx->dsa_write_depth_stencil[i]);
+ pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil);
pipe->delete_rasterizer_state(pipe, ctx->rs_state);
pipe->delete_vs_state(pipe, ctx->vs_col);
@@ -266,6 +261,8 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
ctx->blitter.saved_fs = INVALID_PTR;
ctx->blitter.saved_vs = INVALID_PTR;
+ pipe->set_stencil_ref(pipe, &ctx->blitter.saved_stencil_ref);
+
/* restore the state objects which are required to be saved before copy/fill
*/
if (ctx->blitter.saved_fb_state.nr_cbufs != ~0) {
@@ -413,26 +410,6 @@ static void blitter_draw_quad(struct blitter_context_priv *ctx)
}
static INLINE
-void *blitter_get_state_write_depth_stencil(
- struct blitter_context_priv *ctx,
- unsigned stencil)
-{
- struct pipe_context *pipe = ctx->pipe;
-
- stencil &= 0xff;
-
- /* Create the DSA state on-demand. */
- if (!ctx->dsa_write_depth_stencil[stencil]) {
- ctx->template_dsa.stencil[0].ref_value = stencil;
-
- ctx->dsa_write_depth_stencil[stencil] =
- pipe->create_depth_stencil_alpha_state(pipe, &ctx->template_dsa);
- }
-
- return ctx->dsa_write_depth_stencil[stencil];
-}
-
-static INLINE
void **blitter_get_sampler_state(struct blitter_context_priv *ctx,
int miplevel)
{
@@ -548,6 +525,7 @@ void util_blitter_clear(struct blitter_context *blitter,
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->pipe;
+ struct pipe_stencil_ref sr = { { 0 } };
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
@@ -559,9 +537,11 @@ void util_blitter_clear(struct blitter_context *blitter,
else
pipe->bind_blend_state(pipe, ctx->blend_keep_color);
- if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL)
- pipe->bind_depth_stencil_alpha_state(pipe,
- blitter_get_state_write_depth_stencil(ctx, stencil));
+ if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+ sr.ref_value[0] = stencil & 0xff;
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil);
+ pipe->set_stencil_ref(pipe, &sr);
+ }
else
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 3da5a6ca52..a2f17073ac 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -47,6 +47,7 @@ struct blitter_context
void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */
struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
+ struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
int saved_num_sampler_states;
void *saved_sampler_states[32];
@@ -170,6 +171,13 @@ void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter,
}
static INLINE
+void util_blitter_save_stencil_ref(struct blitter_context *blitter,
+ const struct pipe_stencil_ref *state)
+{
+ blitter->saved_stencil_ref = *state;
+}
+
+static INLINE
void util_blitter_save_rasterizer(struct blitter_context *blitter,
void *state)
{
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 4821b8a143..858d52c6ef 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -288,130 +288,13 @@ debug_dump_flags(const struct debug_named_value *names,
}
-static const struct debug_named_value pipe_format_names[] = {
-#ifdef DEBUG
- DEBUG_NAMED_VALUE(PIPE_FORMAT_NONE),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8R8G8B8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_X8R8G8B8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B8G8R8A8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B8G8R8X8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A1R5G5B5_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A4R4G4B4_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R5G6B5_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A2B10G10R10_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_L8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_I8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8L8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_L16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_YCBCR),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_YCBCR_REV),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_Z16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_Z32_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_Z32_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_S8Z24_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_Z24S8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_X8Z24_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_Z24X8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_S8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R64_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R64G64_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R64G64B64_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R64G64B64A64_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32A32_FLOAT),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32A32_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32A32_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32A32_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R32G32B32A32_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16A16_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16A16_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16A16_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R16G16B16A16_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_UNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_USCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B6G5R5_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8B8G8R8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_X8B8G8R8_SNORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_SSCALED),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_L8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8L8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_A8R8G8B8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_X8R8G8B8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B8G8R8A8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B8G8R8X8_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_X8UB8UG8SR8S_NORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_B6UG5SR5S_NORM),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_RGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_RGBA),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT3_RGBA),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT5_RGBA),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_SRGB),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_SRGBA),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT3_SRGBA),
- DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT5_SRGBA),
-#endif
- DEBUG_NAMED_VALUE_END
-};
-
#ifdef DEBUG
void debug_print_format(const char *msg, unsigned fmt )
{
- debug_printf("%s: %s\n", msg, debug_dump_enum(pipe_format_names, fmt));
+ debug_printf("%s: %s\n", msg, util_format_name(fmt));
}
#endif
-const char *pf_name( enum pipe_format format )
-{
- return debug_dump_enum(pipe_format_names, format);
-}
-
static const struct debug_named_value pipe_prim_names[] = {
@@ -707,7 +590,7 @@ debug_dump_float_rgba_bmp(const char *filename,
bmih.biClrUsed = 0;
bmih.biClrImportant = 0;
- stream = os_stream_create(filename, bmfh.bfSize);
+ stream = os_file_stream_create(filename);
if(!stream)
goto error1;
diff --git a/src/gallium/auxiliary/util/u_debug_dump.h b/src/gallium/auxiliary/util/u_debug_dump.h
deleted file mode 100644
index 19b130ad18..0000000000
--- a/src/gallium/auxiliary/util/u_debug_dump.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- * Dump data in human/machine readable format.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-#ifndef U_DEBUG_DUMP_H_
-#define U_DEBUG_DUMP_H_
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-const char *
-debug_dump_blend_factor(unsigned value, boolean shortened);
-
-const char *
-debug_dump_blend_func(unsigned value, boolean shortened);
-
-const char *
-debug_dump_func(unsigned value, boolean shortened);
-
-const char *
-debug_dump_tex_target(unsigned value, boolean shortened);
-
-const char *
-debug_dump_tex_wrap(unsigned value, boolean shortened);
-
-const char *
-debug_dump_tex_mipfilter(unsigned value, boolean shortened);
-
-const char *
-debug_dump_tex_filter(unsigned value, boolean shortened);
-
-
-/* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* U_DEBUG_H_ */
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
new file mode 100644
index 0000000000..379f18ef38
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -0,0 +1,173 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Dump data in human/machine readable format.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#ifndef U_DEBUG_DUMP_H_
+#define U_DEBUG_DUMP_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define UTIL_DUMP_INVALID_NAME "<invalid>"
+
+
+struct os_stream;
+
+
+/* Duplicated here for convenience */
+extern struct os_stream *
+os_log_stream;
+
+
+/*
+ * p_defines.h
+ *
+ * XXX: These functions don't really dump anything -- just translate into
+ * strings so a verb better than "dump" should be used instead, in order to
+ * free up the namespace to the true dumper functions.
+ */
+
+const char *
+util_dump_blend_factor(unsigned value, boolean shortened);
+
+const char *
+util_dump_blend_func(unsigned value, boolean shortened);
+
+const char *
+util_dump_func(unsigned value, boolean shortened);
+
+const char *
+util_dump_tex_target(unsigned value, boolean shortened);
+
+const char *
+util_dump_tex_wrap(unsigned value, boolean shortened);
+
+const char *
+util_dump_tex_mipfilter(unsigned value, boolean shortened);
+
+const char *
+util_dump_tex_filter(unsigned value, boolean shortened);
+
+
+/*
+ * p_state.h, through an os_stream
+ */
+
+void
+util_dump_template(struct os_stream *stream,
+ const struct pipe_texture *templat);
+
+void
+util_dump_rasterizer_state(struct os_stream *stream,
+ const struct pipe_rasterizer_state *state);
+
+void
+util_dump_poly_stipple(struct os_stream *stream,
+ const struct pipe_poly_stipple *state);
+
+void
+util_dump_viewport_state(struct os_stream *stream,
+ const struct pipe_viewport_state *state);
+
+void
+util_dump_scissor_state(struct os_stream *stream,
+ const struct pipe_scissor_state *state);
+
+void
+util_dump_clip_state(struct os_stream *stream,
+ const struct pipe_clip_state *state);
+
+void
+util_dump_shader_state(struct os_stream *stream,
+ const struct pipe_shader_state *state);
+
+void
+util_dump_depth_stencil_alpha_state(struct os_stream *stream,
+ const struct pipe_depth_stencil_alpha_state *state);
+
+void
+util_dump_rt_blend_state(struct os_stream *stream,
+ const struct pipe_rt_blend_state *state);
+
+void
+util_dump_blend_state(struct os_stream *stream,
+ const struct pipe_blend_state *state);
+
+void
+util_dump_blend_color(struct os_stream *stream,
+ const struct pipe_blend_color *state);
+
+void
+util_dump_stencil_ref(struct os_stream *stream,
+ const struct pipe_stencil_ref *state);
+
+void
+util_dump_framebuffer_state(struct os_stream *stream,
+ const struct pipe_framebuffer_state *state);
+
+void
+util_dump_sampler_state(struct os_stream *stream,
+ const struct pipe_sampler_state *state);
+
+void
+util_dump_surface(struct os_stream *stream,
+ const struct pipe_surface *state);
+
+void
+util_dump_transfer(struct os_stream *stream,
+ const struct pipe_transfer *state);
+
+void
+util_dump_vertex_buffer(struct os_stream *stream,
+ const struct pipe_vertex_buffer *state);
+
+void
+util_dump_vertex_element(struct os_stream *stream,
+ const struct pipe_vertex_element *state);
+
+
+/* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_DEBUG_H_ */
diff --git a/src/gallium/auxiliary/util/u_debug_dump.c b/src/gallium/auxiliary/util/u_dump_defines.c
index 61624d05c0..96a2256347 100644
--- a/src/gallium/auxiliary/util/u_debug_dump.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -28,15 +28,12 @@
#include "util/u_memory.h"
#include "util/u_debug.h"
-#include "util/u_debug_dump.h"
-
-
-#define DEBUG_DUMP_INVALID_NAME "<invalid>"
+#include "util/u_dump.h"
#if 0
static const char *
-debug_dump_strip_prefix(const char *name,
+util_dump_strip_prefix(const char *name,
const char *prefix)
{
const char *stripped;
@@ -55,30 +52,30 @@ debug_dump_strip_prefix(const char *name,
#endif
static const char *
-debug_dump_enum_continuous(unsigned value,
+util_dump_enum_continuous(unsigned value,
unsigned num_names,
const char **names)
{
if (value >= num_names)
- return DEBUG_DUMP_INVALID_NAME;
+ return UTIL_DUMP_INVALID_NAME;
return names[value];
}
-#define DEFINE_DEBUG_DUMP_CONTINUOUS(_name) \
+#define DEFINE_UTIL_DUMP_CONTINUOUS(_name) \
const char * \
- debug_dump_##_name(unsigned value, boolean shortened) \
+ util_dump_##_name(unsigned value, boolean shortened) \
{ \
if(shortened) \
- return debug_dump_enum_continuous(value, Elements(debug_dump_##_name##_short_names), debug_dump_##_name##_short_names); \
+ return util_dump_enum_continuous(value, Elements(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
else \
- return debug_dump_enum_continuous(value, Elements(debug_dump_##_name##_names), debug_dump_##_name##_names); \
+ return util_dump_enum_continuous(value, Elements(util_dump_##_name##_names), util_dump_##_name##_names); \
}
static const char *
-debug_dump_blend_factor_names[] = {
- DEBUG_DUMP_INVALID_NAME, /* 0x0 */
+util_dump_blend_factor_names[] = {
+ UTIL_DUMP_INVALID_NAME, /* 0x0 */
"PIPE_BLENDFACTOR_ONE",
"PIPE_BLENDFACTOR_SRC_COLOR",
"PIPE_BLENDFACTOR_SRC_ALPHA",
@@ -89,18 +86,18 @@ debug_dump_blend_factor_names[] = {
"PIPE_BLENDFACTOR_CONST_ALPHA",
"PIPE_BLENDFACTOR_SRC1_COLOR",
"PIPE_BLENDFACTOR_SRC1_ALPHA",
- DEBUG_DUMP_INVALID_NAME, /* 0x0b */
- DEBUG_DUMP_INVALID_NAME, /* 0x0c */
- DEBUG_DUMP_INVALID_NAME, /* 0x0d */
- DEBUG_DUMP_INVALID_NAME, /* 0x0e */
- DEBUG_DUMP_INVALID_NAME, /* 0x0f */
- DEBUG_DUMP_INVALID_NAME, /* 0x10 */
+ UTIL_DUMP_INVALID_NAME, /* 0x0b */
+ UTIL_DUMP_INVALID_NAME, /* 0x0c */
+ UTIL_DUMP_INVALID_NAME, /* 0x0d */
+ UTIL_DUMP_INVALID_NAME, /* 0x0e */
+ UTIL_DUMP_INVALID_NAME, /* 0x0f */
+ UTIL_DUMP_INVALID_NAME, /* 0x10 */
"PIPE_BLENDFACTOR_ZERO",
"PIPE_BLENDFACTOR_INV_SRC_COLOR",
"PIPE_BLENDFACTOR_INV_SRC_ALPHA",
"PIPE_BLENDFACTOR_INV_DST_ALPHA",
"PIPE_BLENDFACTOR_INV_DST_COLOR",
- DEBUG_DUMP_INVALID_NAME, /* 0x16 */
+ UTIL_DUMP_INVALID_NAME, /* 0x16 */
"PIPE_BLENDFACTOR_INV_CONST_COLOR",
"PIPE_BLENDFACTOR_INV_CONST_ALPHA",
"PIPE_BLENDFACTOR_INV_SRC1_COLOR",
@@ -108,8 +105,8 @@ debug_dump_blend_factor_names[] = {
};
static const char *
-debug_dump_blend_factor_short_names[] = {
- DEBUG_DUMP_INVALID_NAME, /* 0x0 */
+util_dump_blend_factor_short_names[] = {
+ UTIL_DUMP_INVALID_NAME, /* 0x0 */
"one",
"src_color",
"src_alpha",
@@ -120,29 +117,29 @@ debug_dump_blend_factor_short_names[] = {
"const_alpha",
"src1_color",
"src1_alpha",
- DEBUG_DUMP_INVALID_NAME, /* 0x0b */
- DEBUG_DUMP_INVALID_NAME, /* 0x0c */
- DEBUG_DUMP_INVALID_NAME, /* 0x0d */
- DEBUG_DUMP_INVALID_NAME, /* 0x0e */
- DEBUG_DUMP_INVALID_NAME, /* 0x0f */
- DEBUG_DUMP_INVALID_NAME, /* 0x10 */
+ UTIL_DUMP_INVALID_NAME, /* 0x0b */
+ UTIL_DUMP_INVALID_NAME, /* 0x0c */
+ UTIL_DUMP_INVALID_NAME, /* 0x0d */
+ UTIL_DUMP_INVALID_NAME, /* 0x0e */
+ UTIL_DUMP_INVALID_NAME, /* 0x0f */
+ UTIL_DUMP_INVALID_NAME, /* 0x10 */
"zero",
"inv_src_color",
"inv_src_alpha",
"inv_dst_alpha",
"inv_dst_color",
- DEBUG_DUMP_INVALID_NAME, /* 0x16 */
+ UTIL_DUMP_INVALID_NAME, /* 0x16 */
"inv_const_color",
"inv_const_alpha",
"inv_src1_color",
"inv_src1_alpha"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(blend_factor)
+DEFINE_UTIL_DUMP_CONTINUOUS(blend_factor)
static const char *
-debug_dump_blend_func_names[] = {
+util_dump_blend_func_names[] = {
"PIPE_BLEND_ADD",
"PIPE_BLEND_SUBTRACT",
"PIPE_BLEND_REVERSE_SUBTRACT",
@@ -151,7 +148,7 @@ debug_dump_blend_func_names[] = {
};
static const char *
-debug_dump_blend_func_short_names[] = {
+util_dump_blend_func_short_names[] = {
"add",
"sub",
"rev_sub",
@@ -159,11 +156,11 @@ debug_dump_blend_func_short_names[] = {
"max"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(blend_func)
+DEFINE_UTIL_DUMP_CONTINUOUS(blend_func)
static const char *
-debug_dump_func_names[] = {
+util_dump_func_names[] = {
"PIPE_FUNC_NEVER",
"PIPE_FUNC_LESS",
"PIPE_FUNC_EQUAL",
@@ -175,7 +172,7 @@ debug_dump_func_names[] = {
};
static const char *
-debug_dump_func_short_names[] = {
+util_dump_func_short_names[] = {
"never",
"less",
"equal",
@@ -186,11 +183,11 @@ debug_dump_func_short_names[] = {
"always"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(func)
+DEFINE_UTIL_DUMP_CONTINUOUS(func)
static const char *
-debug_dump_tex_target_names[] = {
+util_dump_tex_target_names[] = {
"PIPE_TEXTURE_1D",
"PIPE_TEXTURE_2D",
"PIPE_TEXTURE_3D",
@@ -198,18 +195,18 @@ debug_dump_tex_target_names[] = {
};
static const char *
-debug_dump_tex_target_short_names[] = {
+util_dump_tex_target_short_names[] = {
"1d",
"2d",
"3d",
"cube"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(tex_target)
+DEFINE_UTIL_DUMP_CONTINUOUS(tex_target)
static const char *
-debug_dump_tex_wrap_names[] = {
+util_dump_tex_wrap_names[] = {
"PIPE_TEX_WRAP_REPEAT",
"PIPE_TEX_WRAP_CLAMP",
"PIPE_TEX_WRAP_CLAMP_TO_EDGE",
@@ -221,7 +218,7 @@ debug_dump_tex_wrap_names[] = {
};
static const char *
-debug_dump_tex_wrap_short_names[] = {
+util_dump_tex_wrap_short_names[] = {
"repeat",
"clamp",
"clamp_to_edge",
@@ -232,36 +229,36 @@ debug_dump_tex_wrap_short_names[] = {
"mirror_clamp_to_border"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(tex_wrap)
+DEFINE_UTIL_DUMP_CONTINUOUS(tex_wrap)
static const char *
-debug_dump_tex_mipfilter_names[] = {
+util_dump_tex_mipfilter_names[] = {
"PIPE_TEX_MIPFILTER_NEAREST",
"PIPE_TEX_MIPFILTER_LINEAR",
"PIPE_TEX_MIPFILTER_NONE"
};
static const char *
-debug_dump_tex_mipfilter_short_names[] = {
+util_dump_tex_mipfilter_short_names[] = {
"nearest",
"linear",
"none"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(tex_mipfilter)
+DEFINE_UTIL_DUMP_CONTINUOUS(tex_mipfilter)
static const char *
-debug_dump_tex_filter_names[] = {
+util_dump_tex_filter_names[] = {
"PIPE_TEX_FILTER_NEAREST",
"PIPE_TEX_FILTER_LINEAR"
};
static const char *
-debug_dump_tex_filter_short_names[] = {
+util_dump_tex_filter_short_names[] = {
"nearest",
"linear"
};
-DEFINE_DEBUG_DUMP_CONTINUOUS(tex_filter)
+DEFINE_UTIL_DUMP_CONTINUOUS(tex_filter)
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
new file mode 100644
index 0000000000..eaf4ec90f2
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -0,0 +1,709 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_compiler.h"
+#include "os/os_stream.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
+#include "util/u_format.h"
+#include "tgsi/tgsi_dump.h"
+
+#include "u_dump.h"
+
+
+/*
+ * Dump primitives
+ */
+
+static INLINE void
+util_stream_writef(struct os_stream *stream, const char *format, ...)
+{
+ static char buf[1024];
+ unsigned len;
+ va_list ap;
+ va_start(ap, format);
+ len = util_vsnprintf(buf, sizeof(buf), format, ap);
+ va_end(ap);
+ os_stream_write(stream, buf, len);
+}
+
+static void
+util_dump_bool(struct os_stream *stream, int value)
+{
+ util_stream_writef(stream, "%c", value ? '1' : '0');
+}
+
+static void
+util_dump_int(struct os_stream *stream, long long int value)
+{
+ util_stream_writef(stream, "%lli", value);
+}
+
+static void
+util_dump_uint(struct os_stream *stream, long long unsigned value)
+{
+ util_stream_writef(stream, "%llu", value);
+}
+
+static void
+util_dump_float(struct os_stream *stream, double value)
+{
+ util_stream_writef(stream, "%g", value);
+}
+
+static void
+util_dump_string(struct os_stream *stream, const char *str)
+{
+ os_stream_write_str(stream, "\"");
+ os_stream_write_str(stream, str);
+ os_stream_write_str(stream, "\"");
+}
+
+static void
+util_dump_enum(struct os_stream *stream, const char *value)
+{
+ os_stream_write_str(stream, value);
+}
+
+static void
+util_dump_array_begin(struct os_stream *stream)
+{
+ os_stream_write_str(stream, "{");
+}
+
+static void
+util_dump_array_end(struct os_stream *stream)
+{
+ os_stream_write_str(stream, "}");
+}
+
+static void
+util_dump_elem_begin(struct os_stream *stream)
+{
+}
+
+static void
+util_dump_elem_end(struct os_stream *stream)
+{
+ os_stream_write_str(stream, ", ");
+}
+
+static void
+util_dump_struct_begin(struct os_stream *stream, const char *name)
+{
+ os_stream_write_str(stream, "{");
+}
+
+static void
+util_dump_struct_end(struct os_stream *stream)
+{
+ os_stream_write_str(stream, "}");
+}
+
+static void
+util_dump_member_begin(struct os_stream *stream, const char *name)
+{
+ util_stream_writef(stream, "%s = ", name);
+}
+
+static void
+util_dump_member_end(struct os_stream *stream)
+{
+ os_stream_write_str(stream, ", ");
+}
+
+static void
+util_dump_null(struct os_stream *stream)
+{
+ os_stream_write_str(stream, "NULL");
+}
+
+static void
+util_dump_ptr(struct os_stream *stream, const void *value)
+{
+ if(value)
+ util_stream_writef(stream, "0x%08lx", (unsigned long)(uintptr_t)value);
+ else
+ util_dump_null(stream);
+}
+
+
+/*
+ * Code saving macros.
+ */
+
+#define util_dump_arg(_stream, _type, _arg) \
+ do { \
+ util_dump_arg_begin(_stream, #_arg); \
+ util_dump_##_type(_stream, _arg); \
+ util_dump_arg_end(_stream); \
+ } while(0)
+
+#define util_dump_ret(_stream, _type, _arg) \
+ do { \
+ util_dump_ret_begin(_stream); \
+ util_dump_##_type(_stream, _arg); \
+ util_dump_ret_end(_stream); \
+ } while(0)
+
+#define util_dump_array(_stream, _type, _obj, _size) \
+ do { \
+ size_t idx; \
+ util_dump_array_begin(_stream); \
+ for(idx = 0; idx < (_size); ++idx) { \
+ util_dump_elem_begin(_stream); \
+ util_dump_##_type(_stream, (_obj)[idx]); \
+ util_dump_elem_end(_stream); \
+ } \
+ util_dump_array_end(_stream); \
+ } while(0)
+
+#define util_dump_struct_array(_stream, _type, _obj, _size) \
+ do { \
+ size_t idx; \
+ util_dump_array_begin(_stream); \
+ for(idx = 0; idx < (_size); ++idx) { \
+ util_dump_elem_begin(_stream); \
+ util_dump_##_type(_stream, &(_obj)[idx]); \
+ util_dump_elem_end(_stream); \
+ } \
+ util_dump_array_end(_stream); \
+ } while(0)
+
+#define util_dump_member(_stream, _type, _obj, _member) \
+ do { \
+ util_dump_member_begin(_stream, #_member); \
+ util_dump_##_type(_stream, (_obj)->_member); \
+ util_dump_member_end(_stream); \
+ } while(0)
+
+#define util_dump_arg_array(_stream, _type, _arg, _size) \
+ do { \
+ util_dump_arg_begin(_stream, #_arg); \
+ util_dump_array(_stream, _type, _arg, _size); \
+ util_dump_arg_end(_stream); \
+ } while(0)
+
+#define util_dump_member_array(_stream, _type, _obj, _member) \
+ do { \
+ util_dump_member_begin(_stream, #_member); \
+ util_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
+ util_dump_member_end(_stream); \
+ } while(0)
+
+
+
+/*
+ * Wrappers for enum -> string dumpers.
+ */
+
+
+static void
+util_dump_format(struct os_stream *stream, enum pipe_format format)
+{
+ util_dump_enum(stream, util_format_name(format));
+}
+
+
+static void
+util_dump_enum_blend_factor(struct os_stream *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_blend_factor(value, TRUE));
+}
+
+static void
+util_dump_enum_blend_func(struct os_stream *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_blend_func(value, TRUE));
+}
+
+static void
+util_dump_enum_func(struct os_stream *stream, unsigned value)
+{
+ util_dump_enum(stream, util_dump_func(value, TRUE));
+}
+
+
+/*
+ * Public functions
+ */
+
+
+void
+util_dump_template(struct os_stream *stream, const struct pipe_texture *templat)
+{
+ if(!templat) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_texture");
+
+ 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, uint, templat, last_level);
+ util_dump_member(stream, uint, templat, tex_usage);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterizer_state *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_rasterizer_state");
+
+ util_dump_member(stream, bool, state, flatshade);
+ util_dump_member(stream, bool, state, light_twoside);
+ util_dump_member(stream, uint, state, front_winding);
+ util_dump_member(stream, uint, state, cull_mode);
+ util_dump_member(stream, uint, state, fill_cw);
+ util_dump_member(stream, uint, state, fill_ccw);
+ util_dump_member(stream, bool, state, offset_cw);
+ util_dump_member(stream, bool, state, offset_ccw);
+ util_dump_member(stream, bool, state, scissor);
+ util_dump_member(stream, bool, state, poly_smooth);
+ util_dump_member(stream, bool, state, poly_stipple_enable);
+ util_dump_member(stream, bool, state, point_smooth);
+ 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_size_per_vertex);
+ util_dump_member(stream, bool, state, multisample);
+ util_dump_member(stream, bool, state, line_smooth);
+ util_dump_member(stream, bool, state, line_stipple_enable);
+ util_dump_member(stream, uint, state, line_stipple_factor);
+ util_dump_member(stream, uint, state, line_stipple_pattern);
+ util_dump_member(stream, bool, state, line_last_pixel);
+ util_dump_member(stream, bool, state, bypass_vs_clip_and_viewport);
+ util_dump_member(stream, bool, state, flatshade_first);
+ util_dump_member(stream, bool, state, gl_rasterization_rules);
+
+ util_dump_member(stream, float, state, line_width);
+ util_dump_member(stream, float, state, point_size);
+ util_dump_member(stream, float, state, offset_units);
+ util_dump_member(stream, float, state, offset_scale);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_poly_stipple(struct os_stream *stream, const struct pipe_poly_stipple *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_poly_stipple");
+
+ util_dump_member_begin(stream, "stipple");
+ util_dump_member_array(stream, uint, state, stipple);
+ util_dump_member_end(stream);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_viewport_state(struct os_stream *stream, const struct pipe_viewport_state *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_viewport_state");
+
+ util_dump_member_array(stream, float, state, scale);
+ util_dump_member_array(stream, float, state, translate);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_scissor_state(struct os_stream *stream, const struct pipe_scissor_state *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_scissor_state");
+
+ util_dump_member(stream, uint, state, minx);
+ util_dump_member(stream, uint, state, miny);
+ util_dump_member(stream, uint, state, maxx);
+ util_dump_member(stream, uint, state, maxy);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_clip_state(struct os_stream *stream, const struct pipe_clip_state *state)
+{
+ unsigned i;
+
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_clip_state");
+
+ util_dump_member_begin(stream, "ucp");
+ util_dump_array_begin(stream);
+ for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
+ util_dump_elem_begin(stream);
+ util_dump_array(stream, float, state->ucp[i], 4);
+ util_dump_elem_end(stream);
+ }
+ util_dump_array_end(stream);
+ util_dump_member_end(stream);
+
+ util_dump_member(stream, uint, state, nr);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_shader_state(struct os_stream *stream, const struct pipe_shader_state *state)
+{
+ char str[8192];
+
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ tgsi_dump_str(state->tokens, 0, str, sizeof(str));
+
+ util_dump_struct_begin(stream, "pipe_shader_state");
+
+ util_dump_member_begin(stream, "tokens");
+ util_dump_string(stream, str);
+ util_dump_member_end(stream);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_depth_stencil_alpha_state(struct os_stream *stream, const struct pipe_depth_stencil_alpha_state *state)
+{
+ unsigned i;
+
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state");
+
+ util_dump_member_begin(stream, "depth");
+ util_dump_struct_begin(stream, "pipe_depth_state");
+ util_dump_member(stream, bool, &state->depth, enabled);
+ if (state->depth.enabled) {
+ util_dump_member(stream, bool, &state->depth, writemask);
+ util_dump_member(stream, enum_func, &state->depth, func);
+ }
+ util_dump_struct_end(stream);
+ util_dump_member_end(stream);
+
+ util_dump_member_begin(stream, "stencil");
+ util_dump_array_begin(stream);
+ for(i = 0; i < Elements(state->stencil); ++i) {
+ util_dump_elem_begin(stream);
+ util_dump_struct_begin(stream, "pipe_stencil_state");
+ 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, uint, &state->stencil[i], valuemask);
+ util_dump_member(stream, uint, &state->stencil[i], writemask);
+ }
+ util_dump_struct_end(stream);
+ util_dump_elem_end(stream);
+ }
+ util_dump_array_end(stream);
+ util_dump_member_end(stream);
+
+ util_dump_member_begin(stream, "alpha");
+ util_dump_struct_begin(stream, "pipe_alpha_state");
+ util_dump_member(stream, bool, &state->alpha, enabled);
+ if (state->alpha.enabled) {
+ util_dump_member(stream, enum_func, &state->alpha, func);
+ util_dump_member(stream, float, &state->alpha, ref_value);
+ }
+ util_dump_struct_end(stream);
+ util_dump_member_end(stream);
+
+ util_dump_struct_end(stream);
+}
+
+void
+util_dump_rt_blend_state(struct os_stream *stream, const struct pipe_rt_blend_state *state)
+{
+ util_dump_struct_begin(stream, "pipe_rt_blend_state");
+
+ util_dump_member(stream, uint, state, blend_enable);
+ if (state->blend_enable) {
+ util_dump_member(stream, enum_blend_func, state, rgb_func);
+ util_dump_member(stream, enum_blend_factor, state, rgb_src_factor);
+ util_dump_member(stream, enum_blend_factor, state, rgb_dst_factor);
+
+ util_dump_member(stream, enum_blend_func, state, alpha_func);
+ util_dump_member(stream, enum_blend_factor, state, alpha_src_factor);
+ util_dump_member(stream, enum_blend_factor, state, alpha_dst_factor);
+ }
+
+ util_dump_member(stream, uint, state, colormask);
+
+ util_dump_struct_end(stream);
+}
+
+void
+util_dump_blend_state(struct os_stream *stream, const struct pipe_blend_state *state)
+{
+ unsigned valid_entries = 1;
+
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_blend_state");
+
+ util_dump_member(stream, bool, state, dither);
+
+ util_dump_member(stream, bool, state, logicop_enable);
+ if (state->logicop_enable) {
+ util_dump_member(stream, enum_func, state, logicop_func);
+ }
+ else {
+ util_dump_member(stream, bool, state, independent_blend_enable);
+
+ util_dump_member_begin(stream, "rt");
+ if (state->independent_blend_enable)
+ valid_entries = PIPE_MAX_COLOR_BUFS;
+ util_dump_struct_array(stream, rt_blend_state, state->rt, valid_entries);
+ util_dump_member_end(stream);
+ }
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_blend_color(struct os_stream *stream, const struct pipe_blend_color *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_blend_color");
+
+ util_dump_member_array(stream, float, state, color);
+
+ util_dump_struct_end(stream);
+}
+
+void
+util_dump_stencil_ref(struct os_stream *stream, const struct pipe_stencil_ref *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_stencil_ref");
+
+ util_dump_member_array(stream, uint, state, ref_value);
+
+ util_dump_struct_end(stream);
+}
+
+void
+util_dump_framebuffer_state(struct os_stream *stream, const struct pipe_framebuffer_state *state)
+{
+ util_dump_struct_begin(stream, "pipe_framebuffer_state");
+
+ util_dump_member(stream, uint, state, width);
+ util_dump_member(stream, uint, state, height);
+ util_dump_member(stream, uint, state, nr_cbufs);
+ util_dump_member_array(stream, ptr, state, cbufs);
+ util_dump_member(stream, ptr, state, zsbuf);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_state *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ 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, 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, float, state, lod_bias);
+ util_dump_member(stream, float, state, min_lod);
+ util_dump_member(stream, float, state, max_lod);
+ util_dump_member_array(stream, float, state, border_color);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_surface(struct os_stream *stream, const struct pipe_surface *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_surface");
+
+ util_dump_member(stream, format, state, format);
+ util_dump_member(stream, uint, state, width);
+ util_dump_member(stream, uint, state, height);
+
+ util_dump_member(stream, uint, state, layout);
+ util_dump_member(stream, uint, state, offset);
+ util_dump_member(stream, uint, state, usage);
+
+ util_dump_member(stream, ptr, state, texture);
+ util_dump_member(stream, uint, state, face);
+ util_dump_member(stream, uint, state, level);
+ util_dump_member(stream, uint, state, zslice);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_transfer");
+
+ util_dump_member(stream, uint, state, width);
+ util_dump_member(stream, uint, state, height);
+
+ util_dump_member(stream, uint, state, stride);
+ util_dump_member(stream, uint, state, usage);
+
+ util_dump_member(stream, ptr, state, texture);
+ util_dump_member(stream, uint, state, face);
+ util_dump_member(stream, uint, state, level);
+ util_dump_member(stream, uint, state, zslice);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffer *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_vertex_buffer");
+
+ util_dump_member(stream, uint, state, stride);
+ util_dump_member(stream, uint, state, max_index);
+ util_dump_member(stream, uint, state, buffer_offset);
+ util_dump_member(stream, ptr, state, buffer);
+
+ util_dump_struct_end(stream);
+}
+
+
+void
+util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_element *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_vertex_element");
+
+ util_dump_member(stream, uint, state, src_offset);
+
+ util_dump_member(stream, uint, state, vertex_buffer_index);
+ util_dump_member(stream, uint, state, nr_components);
+
+ util_dump_member(stream, format, state, src_format);
+
+ util_dump_struct_end(stream);
+}
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 4323bc881b..2fbbb83d4b 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -156,6 +156,19 @@ util_format_description(enum pipe_format format);
* Format query functions.
*/
+static INLINE const char *
+util_format_name(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return "???";
+ }
+
+ return desc->name;
+}
+
static INLINE boolean
util_format_is_compressed(enum pipe_format format)
{