r600g: add assertions after translate_colorswap/colorformat/dbformat/texformat
authorMarek Olšák <maraeo@gmail.com>
Sat, 7 Jul 2012 22:23:41 +0000 (00:23 +0200)
committerMarek Olšák <maraeo@gmail.com>
Mon, 9 Jul 2012 11:57:59 +0000 (13:57 +0200)
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c

index 15727986ea8c50b6c3db309fec20ff230d3422c4..939e05b06d89048b587dda9406e83a83fc96e5ba 100644 (file)
@@ -983,8 +983,10 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
        format = r600_translate_texformat(ctx->screen, state->format,
                                          swizzle,
                                          &word4, &yuv_format);
+       assert(format != ~0);
        if (format == ~0) {
-               format = 0;
+               FREE(view);
+               return NULL;
        }
 
        if (tmp->is_depth && !tmp->is_flushing_texture) {
@@ -1415,7 +1417,11 @@ static void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rsta
        }
 
        format = r600_translate_colorformat(surf->base.format);
+       assert(format != ~0);
+
        swap = r600_translate_colorswap(surf->base.format);
+       assert(swap != ~0);
+
        if (rtex->resource.b.b.usage == PIPE_USAGE_STAGING) {
                endian = ENDIAN_NONE;
        } else {
@@ -1534,6 +1540,7 @@ static void evergreen_db(struct r600_context *rctx, struct r600_pipe_state *rsta
        rtex = (struct r600_resource_texture*)surf->base.texture;
        first_layer = surf->base.u.tex.first_layer;
        format = r600_translate_dbformat(surf->base.format);
+       assert(format != ~0);
 
        offset = r600_resource_va(rctx->context.screen, surf->base.texture);
        /* XXX remove this once tiling is properly supported */
index 3fd77daae7d8fa0091db4e21138480acf1f3f233..d51c64bca5e0562289b3b9d5680550590c57bb7c 100644 (file)
@@ -995,8 +995,10 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
        format = r600_translate_texformat(ctx->screen, state->format,
                                          swizzle,
                                          &word4, &yuv_format);
+       assert(format != ~0);
        if (format == ~0) {
-               format = 0;
+               FREE(view);
+               return NULL;
        }
 
        if (tmp->is_depth && !tmp->is_flushing_texture) {
@@ -1456,8 +1458,12 @@ static void r600_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
        }
 
        format = r600_translate_colorformat(surf->base.format);
+       assert(format != ~0);
+
        swap = r600_translate_colorswap(surf->base.format);
-       if(rtex->resource.b.b.usage == PIPE_USAGE_STAGING) {
+       assert(swap != ~0);
+
+       if (rtex->resource.b.b.usage == PIPE_USAGE_STAGING) {
                endian = ENDIAN_NONE;
        } else {
                endian = r600_colorformat_endian_swap(format);
@@ -1612,6 +1618,7 @@ static void r600_db(struct r600_context *rctx, struct r600_pipe_state *rstate,
        }
 
        format = r600_translate_dbformat(state->zsbuf->format);
+       assert(format != ~0);
 
        r600_pipe_state_add_reg_bo(rstate, R_02800C_DB_DEPTH_BASE,
                                offset >> 8, &rtex->resource, RADEON_USAGE_READWRITE);