aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-04 12:18:13 +0100
committermarha <marha@users.sourceforge.net>2014-03-04 12:23:48 +0100
commit45392e4a0642880b569ea5d4a350cdc395a2c7db (patch)
treec3c2a49de903a18c3f8e1bf79684c29337ebcf7c /mesalib/src/gallium
parent5ec0616d4e3c4c6095f4975abbe9c21e5b6af967 (diff)
parent321c01267ae1c446f1bd22b642567fcafa016c02 (diff)
downloadvcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.gz
vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.bz2
vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.zip
Merge remote-tracking branch 'origin/released'
* origin/released: libX11 libxcb mesa xserver xcb-proto xkeyboard-config git update 4 Mar 2014 Conflicts: mesalib/src/mapi/glapi/glapi.h mesalib/src/mapi/glapi/glthread.c mesalib/src/mesa/drivers/dri/common/dri_util.c mesalib/src/mesa/main/bufferobj.c xorg-server/dix/dispatch.c xorg-server/hw/xwin/glx/gen_gl_wrappers.py xorg-server/hw/xwin/winmultiwindowwm.c
Diffstat (limited to 'mesalib/src/gallium')
-rw-r--r--mesalib/src/gallium/Automake.inc12
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_flush.c391
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_flush.h138
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c21
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h26
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_range.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.c75
9 files changed, 640 insertions, 31 deletions
diff --git a/mesalib/src/gallium/Automake.inc b/mesalib/src/gallium/Automake.inc
index 1e4a34f5d..1acc99ef5 100644
--- a/mesalib/src/gallium/Automake.inc
+++ b/mesalib/src/gallium/Automake.inc
@@ -51,12 +51,14 @@ GALLIUM_VIDEO_CFLAGS = \
$(VISIBILITY_CFLAGS)
-# TODO: add -export-symbols-regex
+DRI_VERSION_SCRIPT ?= $(top_srcdir)/src/gallium/state_trackers/dri/dri.link
+
GALLIUM_DRI_LINKER_FLAGS = \
-module \
-avoid-version \
+ -Wl,--version-script=$(DRI_VERSION_SCRIPT) \
-shared \
- -Wl,-Bsymbolic
+ -no-undefined
GALLIUM_VDPAU_LINKER_FLAGS = \
-module \
@@ -76,7 +78,11 @@ GALLIUM_VDPAU_LIB_DEPS = \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
$(top_builddir)/src/gallium/state_trackers/vdpau/libvdpautracker.la \
$(VDPAU_LIBS) \
- $(LIBDRM_LIBS)
+ $(LIBDRM_LIBS) \
+ -lm \
+ $(CLOCK_LIB) \
+ $(PTHREAD_LIBS) \
+ $(DLOPEN_LIBS)
GALLIUM_XVMC_LIB_DEPS = \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index c89cbddd0..8919783c2 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -91,6 +91,7 @@ C_SOURCES := \
translate/translate_sse.c \
util/u_debug.c \
util/u_debug_describe.c \
+ util/u_debug_flush.c \
util/u_debug_memory.c \
util/u_debug_refcnt.c \
util/u_debug_stack.c \
@@ -155,7 +156,8 @@ C_SOURCES := \
vl/vl_idct.c \
vl/vl_mc.c \
vl/vl_vertex_buffers.c \
- vl/vl_video_buffer.c
+ vl/vl_video_buffer.c \
+ vl/vl_deint_filter.c
GENERATED_SOURCES := \
indices/u_indices_gen.c \
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_flush.c b/mesalib/src/gallium/auxiliary/util/u_debug_flush.c
new file mode 100644
index 000000000..9cf70db58
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_flush.c
@@ -0,0 +1,391 @@
+/**************************************************************************
+ *
+ * Copyright 2012 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
+ * u_debug_flush.c Debug flush and map-related issues:
+ * - Flush while synchronously mapped.
+ * - Command stream reference while synchronously mapped.
+ * - Synchronous map while referenced on command stream.
+ * - Recursive maps.
+ * - Unmap while not mapped.
+ *
+ * @author Thomas Hellstrom <thellstrom@vmware.com>
+ */
+
+#ifdef DEBUG
+#include "pipe/p_compiler.h"
+#include "util/u_debug_stack.h"
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "util/u_debug_flush.h"
+#include "util/u_hash_table.h"
+#include "util/u_double_list.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include <stdio.h>
+
+struct debug_flush_buf {
+ /* Atomic */
+ struct pipe_reference reference; /* Must be the first member. */
+ pipe_mutex mutex;
+ /* Immutable */
+ boolean supports_unsync;
+ unsigned bt_depth;
+ /* Protected by mutex */
+ boolean mapped;
+ boolean mapped_sync;
+ struct debug_stack_frame *map_frame;
+};
+
+struct debug_flush_item {
+ struct debug_flush_buf *fbuf;
+ unsigned bt_depth;
+ struct debug_stack_frame *ref_frame;
+};
+
+struct debug_flush_ctx {
+ /* Contexts are used by a single thread at a time */
+ unsigned bt_depth;
+ boolean catch_map_of_referenced;
+ struct util_hash_table *ref_hash;
+ struct list_head head;
+};
+
+pipe_static_mutex(list_mutex);
+static struct list_head ctx_list = {&ctx_list, &ctx_list};
+
+static struct debug_stack_frame *
+debug_flush_capture_frame(int start, int depth)
+{
+ struct debug_stack_frame *frames;
+
+ frames = CALLOC(depth, sizeof(*frames));
+ if (!frames)
+ return NULL;
+
+ debug_backtrace_capture(frames, start, depth);
+ return frames;
+}
+
+static int
+debug_flush_pointer_compare(void *key1, void *key2)
+{
+ return (key1 == key2) ? 0 : 1;
+}
+
+static unsigned
+debug_flush_pointer_hash(void *key)
+{
+ return (unsigned) (unsigned long) key;
+}
+
+struct debug_flush_buf *
+debug_flush_buf_create(boolean supports_unsync, unsigned bt_depth)
+{
+ struct debug_flush_buf *fbuf = CALLOC_STRUCT(debug_flush_buf);
+
+ if (!fbuf)
+ goto out_no_buf;
+
+ fbuf->supports_unsync = supports_unsync;
+ fbuf->bt_depth = bt_depth;
+ pipe_reference_init(&fbuf->reference, 1);
+ pipe_mutex_init(fbuf->mutex);
+
+ return fbuf;
+out_no_buf:
+ debug_printf("Debug flush buffer creation failed.\n");
+ debug_printf("Debug flush checking for this buffer will be incomplete.\n");
+ return NULL;
+}
+
+void
+debug_flush_buf_reference(struct debug_flush_buf **dst,
+ struct debug_flush_buf *src)
+{
+ struct debug_flush_buf *fbuf = *dst;
+
+ if (pipe_reference(&(*dst)->reference, &src->reference)) {
+ if (fbuf->map_frame)
+ FREE(fbuf->map_frame);
+
+ FREE(fbuf);
+ }
+
+ *dst = src;
+}
+
+static void
+debug_flush_item_destroy(struct debug_flush_item *item)
+{
+ debug_flush_buf_reference(&item->fbuf, NULL);
+
+ if (item->ref_frame)
+ FREE(item->ref_frame);
+
+ FREE(item);
+}
+
+struct debug_flush_ctx *
+debug_flush_ctx_create(boolean catch_reference_of_mapped, unsigned bt_depth)
+{
+ struct debug_flush_ctx *fctx = CALLOC_STRUCT(debug_flush_ctx);
+
+ if (!fctx)
+ goto out_no_ctx;
+
+ fctx->ref_hash = util_hash_table_create(debug_flush_pointer_hash,
+ debug_flush_pointer_compare);
+
+ if (!fctx->ref_hash)
+ goto out_no_ref_hash;
+
+ fctx->bt_depth = bt_depth;
+ pipe_mutex_lock(list_mutex);
+ list_addtail(&fctx->head, &ctx_list);
+ pipe_mutex_unlock(list_mutex);
+
+ return fctx;
+
+ out_no_ref_hash:
+ FREE(fctx);
+out_no_ctx:
+ debug_printf("Debug flush context creation failed.\n");
+ debug_printf("Debug flush checking for this context will be incomplete.\n");
+ return NULL;
+}
+
+static void
+debug_flush_alert(const char *s, const char *op,
+ unsigned start, unsigned depth,
+ boolean continued,
+ boolean capture,
+ const struct debug_stack_frame *frame)
+{
+ if (capture)
+ frame = debug_flush_capture_frame(start, depth);
+
+ if (s)
+ debug_printf("%s ", s);
+ if (frame) {
+ debug_printf("%s backtrace follows:\n", op);
+ debug_backtrace_dump(frame, depth);
+ } else
+ debug_printf("No %s backtrace was captured.\n", op);
+
+ if (continued)
+ debug_printf("**********************************\n");
+ else
+ debug_printf("*********END OF MESSAGE***********\n\n\n");
+
+ if (capture)
+ FREE((void *)frame);
+}
+
+
+void
+debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
+{
+ boolean mapped_sync = FALSE;
+
+ if (!fbuf)
+ return;
+
+ pipe_mutex_lock(fbuf->mutex);
+ if (fbuf->mapped) {
+ debug_flush_alert("Recursive map detected.", "Map",
+ 2, fbuf->bt_depth, TRUE, TRUE, NULL);
+ debug_flush_alert(NULL, "Previous map", 0, fbuf->bt_depth, FALSE,
+ FALSE, fbuf->map_frame);
+ } else if (!(flags & PIPE_TRANSFER_UNSYNCHRONIZED) ||
+ !fbuf->supports_unsync) {
+ fbuf->mapped_sync = mapped_sync = TRUE;
+ }
+ fbuf->map_frame = debug_flush_capture_frame(1, fbuf->bt_depth);
+ fbuf->mapped = TRUE;
+ pipe_mutex_unlock(fbuf->mutex);
+
+ if (mapped_sync) {
+ struct debug_flush_ctx *fctx;
+
+ pipe_mutex_lock(list_mutex);
+ LIST_FOR_EACH_ENTRY(fctx, &ctx_list, head) {
+ struct debug_flush_item *item =
+ util_hash_table_get(fctx->ref_hash, fbuf);
+
+ if (item && fctx->catch_map_of_referenced) {
+ debug_flush_alert("Already referenced map detected.",
+ "Map", 2, fbuf->bt_depth, TRUE, TRUE, NULL);
+ debug_flush_alert(NULL, "Reference", 0, item->bt_depth,
+ FALSE, FALSE, item->ref_frame);
+ }
+ }
+ pipe_mutex_unlock(list_mutex);
+ }
+}
+
+void
+debug_flush_unmap(struct debug_flush_buf *fbuf)
+{
+ if (!fbuf)
+ return;
+
+ pipe_mutex_lock(fbuf->mutex);
+ if (!fbuf->mapped)
+ debug_flush_alert("Unmap not previously mapped detected.", "Map",
+ 2, fbuf->bt_depth, FALSE, TRUE, NULL);
+
+ fbuf->mapped_sync = FALSE;
+ fbuf->mapped = FALSE;
+ if (fbuf->map_frame) {
+ FREE(fbuf->map_frame);
+ fbuf->map_frame = NULL;
+ }
+ pipe_mutex_unlock(fbuf->mutex);
+}
+
+void
+debug_flush_cb_reference(struct debug_flush_ctx *fctx,
+ struct debug_flush_buf *fbuf)
+{
+ struct debug_flush_item *item;
+
+ if (!fctx || !fbuf)
+ return;
+
+ item = util_hash_table_get(fctx->ref_hash, fbuf);
+
+ pipe_mutex_lock(fbuf->mutex);
+ if (fbuf->mapped_sync) {
+ debug_flush_alert("Reference of mapped buffer detected.", "Reference",
+ 2, fctx->bt_depth, TRUE, TRUE, NULL);
+ debug_flush_alert(NULL, "Map", 0, fbuf->bt_depth, FALSE,
+ FALSE, fbuf->map_frame);
+ }
+ pipe_mutex_unlock(fbuf->mutex);
+
+ if (!item) {
+ item = CALLOC_STRUCT(debug_flush_item);
+ if (item) {
+ debug_flush_buf_reference(&item->fbuf, fbuf);
+ item->bt_depth = fctx->bt_depth;
+ item->ref_frame = debug_flush_capture_frame(2, item->bt_depth);
+ if (util_hash_table_set(fctx->ref_hash, fbuf, item) != PIPE_OK) {
+ debug_flush_item_destroy(item);
+ goto out_no_item;
+ }
+ return;
+ }
+ goto out_no_item;
+ }
+ return;
+
+out_no_item:
+ debug_printf("Debug flush command buffer reference creation failed.\n");
+ debug_printf("Debug flush checking will be incomplete "
+ "for this command batch.\n");
+}
+
+static enum pipe_error
+debug_flush_might_flush_cb(void *key, void *value, void *data)
+{
+ struct debug_flush_item *item =
+ (struct debug_flush_item *) value;
+ struct debug_flush_buf *fbuf = item->fbuf;
+ const char *reason = (const char *) data;
+ char message[80];
+
+ snprintf(message, sizeof(message),
+ "%s referenced mapped buffer detected.", reason);
+
+ pipe_mutex_lock(fbuf->mutex);
+ if (fbuf->mapped_sync) {
+ debug_flush_alert(message, reason, 3, item->bt_depth, TRUE, TRUE, NULL);
+ debug_flush_alert(NULL, "Map", 0, fbuf->bt_depth, TRUE, FALSE,
+ fbuf->map_frame);
+ debug_flush_alert(NULL, "First reference", 0, item->bt_depth, FALSE,
+ FALSE, item->ref_frame);
+ }
+ pipe_mutex_unlock(fbuf->mutex);
+
+ return PIPE_OK;
+}
+
+void
+debug_flush_might_flush(struct debug_flush_ctx *fctx)
+{
+ if (!fctx)
+ return;
+
+ util_hash_table_foreach(fctx->ref_hash,
+ debug_flush_might_flush_cb,
+ "Might flush");
+}
+
+static enum pipe_error
+debug_flush_flush_cb(void *key, void *value, void *data)
+{
+ struct debug_flush_item *item =
+ (struct debug_flush_item *) value;
+
+ debug_flush_item_destroy(item);
+
+ return PIPE_OK;
+}
+
+
+void
+debug_flush_flush(struct debug_flush_ctx *fctx)
+{
+ if (!fctx)
+ return;
+
+ util_hash_table_foreach(fctx->ref_hash,
+ debug_flush_might_flush_cb,
+ "Flush");
+ util_hash_table_foreach(fctx->ref_hash,
+ debug_flush_flush_cb,
+ NULL);
+ util_hash_table_clear(fctx->ref_hash);
+}
+
+void
+debug_flush_ctx_destroy(struct debug_flush_ctx *fctx)
+{
+ if (!fctx)
+ return;
+
+ list_del(&fctx->head);
+ util_hash_table_foreach(fctx->ref_hash,
+ debug_flush_flush_cb,
+ NULL);
+ util_hash_table_clear(fctx->ref_hash);
+ util_hash_table_destroy(fctx->ref_hash);
+ FREE(fctx);
+}
+#endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_flush.h b/mesalib/src/gallium/auxiliary/util/u_debug_flush.h
new file mode 100644
index 000000000..a604167f0
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_flush.h
@@ -0,0 +1,138 @@
+/**************************************************************************
+ *
+ * Copyright 2012 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
+ * u_debug_flush.h - Header for debugging flush- and map- related issues.
+ * - Flush while synchronously mapped.
+ * - Command stream reference while synchronously mapped.
+ * - Synchronous map while referenced on command stream.
+ * - Recursive maps.
+ * - Unmap while not mapped.
+ *
+ * @author Thomas Hellstrom <thellstrom@vmware.com>
+ */
+#ifdef DEBUG
+
+#ifndef U_DEBUG_FLUSH_H_
+#define U_DEBUG_FLUSH_H_
+
+struct debug_flush_buf;
+struct debug_flush_ctx;
+
+/**
+ * Create a buffer (AKA allocation) representation.
+ *
+ * @param support_unsync Whether unsynchronous maps are truly supported.
+ * @param bt_depth Depth of backtrace to be captured for this buffer
+ * representation.
+ */
+struct debug_flush_buf *
+debug_flush_buf_create(boolean supports_unsync, unsigned bt_depth);
+
+/**
+ * Reference a buffer representation.
+ *
+ * @param dst Pointer copy destination
+ * @param src Pointer copy source (may be NULL).
+ *
+ * Replace a pointer to a buffer representation with proper refcounting.
+ */
+void
+debug_flush_buf_reference(struct debug_flush_buf **dst,
+ struct debug_flush_buf *src);
+
+/**
+ * Create a context representation.
+ *
+ * @param catch_map_of_referenced Whether to catch synchronous maps of buffers
+ * already present on the command stream.
+ * @param bt_depth Depth of backtrace to be captured for this context
+ * representation.
+ */
+struct debug_flush_ctx *
+debug_flush_ctx_create(boolean catch_map_of_referenced, unsigned bt_depth);
+
+/**
+ * Destroy a context representation.
+ *
+ * @param fctx The context representation to destroy.
+ */
+void
+debug_flush_ctx_destroy(struct debug_flush_ctx *fctx);
+
+/**
+ * Map annotation
+ *
+ * @param fbuf The buffer representation to map.
+ * @param flags Pipebuffer flags for the map.
+ *
+ * Used to annotate a map of the buffer described by the buffer representation.
+ */
+void debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags);
+
+/**
+ * Unmap annotation
+ *
+ * @param fbuf The buffer representation to map.
+ *
+ * Used to annotate an unmap of the buffer described by the
+ * buffer representation.
+ */
+void debug_flush_unmap(struct debug_flush_buf *fbuf);
+
+/**
+ * Might flush annotation
+ *
+ * @param fctx The context representation that might be flushed.
+ *
+ * Used to annotate a conditional (possible) flush of the given context.
+ */
+void debug_flush_might_flush(struct debug_flush_ctx *fctx);
+
+/**
+ * Flush annotation
+ *
+ * @param fctx The context representation that is flushed.
+ *
+ * Used to annotate a real flush of the given context.
+ */
+void debug_flush_flush(struct debug_flush_ctx *fctx);
+
+
+/**
+ * Flush annotation
+ *
+ * @param fctx The context representation that is flushed.
+ *
+ * Used to annotate a real flush of the given context.
+ */
+void debug_flush_cb_reference(struct debug_flush_ctx *fctx,
+ struct debug_flush_buf *fbuf);
+
+#endif
+#endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index 6b602bf32..056f82f72 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -527,7 +527,7 @@ util_format_fits_8unorm(const struct util_format_description *format_desc)
}
-void
+boolean
util_format_translate(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_x, unsigned dst_y,
@@ -555,7 +555,7 @@ util_format_translate(enum pipe_format dst_format,
util_copy_rect(dst, dst_format, dst_stride, dst_x, dst_y,
width, height, src, (int)src_stride,
src_x, src_y);
- return;
+ return TRUE;
}
assert(dst_x % dst_format_desc->block.width == 0);
@@ -621,7 +621,7 @@ util_format_translate(enum pipe_format dst_format,
FREE(tmp_z);
- return;
+ return TRUE;
}
if (util_format_fits_8unorm(src_format_desc) ||
@@ -629,10 +629,15 @@ util_format_translate(enum pipe_format dst_format,
unsigned tmp_stride;
uint8_t *tmp_row;
+ if (!src_format_desc->unpack_rgba_8unorm ||
+ !dst_format_desc->pack_rgba_8unorm) {
+ return FALSE;
+ }
+
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = MALLOC(y_step * tmp_stride);
if (!tmp_row)
- return;
+ return FALSE;
while (height >= y_step) {
src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@@ -654,10 +659,15 @@ util_format_translate(enum pipe_format dst_format,
unsigned tmp_stride;
float *tmp_row;
+ if (!src_format_desc->unpack_rgba_float ||
+ !dst_format_desc->pack_rgba_float) {
+ return FALSE;
+ }
+
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = MALLOC(y_step * tmp_stride);
if (!tmp_row)
- return;
+ return FALSE;
while (height >= y_step) {
src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@@ -675,6 +685,7 @@ util_format_translate(enum pipe_format dst_format,
FREE(tmp_row);
}
+ return TRUE;
}
void util_format_compose_swizzles(const unsigned char swz1[4],
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 5f86e2d2c..e36a9e237 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -1190,7 +1190,7 @@ util_format_write_4i(enum pipe_format format,
boolean
util_format_fits_8unorm(const struct util_format_description *format_desc);
-void
+boolean
util_format_translate(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_x, unsigned dst_y,
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index b5e06630a..ec03e4e58 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -112,10 +112,13 @@ static INLINE float logf( float f )
#define logf(x) ((float)log((double)(x)))
#endif /* logf */
+#if _MSC_VER < 1800
#define isfinite(x) _finite((double)(x))
#define isnan(x) _isnan((double)(x))
+#endif /* _MSC_VER < 1800 */
#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */
+#if _MSC_VER < 1800
static INLINE double log2( double x )
{
const double invln2 = 1.442695041;
@@ -133,6 +136,7 @@ roundf(float x)
{
return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
}
+#endif
#define INFINITY (DBL_MAX + DBL_MAX)
#define NAN (INFINITY - INFINITY)
@@ -717,13 +721,18 @@ util_bitcount(unsigned n)
*/
#ifdef PIPE_ARCH_BIG_ENDIAN
+#define util_le64_to_cpu(x) util_bswap64(x)
#define util_le32_to_cpu(x) util_bswap32(x)
#define util_le16_to_cpu(x) util_bswap16(x)
#else
+#define util_le64_to_cpu(x) (x)
#define util_le32_to_cpu(x) (x)
#define util_le16_to_cpu(x) (x)
#endif
+#define util_cpu_to_le64(x) util_le64_to_cpu(x)
+#define util_cpu_to_le32(x) util_le32_to_cpu(x)
+#define util_cpu_to_le16(x) util_le16_to_cpu(x)
/**
* Reverse byte order of a 32 bit word.
@@ -731,7 +740,8 @@ util_bitcount(unsigned n)
static INLINE uint32_t
util_bswap32(uint32_t n)
{
-#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
+/* We need the gcc version checks for non-autoconf build system */
+#if defined(HAVE___BUILTIN_BSWAP32) || (defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403))
return __builtin_bswap32(n);
#else
return (n >> 24) |
@@ -741,6 +751,20 @@ util_bswap32(uint32_t n)
#endif
}
+/**
+ * Reverse byte order of a 64bit word.
+ */
+static INLINE uint64_t
+util_bswap64(uint64_t n)
+{
+#if defined(HAVE___BUILTIN_BSWAP64)
+ return __builtin_bswap64(n);
+#else
+ return ((uint64_t)util_bswap32(n) << 32) |
+ util_bswap32((n >> 32));
+#endif
+}
+
/**
* Reverse byte order of a 16 bit word.
diff --git a/mesalib/src/gallium/auxiliary/util/u_range.h b/mesalib/src/gallium/auxiliary/util/u_range.h
index 4b1d0d1be..efe25ef5e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_range.h
+++ b/mesalib/src/gallium/auxiliary/util/u_range.h
@@ -36,6 +36,8 @@
#include "os/os_thread.h"
+#include "util/u_math.h"
+
struct util_range {
unsigned start; /* inclusive */
unsigned end; /* exclusive */
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
index 7349d0068..744ea2e5e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -44,11 +44,12 @@ struct u_upload_mgr {
unsigned default_size; /* Minimum size of the upload buffer, in bytes. */
unsigned alignment; /* Alignment of each sub-allocation. */
unsigned bind; /* Bitmask of PIPE_BIND_* flags. */
+ unsigned map_flags; /* Bitmask of PIPE_TRANSFER_* flags. */
+ boolean map_persistent; /* If persistent mappings are supported. */
struct pipe_resource *buffer; /* Upload buffer. */
struct pipe_transfer *transfer; /* Transfer object for the upload buffer. */
uint8_t *map; /* Pointer to the mapped upload buffer. */
- unsigned size; /* Actual size of the upload buffer. */
unsigned offset; /* Aligned offset to the upload buffer, pointing
* at the first unused byte. */
};
@@ -67,20 +68,39 @@ struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
upload->default_size = default_size;
upload->alignment = alignment;
upload->bind = bind;
- upload->buffer = NULL;
+
+ upload->map_persistent =
+ pipe->screen->get_param(pipe->screen,
+ PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT);
+
+ if (upload->map_persistent) {
+ upload->map_flags = PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_PERSISTENT |
+ PIPE_TRANSFER_COHERENT;
+ }
+ else {
+ upload->map_flags = PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_UNSYNCHRONIZED |
+ PIPE_TRANSFER_FLUSH_EXPLICIT;
+ }
return upload;
}
-void u_upload_unmap( struct u_upload_mgr *upload )
+
+static void upload_unmap_internal(struct u_upload_mgr *upload, boolean destroying)
{
+ if (!destroying && upload->map_persistent)
+ return;
+
if (upload->transfer) {
struct pipe_box *box = &upload->transfer->box;
- if ((int) upload->offset > box->x) {
+ if (!upload->map_persistent && (int) upload->offset > box->x) {
pipe_buffer_flush_mapped_range(upload->pipe, upload->transfer,
box->x, upload->offset - box->x);
}
+
pipe_transfer_unmap(upload->pipe, upload->transfer);
upload->transfer = NULL;
upload->map = NULL;
@@ -88,12 +108,17 @@ void u_upload_unmap( struct u_upload_mgr *upload )
}
+void u_upload_unmap( struct u_upload_mgr *upload )
+{
+ upload_unmap_internal(upload, FALSE);
+}
+
+
static void u_upload_release_buffer(struct u_upload_mgr *upload)
{
/* Unmap and unreference the upload buffer. */
- u_upload_unmap(upload);
+ upload_unmap_internal(upload, TRUE);
pipe_resource_reference( &upload->buffer, NULL );
- upload->size = 0;
}
@@ -108,6 +133,8 @@ static enum pipe_error
u_upload_alloc_buffer( struct u_upload_mgr *upload,
unsigned min_size )
{
+ struct pipe_screen *screen = upload->pipe->screen;
+ struct pipe_resource buffer;
unsigned size;
/* Release the old buffer, if present:
@@ -118,28 +145,36 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
*/
size = align(MAX2(upload->default_size, min_size), 4096);
- upload->buffer = pipe_buffer_create( upload->pipe->screen,
- upload->bind,
- PIPE_USAGE_STREAM,
- size );
+ memset(&buffer, 0, sizeof buffer);
+ buffer.target = PIPE_BUFFER;
+ buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
+ buffer.bind = upload->bind;
+ buffer.usage = PIPE_USAGE_STREAM;
+ buffer.width0 = size;
+ buffer.height0 = 1;
+ buffer.depth0 = 1;
+ buffer.array_size = 1;
+
+ if (upload->map_persistent) {
+ buffer.flags = PIPE_RESOURCE_FLAG_MAP_PERSISTENT |
+ PIPE_RESOURCE_FLAG_MAP_COHERENT;
+ }
+
+ upload->buffer = screen->resource_create(screen, &buffer);
if (upload->buffer == NULL) {
return PIPE_ERROR_OUT_OF_MEMORY;
}
/* Map the new buffer. */
upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
- 0, size,
- PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_FLUSH_EXPLICIT,
+ 0, size, upload->map_flags,
&upload->transfer);
if (upload->map == NULL) {
upload->transfer = NULL;
- upload->size = 0;
pipe_resource_reference(&upload->buffer, NULL);
return PIPE_ERROR_OUT_OF_MEMORY;
}
- upload->size = size;
upload->offset = 0;
return PIPE_OK;
}
@@ -164,7 +199,8 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
/* Make sure we have enough space in the upload buffer
* for the sub-allocation. */
- if (MAX2(upload->offset, alloc_offset) + alloc_size > upload->size) {
+ if (!upload->buffer ||
+ MAX2(upload->offset, alloc_offset) + alloc_size > upload->buffer->width0) {
enum pipe_error ret = u_upload_alloc_buffer(upload,
alloc_offset + alloc_size);
if (ret != PIPE_OK)
@@ -175,10 +211,9 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
if (!upload->map) {
upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
- offset, upload->size - offset,
- PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_FLUSH_EXPLICIT |
- PIPE_TRANSFER_UNSYNCHRONIZED,
+ offset,
+ upload->buffer->width0 - offset,
+ upload->map_flags,
&upload->transfer);
if (!upload->map) {
upload->transfer = NULL;