i965/miptree: Set refcount before failing via _release()
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Mon, 3 Jul 2017 11:23:35 +0000 (14:23 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 18 Jul 2017 18:35:03 +0000 (21:35 +0300)
Otherwise one wraps uint to UINT_MAX via -1.

Fixes: 3cf470f2b6c ("i965: Add isl based miptree creator")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c

index 47475689f9c394baf01fe2f156b1c60084cee3f9..5f60abb3de362159704a94abde2b4af3b772e2f5 100644 (file)
@@ -709,6 +709,8 @@ make_surface(struct brw_context *brw, GLenum target, mesa_format format,
       return NULL;
    }
 
+   mt->refcount = 1;
+
    if (target == GL_TEXTURE_CUBE_MAP ||
        target == GL_TEXTURE_CUBE_MAP_ARRAY)
       isl_usage_flags |= ISL_SURF_USAGE_CUBE_BIT;
@@ -753,7 +755,6 @@ make_surface(struct brw_context *brw, GLenum target, mesa_format format,
    mt->last_level = last_level;
    mt->target = target;
    mt->format = format;
-   mt->refcount = 1;
    mt->aux_state = NULL;
 
    return mt;