aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c26
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_cpu_detect.c1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_cpu_detect.h1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_memory.c55
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_inlines.h4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_resource.c119
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_resource.h34
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_transfer.c73
9 files changed, 235 insertions, 79 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 70fec9118..2a4a13e9f 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -1135,18 +1135,17 @@ static boolean is_blit_generic_supported(struct blitter_context *blitter,
if (dst) {
unsigned bind;
- boolean is_stencil;
const struct util_format_description *desc =
util_format_description(dst_format);
-
- is_stencil = util_format_has_stencil(desc);
+ boolean dst_has_stencil = util_format_has_stencil(desc);
/* Stencil export must be supported for stencil copy. */
- if ((mask & PIPE_MASK_S) && is_stencil && !ctx->has_stencil_export) {
+ if ((mask & PIPE_MASK_S) && dst_has_stencil &&
+ !ctx->has_stencil_export) {
return FALSE;
}
- if (is_stencil || util_format_has_depth(desc))
+ if (dst_has_stencil || util_format_has_depth(desc))
bind = PIPE_BIND_DEPTH_STENCIL;
else
bind = PIPE_BIND_RENDER_TARGET;
@@ -1168,15 +1167,18 @@ static boolean is_blit_generic_supported(struct blitter_context *blitter,
}
/* Check stencil sampler support for stencil copy. */
- if (util_format_has_stencil(util_format_description(src_format))) {
- enum pipe_format stencil_format =
+ if (mask & PIPE_MASK_S) {
+ if (util_format_has_stencil(util_format_description(src_format))) {
+ enum pipe_format stencil_format =
util_format_stencil_only(src_format);
- assert(stencil_format != PIPE_FORMAT_NONE);
+ assert(stencil_format != PIPE_FORMAT_NONE);
- if (stencil_format != src_format &&
- !screen->is_format_supported(screen, stencil_format, src->target,
- src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) {
- return FALSE;
+ if (stencil_format != src_format &&
+ !screen->is_format_supported(screen, stencil_format,
+ src->target, src->nr_samples,
+ PIPE_BIND_SAMPLER_VIEW)) {
+ return FALSE;
+ }
}
}
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
index 03280515b..7e6df9df1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -279,6 +279,7 @@ util_cpu_detect(void)
util_cpu_caps.has_sse4_1 = (regs2[2] >> 19) & 1;
util_cpu_caps.has_sse4_2 = (regs2[2] >> 20) & 1;
util_cpu_caps.has_avx = (regs2[2] >> 28) & 1;
+ util_cpu_caps.has_f16c = (regs2[2] >> 29) & 1;
util_cpu_caps.has_mmx2 = util_cpu_caps.has_sse; /* SSE cpus supports mmxext too */
cacheline = ((regs2[1] >> 8) & 0xFF) * 8;
diff --git a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.h b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.h
index acac68658..21c2f048f 100644
--- a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -63,6 +63,7 @@ struct util_cpu_caps {
unsigned has_sse4_1:1;
unsigned has_sse4_2:1;
unsigned has_avx:1;
+ unsigned has_f16c:1;
unsigned has_3dnow:1;
unsigned has_3dnow_ext:1;
unsigned has_altivec:1;
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
index 4bf26a524..472354781 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
@@ -76,6 +76,7 @@ struct debug_memory_header
#endif
unsigned magic;
+ unsigned tag;
};
struct debug_memory_footer
@@ -140,6 +141,7 @@ debug_malloc(const char *file, unsigned line, const char *function,
hdr->function = function;
hdr->size = size;
hdr->magic = DEBUG_MEMORY_MAGIC;
+ hdr->tag = 0;
#if DEBUG_FREED_MEMORY
hdr->freed = FALSE;
#endif
@@ -263,6 +265,7 @@ debug_realloc(const char *file, unsigned line, const char *function,
new_hdr->function = old_hdr->function;
new_hdr->size = new_size;
new_hdr->magic = DEBUG_MEMORY_MAGIC;
+ new_hdr->tag = 0;
#if DEBUG_FREED_MEMORY
new_hdr->freed = FALSE;
#endif
@@ -348,6 +351,58 @@ debug_memory_end(unsigned long start_no)
/**
+ * Put a tag (arbitrary integer) on a memory block.
+ * Can be useful for debugging.
+ */
+void
+debug_memory_tag(void *ptr, unsigned tag)
+{
+ struct debug_memory_header *hdr;
+
+ if (!ptr)
+ return;
+
+ hdr = header_from_data(ptr);
+ if (hdr->magic != DEBUG_MEMORY_MAGIC) {
+ debug_printf("%s corrupted memory at %p\n", __FUNCTION__, ptr);
+ debug_assert(0);
+ }
+
+ hdr->tag = tag;
+}
+
+
+/**
+ * Check the given block of memory for validity/corruption.
+ */
+void
+debug_memory_check_block(void *ptr)
+{
+ struct debug_memory_header *hdr;
+ struct debug_memory_footer *ftr;
+
+ if (!ptr)
+ return;
+
+ hdr = header_from_data(ptr);
+ ftr = footer_from_header(hdr);
+
+ if (hdr->magic != DEBUG_MEMORY_MAGIC) {
+ debug_printf("%s:%u:%s: bad or corrupted memory %p\n",
+ hdr->file, hdr->line, hdr->function, ptr);
+ debug_assert(0);
+ }
+
+ if (ftr->magic != DEBUG_MEMORY_MAGIC) {
+ debug_printf("%s:%u:%s: buffer overflow %p\n",
+ hdr->file, hdr->line, hdr->function, ptr);
+ debug_assert(0);
+ }
+}
+
+
+
+/**
* We can periodically call this from elsewhere to do a basic sanity
* check of the heap memory we've allocated.
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 00301265d..ed942fb16 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -447,6 +447,7 @@ util_format_is_compressed(enum pipe_format format)
switch (desc->layout) {
case UTIL_FORMAT_LAYOUT_S3TC:
case UTIL_FORMAT_LAYOUT_RGTC:
+ case UTIL_FORMAT_LAYOUT_ETC:
/* XXX add other formats in the future */
return TRUE;
default:
diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h
index ba745ebb5..7770cd514 100644
--- a/mesalib/src/gallium/auxiliary/util/u_inlines.h
+++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h
@@ -517,7 +517,7 @@ util_query_clear_result(union pipe_query_result *result, unsigned type)
memset(&result->pipeline_statistics, 0, sizeof(result->pipeline_statistics));
break;
default:
- assert(0);
+ memset(result, 0, sizeof(*result));
}
}
@@ -583,7 +583,7 @@ util_copy_constant_buffer(struct pipe_constant_buffer *dst,
}
static INLINE unsigned
-util_max_layer(struct pipe_resource *r, unsigned level)
+util_max_layer(const struct pipe_resource *r, unsigned level)
{
switch (r->target) {
case PIPE_TEXTURE_CUBE:
diff --git a/mesalib/src/gallium/auxiliary/util/u_resource.c b/mesalib/src/gallium/auxiliary/util/u_resource.c
index a32c4f6df..66caaae84 100644
--- a/mesalib/src/gallium/auxiliary/util/u_resource.c
+++ b/mesalib/src/gallium/auxiliary/util/u_resource.c
@@ -1,76 +1,65 @@
+/*
+ * Copyright 2013 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 THE AUTHORS 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 "util/u_inlines.h"
-#include "util/u_transfer.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_resource.h"
-static INLINE struct u_resource *
-u_resource( struct pipe_resource *res )
-{
- return (struct u_resource *)res;
-}
-boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
- struct pipe_resource *resource,
- struct winsys_handle *handle)
+/**
+ * Return the size of the resource in bytes.
+ */
+unsigned
+util_resource_size(const struct pipe_resource *res)
{
- struct u_resource *ur = u_resource(resource);
- return ur->vtbl->resource_get_handle(screen, resource, handle);
-}
+ unsigned width = res->width0;
+ unsigned height = res->height0;
+ unsigned depth = res->depth0;
+ unsigned size = 0;
+ unsigned level;
-void u_resource_destroy_vtbl(struct pipe_screen *screen,
- struct pipe_resource *resource)
-{
- struct u_resource *ur = u_resource(resource);
- ur->vtbl->resource_destroy(screen, resource);
-}
+ for (level = 0; level <= res->last_level; level++) {
+ unsigned slices;
-void *u_transfer_map_vtbl(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- struct pipe_transfer **transfer)
-{
- struct u_resource *ur = u_resource(resource);
- return ur->vtbl->transfer_map(context, resource, level, usage, box,
- transfer);
-}
+ if (res->target == PIPE_TEXTURE_CUBE)
+ slices = 6;
+ else if (res->target == PIPE_TEXTURE_3D)
+ slices = depth;
+ else
+ slices = res->array_size;
-void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
- struct pipe_transfer *transfer,
- const struct pipe_box *box)
-{
- struct u_resource *ur = u_resource(transfer->resource);
- ur->vtbl->transfer_flush_region(pipe, transfer, box);
-}
+ size += (util_format_get_nblocksy(res->format, height) *
+ util_format_get_stride(res->format, width) * slices);
-void u_transfer_unmap_vtbl( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct u_resource *ur = u_resource(transfer->resource);
- ur->vtbl->transfer_unmap(pipe, transfer);
-}
+ width = u_minify(width, 1);
+ height = u_minify(height, 1);
+ depth = u_minify(depth, 1);
+ }
-void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride)
-{
- struct u_resource *ur = u_resource(resource);
- ur->vtbl->transfer_inline_write(pipe,
- resource,
- level,
- usage,
- box,
- data,
- stride,
- layer_stride);
+ return size;
}
-
-
-
-
diff --git a/mesalib/src/gallium/auxiliary/util/u_resource.h b/mesalib/src/gallium/auxiliary/util/u_resource.h
new file mode 100644
index 000000000..977e0136b
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_resource.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013 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 THE AUTHORS 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.
+ */
+
+#ifndef U_RESOURCE_H
+#define U_RESOURCE_H
+
+struct pipe_resource;
+
+unsigned
+util_resource_size(const struct pipe_resource *res);
+
+#endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_transfer.c b/mesalib/src/gallium/auxiliary/util/u_transfer.c
index 861682553..56e059bfd 100644
--- a/mesalib/src/gallium/auxiliary/util/u_transfer.c
+++ b/mesalib/src/gallium/auxiliary/util/u_transfer.c
@@ -87,3 +87,76 @@ void u_default_transfer_unmap( struct pipe_context *pipe,
struct pipe_transfer *transfer )
{
}
+
+
+static INLINE struct u_resource *
+u_resource( struct pipe_resource *res )
+{
+ return (struct u_resource *)res;
+}
+
+boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->resource_get_handle(screen, resource, handle);
+}
+
+void u_resource_destroy_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->resource_destroy(screen, resource);
+}
+
+void *u_transfer_map_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->transfer_map(context, resource, level, usage, box,
+ transfer);
+}
+
+void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_flush_region(pipe, transfer, box);
+}
+
+void u_transfer_unmap_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_unmap(pipe, transfer);
+}
+
+void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned layer_stride)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->transfer_inline_write(pipe,
+ resource,
+ level,
+ usage,
+ box,
+ data,
+ stride,
+ layer_stride);
+}
+
+
+
+