summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/Makefile7
-rw-r--r--src/gallium/auxiliary/SConscript7
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c27
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c1
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c4
-rw-r--r--src/gallium/auxiliary/os/os_stream.h87
-rw-r--r--src/gallium/auxiliary/os/os_stream_log.c (renamed from src/gallium/auxiliary/util/u_debug_dump.h)78
-rw-r--r--src/gallium/auxiliary/os/os_stream_null.c72
-rw-r--r--src/gallium/auxiliary/os/os_stream_stdc.c78
-rw-r--r--src/gallium/auxiliary/os/os_stream_str.c166
-rw-r--r--src/gallium/auxiliary/os/os_stream_wd.c222
-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_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
20 files changed, 1420 insertions, 532 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 507ca6e6aa..ff7695150e 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -49,8 +49,10 @@ C_SOURCES = \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
os/os_misc.c \
+ os/os_stream_log.c \
os/os_stream_stdc.c \
- os/os_stream_wd.c \
+ os/os_stream_str.c \
+ os/os_stream_null.c \
os/os_time.c \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
@@ -91,9 +93,10 @@ C_SOURCES = \
translate/translate.c \
translate/translate_cache.c \
util/u_debug.c \
- util/u_debug_dump.c \
util/u_debug_symbol.c \
util/u_debug_stack.c \
+ util/u_dump_defines.c \
+ util/u_dump_state.c \
util/u_bitmask.c \
util/u_blit.c \
util/u_blitter.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 9709344b54..b531ad2dbd 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -83,8 +83,10 @@ source = [
'indices/u_indices_gen.c',
'indices/u_unfilled_gen.c',
'os/os_misc.c',
+ 'os/os_stream_log.c',
'os/os_stream_stdc.c',
- 'os/os_stream_wd.c',
+ 'os/os_stream_str.c',
+ 'os/os_stream_null.c',
'os/os_time.c',
'pipebuffer/pb_buffer_fenced.c',
'pipebuffer/pb_buffer_malloc.c',
@@ -131,10 +133,11 @@ source = [
'util/u_cache.c',
'util/u_cpu_detect.c',
'util/u_debug.c',
- 'util/u_debug_dump.c',
'util/u_debug_memory.c',
'util/u_debug_stack.c',
'util/u_debug_symbol.c',
+ 'util/u_dump_defines.c',
+ 'util/u_dump_state.c',
'util/u_dl.c',
'util/u_draw_quad.c',
'util/u_format.c',
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index c638239e80..b5241fa64c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -93,6 +93,7 @@ struct cso_context {
struct pipe_framebuffer_state fb, fb_saved;
struct pipe_viewport_state vp, vp_saved;
struct pipe_blend_color blend_color;
+ struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
};
@@ -1057,8 +1058,6 @@ void cso_restore_viewport(struct cso_context *ctx)
}
-
-
enum pipe_error cso_set_blend_color(struct cso_context *ctx,
const struct pipe_blend_color *bc)
{
@@ -1069,6 +1068,30 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx,
return PIPE_OK;
}
+enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
+ const struct pipe_stencil_ref *sr)
+{
+ if (memcmp(&ctx->stencil_ref, sr, sizeof(ctx->stencil_ref))) {
+ ctx->stencil_ref = *sr;
+ ctx->pipe->set_stencil_ref(ctx->pipe, sr);
+ }
+ return PIPE_OK;
+}
+
+void cso_save_stencil_ref(struct cso_context *ctx)
+{
+ ctx->stencil_ref_saved = ctx->stencil_ref;
+}
+
+
+void cso_restore_stencil_ref(struct cso_context *ctx)
+{
+ if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) {
+ ctx->stencil_ref = ctx->stencil_ref_saved;
+ ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref);
+ }
+}
+
enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
void *handle)
{
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index d2089b1c88..707b3c2cee 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -174,6 +174,12 @@ enum pipe_error cso_set_blend_color(struct cso_context *cso,
const struct pipe_blend_color *bc);
+enum pipe_error cso_set_stencil_ref(struct cso_context *cso,
+ const struct pipe_stencil_ref *sr);
+void cso_save_stencil_ref(struct cso_context *cso);
+void cso_restore_stencil_ref(struct cso_context *cso);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index f5ed32d0b0..341353f628 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -310,7 +310,7 @@ draw_arrays_instanced(struct draw_context *draw,
debug_printf("Elements:\n");
for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
debug_printf(" format=%s comps=%u\n",
- pf_name(draw->pt.vertex_element[i].src_format),
+ util_format_name(draw->pt.vertex_element[i].src_format),
draw->pt.vertex_element[i].nr_components);
}
debug_printf("Buffers:\n");
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 6bdd612e6f..9085838022 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -61,6 +61,7 @@ draw_vs_set_constants(struct draw_context *draw,
}
draw->vs.aligned_constant_storage[slot] = align_malloc(size, 16);
}
+ assert(constants);
memcpy((void *)draw->vs.aligned_constant_storage[slot],
constants,
size);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 57c2b763e4..e268862282 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -35,7 +35,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "util/u_debug.h"
-#include "util/u_debug_dump.h"
+#include "util/u_dump.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_format.h"
@@ -173,7 +173,7 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
/* FIXME */
_debug_printf("llvmpipe: failed to translate texture wrap mode %s\n",
- debug_dump_tex_wrap(wrap_mode, TRUE));
+ util_dump_tex_wrap(wrap_mode, TRUE));
coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
coord = lp_build_min(int_coord_bld, coord, length_minus_one);
break;
diff --git a/src/gallium/auxiliary/os/os_stream.h b/src/gallium/auxiliary/os/os_stream.h
index bf30e6542d..693a0621e2 100644
--- a/src/gallium/auxiliary/os/os_stream.h
+++ b/src/gallium/auxiliary/os/os_stream.h
@@ -37,25 +37,86 @@
#include "pipe/p_compiler.h"
-struct os_stream;
-
-
/**
- * Create a stream
- * @param filename relative or absolute path (necessary for windows)
- * @param optional maximum file size (0 for a growable size).
+ * OS stream (FILE, socket, etc) abstraction.
*/
+struct os_stream
+{
+ void
+ (*close)(struct os_stream *stream);
+
+ boolean
+ (*write)(struct os_stream *stream, const void *data, size_t size);
+
+ void
+ (*flush)(struct os_stream *stream);
+};
+
+
+static INLINE void
+os_stream_close(struct os_stream *stream)
+{
+ if (!stream)
+ return;
+
+ stream->close(stream);
+}
+
+
+static INLINE boolean
+os_stream_write(struct os_stream *stream, const void *data, size_t size)
+{
+ if (!stream)
+ return FALSE;
+ return stream->write(stream, data, size);
+}
+
+
+static INLINE boolean
+os_stream_write_str(struct os_stream *stream, const char *str)
+{
+ size_t size;
+ if (!stream)
+ return FALSE;
+ for(size = 0; str[size]; ++size)
+ ;
+ return stream->write(stream, str, size);
+}
+
+
+static INLINE void
+os_stream_flush(struct os_stream *stream)
+{
+ stream->flush(stream);
+}
+
+
+struct os_stream *
+os_file_stream_create(const char *filename);
+
+
+struct os_stream *
+os_null_stream_create(void);
+
+
+extern struct os_stream *
+os_log_stream;
+
+
struct os_stream *
-os_stream_create(const char *filename, size_t max_size);
+os_str_stream_create(size_t initial_size);
+
+
+const char *
+os_str_stream_get(struct os_stream *stream);
-boolean
-os_stream_write(struct os_stream *stream, const void *data, size_t size);
+char *
+os_str_stream_get_and_close(struct os_stream *stream);
-void
-os_stream_flush(struct os_stream *stream);
-void
-os_stream_close(struct os_stream *stream);
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+#define os_file_stream_create(_filename) os_null_stream_create()
+#endif
#endif /* _OS_STREAM_H_ */
diff --git a/src/gallium/auxiliary/util/u_debug_dump.h b/src/gallium/auxiliary/os/os_stream_log.c
index 19b130ad18..7cc2028a22 100644
--- a/src/gallium/auxiliary/util/u_debug_dump.h
+++ b/src/gallium/auxiliary/os/os_stream_log.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
+ *
+ * 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
@@ -10,11 +10,11 @@
* 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.
@@ -22,56 +22,60 @@
* 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>
+ * Debug logging stream implementation.
*/
-#ifndef U_DEBUG_DUMP_H_
-#define U_DEBUG_DUMP_H_
+#include "os_memory.h"
+#include "os_misc.h"
+#include "os_stream.h"
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+static void
+os_log_stream_close(struct os_stream *stream)
+{
+ (void)stream;
+}
-const char *
-debug_dump_blend_factor(unsigned value, boolean shortened);
+static boolean
+os_log_stream_write(struct os_stream *stream, const void *data, size_t size)
+{
+ char *str;
-const char *
-debug_dump_blend_func(unsigned value, boolean shortened);
+ str = os_malloc(size + 1);
+ if (!str)
+ return FALSE;
-const char *
-debug_dump_func(unsigned value, boolean shortened);
+ memcpy(str, data, size);
+ str[size] = 0;
-const char *
-debug_dump_tex_target(unsigned value, boolean shortened);
+ os_log_message(str);
-const char *
-debug_dump_tex_wrap(unsigned value, boolean shortened);
+ os_free(str);
-const char *
-debug_dump_tex_mipfilter(unsigned value, boolean shortened);
+ return TRUE;
+}
-const char *
-debug_dump_tex_filter(unsigned value, boolean shortened);
+static void
+os_log_stream_flush(struct os_stream *stream)
+{
+ (void)stream;
+}
-/* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
+static struct os_stream
+os_log_stream_struct = {
+ &os_log_stream_close,
+ &os_log_stream_write,
+ &os_log_stream_flush
+};
-#ifdef __cplusplus
-}
-#endif
-#endif /* U_DEBUG_H_ */
+struct os_stream *
+os_log_stream = &os_log_stream_struct;
diff --git a/src/gallium/auxiliary/os/os_stream_null.c b/src/gallium/auxiliary/os/os_stream_null.c
new file mode 100644
index 0000000000..128c4e8f0e
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_stream_null.c
@@ -0,0 +1,72 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Null stream implementation.
+ */
+
+#include "os_memory.h"
+#include "os_stream.h"
+
+
+static void
+os_null_stream_close(struct os_stream *stream)
+{
+ (void)stream;
+}
+
+
+static boolean
+os_null_stream_write(struct os_stream *stream, const void *data, size_t size)
+{
+ (void)data;
+ (void)size;
+ return TRUE;
+}
+
+
+static void
+os_null_stream_flush(struct os_stream *stream)
+{
+ (void)stream;
+}
+
+
+static struct os_stream
+os_null_stream = {
+ &os_null_stream_close,
+ &os_null_stream_write,
+ &os_null_stream_flush
+};
+
+
+struct os_stream *
+os_null_stream_create()
+{
+ return &os_null_stream;
+}
diff --git a/src/gallium/auxiliary/os/os_stream_stdc.c b/src/gallium/auxiliary/os/os_stream_stdc.c
index caa60c0b50..9e7ed71107 100644
--- a/src/gallium/auxiliary/os/os_stream_stdc.c
+++ b/src/gallium/auxiliary/os/os_stream_stdc.c
@@ -40,65 +40,73 @@
#include "os_stream.h"
-struct os_stream
+struct os_stdc_stream
{
+ struct os_stream base;
+
FILE *file;
};
-struct os_stream *
-os_stream_create(const char *filename, size_t max_size)
+static INLINE struct os_stdc_stream *
+os_stdc_stream(struct os_stream *stream)
{
- struct os_stream *stream;
-
- (void)max_size;
-
- stream = (struct os_stream *)calloc(1, sizeof(struct os_stream));
- if(!stream)
- goto no_stream;
-
- stream->file = fopen(filename, "w");
- if(!stream->file)
- goto no_file;
-
- return stream;
-
-no_file:
+ return (struct os_stdc_stream *)stream;
+}
+
+
+static void
+os_stdc_stream_close(struct os_stream *_stream)
+{
+ struct os_stdc_stream *stream = os_stdc_stream(_stream);
+
+ fclose(stream->file);
+
free(stream);
-no_stream:
- return NULL;
}
-boolean
-os_stream_write(struct os_stream *stream, const void *data, size_t size)
+static boolean
+os_stdc_stream_write(struct os_stream *_stream, const void *data, size_t size)
{
- if(!stream)
- return FALSE;
-
+ struct os_stdc_stream *stream = os_stdc_stream(_stream);
+
return fwrite(data, size, 1, stream->file) == size ? TRUE : FALSE;
}
-void
-os_stream_flush(struct os_stream *stream)
+static void
+os_stdc_stream_flush(struct os_stream *_stream)
{
- if(!stream)
- return;
-
+ struct os_stdc_stream *stream = os_stdc_stream(_stream);
+
fflush(stream->file);
}
-void
-os_stream_close(struct os_stream *stream)
+struct os_stream *
+os_file_stream_create(const char *filename)
{
+ struct os_stdc_stream *stream;
+
+ stream = (struct os_stdc_stream *)calloc(1, sizeof(*stream));
if(!stream)
- return;
-
- fclose(stream->file);
+ goto no_stream;
+
+ stream->base.close = &os_stdc_stream_close;
+ stream->base.write = &os_stdc_stream_write;
+ stream->base.flush = &os_stdc_stream_flush;
+ stream->file = fopen(filename, "w");
+ if(!stream->file)
+ goto no_file;
+
+ return &stream->base;
+
+no_file:
free(stream);
+no_stream:
+ return NULL;
}
diff --git a/src/gallium/auxiliary/os/os_stream_str.c b/src/gallium/auxiliary/os/os_stream_str.c
new file mode 100644
index 0000000000..b5c7270d2a
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_stream_str.c
@@ -0,0 +1,166 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Malloc string stream implementation.
+ */
+
+#include "pipe/p_config.h"
+
+#include "os_memory.h"
+#include "os_stream.h"
+
+
+struct os_str_stream
+{
+ struct os_stream base;
+
+ char *str;
+
+ size_t size;
+ size_t written;
+};
+
+
+static INLINE struct os_str_stream *
+os_str_stream(struct os_stream *stream)
+{
+ return (struct os_str_stream *)stream;
+}
+
+
+static void
+os_str_stream_close(struct os_stream *_stream)
+{
+ struct os_str_stream *stream = os_str_stream(_stream);
+
+ os_free(stream->str);
+
+ os_free(stream);
+}
+
+
+static boolean
+os_str_stream_write(struct os_stream *_stream, const void *data, size_t size)
+{
+ struct os_str_stream *stream = os_str_stream(_stream);
+ size_t minimum_size;
+ boolean ret = TRUE;
+
+ minimum_size = stream->written + size + 1;
+ if (stream->size < minimum_size) {
+ size_t new_size = stream->size;
+ char * new_str;
+
+ do {
+ new_size *= 2;
+ } while (new_size < minimum_size);
+
+ new_str = os_realloc(stream->str, stream->size, new_size);
+ if (new_str) {
+ stream->str = new_str;
+ stream->size = new_size;
+ }
+ else {
+ size = stream->size - stream->written - 1;
+ ret = FALSE;
+ }
+ }
+
+ memcpy(stream->str + stream->written, data, size);
+ stream->written += size;
+
+ return ret;
+}
+
+
+static void
+os_str_stream_flush(struct os_stream *stream)
+{
+ (void)stream;
+}
+
+
+struct os_stream *
+os_str_stream_create(size_t size)
+{
+ struct os_str_stream *stream;
+
+ stream = (struct os_str_stream *)os_calloc(1, sizeof(*stream));
+ if(!stream)
+ goto no_stream;
+
+ stream->base.close = &os_str_stream_close;
+ stream->base.write = &os_str_stream_write;
+ stream->base.flush = &os_str_stream_flush;
+
+ stream->str = os_malloc(size);
+ if(!stream->str)
+ goto no_str;
+
+ stream->size = size;
+
+ return &stream->base;
+
+no_str:
+ os_free(stream);
+no_stream:
+ return NULL;
+}
+
+
+const char *
+os_str_stream_get(struct os_stream *_stream)
+{
+ struct os_str_stream *stream = os_str_stream(_stream);
+
+ if (!stream)
+ return NULL;
+
+ stream->str[stream->written] = 0;
+ return stream->str;
+}
+
+
+char *
+os_str_stream_get_and_close(struct os_stream *_stream)
+{
+ struct os_str_stream *stream = os_str_stream(_stream);
+ char *str;
+
+ if (!stream)
+ return NULL;
+
+ str = stream->str;
+
+ str[stream->written] = 0;
+
+ os_free(stream);
+
+ return str;
+}
diff --git a/src/gallium/auxiliary/os/os_stream_wd.c b/src/gallium/auxiliary/os/os_stream_wd.c
deleted file mode 100644
index a64cbcab4c..0000000000
--- a/src/gallium/auxiliary/os/os_stream_wd.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/**************************************************************************
- *
- * 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Stream implementation for the Windows Display driver.
- */
-
-#include "pipe/p_config.h"
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-#include <windows.h>
-#include <winddi.h>
-
-#include "os_memory.h"
-#include "os_stream.h"
-
-
-#define MAP_FILE_SIZE (4*1024*1024)
-
-
-struct os_stream
-{
- char filename[MAX_PATH + 1];
- WCHAR wFileName[MAX_PATH + 1];
- boolean growable;
- size_t map_size;
- ULONG_PTR iFile;
- char *pMap;
- size_t written;
- unsigned suffix;
-};
-
-
-static INLINE boolean
-os_stream_map(struct os_stream *stream)
-{
- ULONG BytesInUnicodeString;
- static char filename[MAX_PATH + 1];
- unsigned filename_len;
-
- if(stream->growable)
- filename_len = snprintf(filename,
- sizeof(filename),
- "%s.%04x",
- stream->filename,
- stream->suffix++);
- else
- filename_len = snprintf(filename,
- sizeof(filename),
- "%s",
- stream->filename);
-
- EngMultiByteToUnicodeN(
- stream->wFileName,
- sizeof(stream->wFileName),
- &BytesInUnicodeString,
- filename,
- filename_len);
-
- stream->pMap = EngMapFile(stream->wFileName, stream->map_size, &stream->iFile);
- if(!stream->pMap)
- return FALSE;
-
- memset(stream->pMap, 0, stream->map_size);
- stream->written = 0;
-
- return TRUE;
-}
-
-
-static INLINE void
-os_stream_unmap(struct os_stream *stream)
-{
- EngUnmapFile(stream->iFile);
- if(stream->written < stream->map_size) {
- /* Truncate file size */
- stream->pMap = EngMapFile(stream->wFileName, stream->written, &stream->iFile);
- if(stream->pMap)
- EngUnmapFile(stream->iFile);
- }
-
- stream->pMap = NULL;
-}
-
-
-static INLINE void
-os_stream_full_qualified_filename(char *dst, size_t size, const char *src)
-{
- boolean need_drive, need_root;
-
- if((('A' <= src[0] && src[0] <= 'Z') || ('a' <= src[0] && src[0] <= 'z')) && src[1] == ':') {
- need_drive = FALSE;
- need_root = src[2] == '\\' ? FALSE : TRUE;
- }
- else {
- need_drive = TRUE;
- need_root = src[0] == '\\' ? FALSE : TRUE;
- }
-
- snprintf(dst, size,
- "\\??\\%s%s%s",
- need_drive ? "C:" : "",
- need_root ? "\\" : "",
- src);
-}
-
-
-struct os_stream *
-os_stream_create(const char *filename, size_t max_size)
-{
- struct os_stream *stream;
-
- stream = CALLOC_STRUCT(os_stream);
- if(!stream)
- goto error1;
-
- os_stream_full_qualified_filename(stream->filename,
- sizeof(stream->filename),
- filename);
-
- if(max_size) {
- stream->growable = FALSE;
- stream->map_size = max_size;
- }
- else {
- stream->growable = TRUE;
- stream->map_size = MAP_FILE_SIZE;
- }
-
- if(!os_stream_map(stream))
- goto error2;
-
- return stream;
-
-error2:
- FREE(stream);
-error1:
- return NULL;
-}
-
-
-static INLINE void
-os_stream_copy(struct os_stream *stream, const char *data, size_t size)
-{
- assert(stream->written + size <= stream->map_size);
- memcpy(stream->pMap + stream->written, data, size);
- stream->written += size;
-}
-
-
-boolean
-os_stream_write(struct os_stream *stream, const void *data, size_t size)
-{
- if(!stream)
- return FALSE;
-
- if(!stream->pMap)
- return FALSE;
-
- while(stream->written + size > stream->map_size) {
- size_t step = stream->map_size - stream->written;
- os_stream_copy(stream, data, step);
- data = (const char *)data + step;
- size -= step;
-
- os_stream_unmap(stream);
- if(!stream->growable || !os_stream_map(stream))
- return FALSE;
- }
-
- os_stream_copy(stream, data, size);
-
- return TRUE;
-}
-
-
-void
-os_stream_flush(struct os_stream *stream)
-{
- (void)stream;
-}
-
-
-void
-os_stream_close(struct os_stream *stream)
-{
- if(!stream)
- return;
-
- os_stream_unmap(stream);
-
- FREE(stream);
-}
-
-
-#endif
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_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)
{