i965: Fix segfaults from 45a28a927ab7f29ff325b9326d386a39ba538c18
authorEric Anholt <eric@anholt.net>
Mon, 4 Feb 2013 17:32:06 +0000 (09:32 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 4 Feb 2013 21:58:55 +0000 (13:58 -0800)
If you look up a level that isn't in the miptree, you crash.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c

index e732b6d9b8e4f227db7d9169455c79fc040847a2..f8251b2f0feb2fab8c9f372e58259f8fb521e55f 100644 (file)
@@ -871,7 +871,8 @@ brw_update_texture_surface(struct gl_context *ctx,
 
    surf[4] = 0;
 
-   intel_miptree_get_tile_offsets(intelObj->mt, 0, 0, &tile_x, &tile_y);
+   intel_miptree_get_tile_offsets(intelObj->mt, firstImage->Level, 0,
+                                  &tile_x, &tile_y);
    assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
    /* Note that the low bits of these fields are missing, so
     * there's the possibility of getting in trouble.
index 9c8bc17d5cbf3c6627e6c5a1f91d9c6a9d5ba4a0..179024afc7959f682ae9ee309b906f7fe2e91476 100644 (file)
@@ -334,7 +334,8 @@ gen7_update_texture_surface(struct gl_context *ctx,
    surf[3] = SET_FIELD(depth - 1, BRW_SURFACE_DEPTH) |
              ((intelObj->mt->region->pitch) - 1);
 
-   intel_miptree_get_tile_offsets(intelObj->mt, 0, 0, &tile_x, &tile_y);
+   intel_miptree_get_tile_offsets(intelObj->mt, firstImage->Level, 0,
+                                  &tile_x, &tile_y);
    assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0));
    /* Note that the low bits of these fields are missing, so
     * there's the possibility of getting in trouble.