Mesa (master): i965g: Fix assertions that were always true.

Vinson Lee vlee at kemper.freedesktop.org
Sun Feb 21 09:25:41 UTC 2010


Module: Mesa
Branch: master
Commit: 0b83f48e8263ab9ea7c30a929f1d5764b9c61d2a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b83f48e8263ab9ea7c30a929f1d5764b9c61d2a

Author: Vinson Lee <vlee at vmware.com>
Date:   Sun Feb 21 01:19:47 2010 -0800

i965g: Fix assertions that were always true.

The surface_format field is 9 bits wide which has a maximum value
of 511. BRW_SURFACEFORMAT_INVALID has a value of 4095 which exceeds
the width of the surface_format field.

This patch asserts that the format is not BRW_SURFACEFORMAT_INVALID
before assignment to the surface_format field.

---

 src/gallium/drivers/i965/brw_screen_texture.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c
index feb9d5f..8bdd43c 100644
--- a/src/gallium/drivers/i965/brw_screen_texture.c
+++ b/src/gallium/drivers/i965/brw_screen_texture.c
@@ -191,6 +191,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
    struct brw_texture *tex;
    enum brw_buffer_type buffer_type;
    enum pipe_error ret;
+   GLuint format;
    
    tex = CALLOC_STRUCT(brw_texture);
    if (tex == NULL)
@@ -248,8 +249,10 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
 
    tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
    tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
-   tex->ss.ss0.surface_format = translate_tex_format(tex->base.format);
-   assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
+
+   format = translate_tex_target(tex->base.format);
+   assert(format != BRW_SURFACEFORMAT_INVALID);
+   tex->ss.ss0.surface_format = format;
 
    /* This is ok for all textures with channel width 8bit or less:
     */
@@ -474,6 +477,7 @@ brw_texture_blanket_winsys_buffer(struct pipe_screen *screen,
 {
    struct brw_screen *bscreen = brw_screen(screen);
    struct brw_texture *tex;
+   GLuint format;
 
    if (templ->target != PIPE_TEXTURE_2D ||
        templ->last_level != 0 ||
@@ -518,8 +522,10 @@ brw_texture_blanket_winsys_buffer(struct pipe_screen *screen,
 
    tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
    tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
-   tex->ss.ss0.surface_format = translate_tex_format(tex->base.format);
-   assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
+
+   format = translate_tex_format(tex->base.format);
+   assert(format != BRW_SURFACEFORMAT_INVALID);
+   tex->ss.ss0.surface_format = format;
 
    /* This is ok for all textures with channel width 8bit or less:
     */




More information about the mesa-commit mailing list