diff options
author | marha <marha@users.sourceforge.net> | 2012-12-05 09:14:52 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-12-05 09:14:52 +0100 |
commit | e82692e521240c5f8592f9ce56c9d5b3d68870ec (patch) | |
tree | 3293b7fa02b1f5aa58b74f1fe02444085be2281e /mesalib/src/gallium/auxiliary/util | |
parent | b8da71ffb17d3d16706db04115e9ba1dd8bc49b9 (diff) | |
download | vcxsrv-e82692e521240c5f8592f9ce56c9d5b3d68870ec.tar.gz vcxsrv-e82692e521240c5f8592f9ce56c9d5b3d68870ec.tar.bz2 vcxsrv-e82692e521240c5f8592f9ce56c9d5b3d68870ec.zip |
mesa git update 5 dec 2012
mesa: 484a8dcfa8c8b91b8e99174b5e4953264f32789e
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_cache.c | 8 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_debug.c | 56 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_debug.h | 4 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_draw.c | 11 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_surface.c | 15 |
5 files changed, 48 insertions, 46 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_cache.c b/mesalib/src/gallium/auxiliary/util/u_cache.c index df08ec302..26aab2bf1 100644 --- a/mesalib/src/gallium/auxiliary/util/u_cache.c +++ b/mesalib/src/gallium/auxiliary/util/u_cache.c @@ -183,12 +183,12 @@ util_cache_set(struct util_cache *cache, void *value) { struct util_cache_entry *entry; - uint32_t hash = cache->hash(key); + uint32_t hash; assert(cache); if (!cache) return; - + hash = cache->hash(key); entry = util_cache_entry_get(cache, hash, key); if (!entry) entry = cache->lru.prev; @@ -218,12 +218,12 @@ util_cache_get(struct util_cache *cache, const void *key) { struct util_cache_entry *entry; - uint32_t hash = cache->hash(key); + uint32_t hash; assert(cache); if (!cache) return NULL; - + hash = cache->hash(key); entry = util_cache_entry_get(cache, hash, key); if (!entry) return NULL; diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.c b/mesalib/src/gallium/auxiliary/util/u_debug.c index b26192a8b..ee97b7adb 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug.c @@ -436,7 +436,7 @@ void debug_funclog_enter_exit(const char* f, const int line, const char* file) #ifdef DEBUG /** - * Dump an image to a .raw or .ppm file (depends on OS). + * Dump an image to .ppm file. * \param format PIPE_FORMAT_x * \param cpp bytes per pixel * \param width width in pixels @@ -444,56 +444,48 @@ void debug_funclog_enter_exit(const char* f, const int line, const char* file) * \param stride row stride in bytes */ void debug_dump_image(const char *prefix, - unsigned format, unsigned cpp, + enum pipe_format format, unsigned cpp, unsigned width, unsigned height, unsigned stride, const void *data) { /* write a ppm file */ char filename[256]; + unsigned char *rgb8; FILE *f; util_snprintf(filename, sizeof(filename), "%s.ppm", prefix); - f = fopen(filename, "w"); - if (f) { - int i, x, y; - int r, g, b; - const uint8_t *ptr = (uint8_t *) data; - - /* XXX this is a hack */ - switch (format) { - case PIPE_FORMAT_B8G8R8A8_UNORM: - r = 2; - g = 1; - b = 0; - break; - default: - r = 0; - g = 1; - b = 1; - } + rgb8 = MALLOC(height * width * 3); + if (!rgb8) { + return; + } + + util_format_translate( + PIPE_FORMAT_R8G8B8_UNORM, + rgb8, width * 3, + 0, 0, + format, + data, stride, + 0, 0, width, height); + /* Must be opened in binary mode or DOS line ending causes data + * to be read with one byte offset. + */ + f = fopen(filename, "wb"); + if (f) { fprintf(f, "P6\n"); - fprintf(f, "# ppm-file created by osdemo.c\n"); + fprintf(f, "# ppm-file created by gallium\n"); fprintf(f, "%i %i\n", width, height); fprintf(f, "255\n"); - fclose(f); - - f = fopen(filename, "ab"); /* reopen in binary append mode */ - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - i = y * stride + x * cpp; - fputc(ptr[i + r], f); /* write red */ - fputc(ptr[i + g], f); /* write green */ - fputc(ptr[i + b], f); /* write blue */ - } - } + fwrite(rgb8, 1, height * width * 3, f); fclose(f); } else { fprintf(stderr, "Can't open %s for writing\n", filename); } + + FREE(rgb8); } /* FIXME: dump resources, not surfaces... */ diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h index 3b42c2f07..0eb744333 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.h +++ b/mesalib/src/gallium/auxiliary/util/u_debug.h @@ -41,6 +41,8 @@ #include "os/os_misc.h" +#include "pipe/p_format.h" + #ifdef __cplusplus extern "C" { @@ -418,7 +420,7 @@ struct pipe_transfer; struct pipe_resource; void debug_dump_image(const char *prefix, - unsigned format, unsigned cpp, + enum pipe_format format, unsigned cpp, unsigned width, unsigned height, unsigned stride, const void *data); diff --git a/mesalib/src/gallium/auxiliary/util/u_draw.c b/mesalib/src/gallium/auxiliary/util/u_draw.c index 5b3c41231..83d9284b8 100644 --- a/mesalib/src/gallium/auxiliary/util/u_draw.c +++ b/mesalib/src/gallium/auxiliary/util/u_draw.c @@ -108,8 +108,15 @@ util_draw_max_index( else { /* Per-instance data. Simply make sure the state tracker didn't * request more instances than those that fit in the buffer */ - assert((info->start_instance + info->instance_count)/element->instance_divisor - <= (buffer_max_index + 1)); + if ((info->start_instance + info->instance_count)/element->instance_divisor + > (buffer_max_index + 1)) { + /* FIXME: We really should stop thinking in terms of maximum + * indices/instances and simply start clamping against buffer + * size. */ + debug_printf("%s: too many instances for vertex buffer\n", + __FUNCTION__); + return 0; + } } } } diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index e99431ef8..5b42afd0d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -266,13 +266,14 @@ util_clear_depth_stencil(struct pipe_context *pipe, unsigned dstx, unsigned dsty, unsigned width, unsigned height) { + enum pipe_format format = dst->format; struct pipe_transfer *dst_trans; ubyte *dst_map; boolean need_rmw = FALSE; if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) && ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) && - util_format_is_depth_and_stencil(dst->format)) + util_format_is_depth_and_stencil(format)) need_rmw = TRUE; assert(dst->texture); @@ -289,14 +290,14 @@ util_clear_depth_stencil(struct pipe_context *pipe, if (dst_map) { unsigned dst_stride = dst_trans->stride; - uint64_t zstencil = util_pack64_z_stencil(dst->texture->format, + uint64_t zstencil = util_pack64_z_stencil(format, depth, stencil); unsigned i, j; assert(dst_trans->stride > 0); - switch (util_format_get_blocksize(dst->format)) { + switch (util_format_get_blocksize(format)) { case 1: - assert(dst->format == PIPE_FORMAT_S8_UINT); + assert(format == PIPE_FORMAT_S8_UINT); if(dst_stride == width) memset(dst_map, (uint8_t) zstencil, height * width); else { @@ -307,7 +308,7 @@ util_clear_depth_stencil(struct pipe_context *pipe, } break; case 2: - assert(dst->format == PIPE_FORMAT_Z16_UNORM); + assert(format == PIPE_FORMAT_Z16_UNORM); for (i = 0; i < height; i++) { uint16_t *row = (uint16_t *)dst_map; for (j = 0; j < width; j++) @@ -326,10 +327,10 @@ util_clear_depth_stencil(struct pipe_context *pipe, } else { uint32_t dst_mask; - if (dst->format == PIPE_FORMAT_Z24_UNORM_S8_UINT) + if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT) dst_mask = 0xffffff00; else { - assert(dst->format == PIPE_FORMAT_S8_UINT_Z24_UNORM); + assert(format == PIPE_FORMAT_S8_UINT_Z24_UNORM); dst_mask = 0xffffff; } if (clear_flags & PIPE_CLEAR_DEPTH) |