i965: Don't free the intel_context structure when intelCreateContext fails.
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 31 Aug 2012 21:55:21 +0000 (14:55 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 28 Sep 2012 22:40:20 +0000 (15:40 -0700)
This squashes two commits from master:

    i965: Don't free the intel_context structure when intelCreateContext fails.

    intelDestroyContext will eventually be called, and it will clean things
    up.  The call to brwInitVtbl is moved earlier so that
    intelDestroyContext can call the device-specific destructor.  This also
    makes the code look more like the i915 code.

    NOTE: This is a candidate for the 9.0 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54301
    (cherry picked from commit 87f26214d6bdeb439b30615ec53c293c5141cf11)

And:

    i965: brwInitVtbl needs to know the chipset generation

    Fixes major regressions since de958de.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
    (cherry picked from commit e87c63f2889fcbeb5a8bbd91eda1333d7ed44bf2)

The second commit message should have read 'since 87f2621', of course.

src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_vtbl.c

index 4e5aed6..e94df26 100644 (file)
@@ -140,6 +140,13 @@ brwCreateContext(int api,
       return false;
    }
 
+   /* brwInitVtbl needs to know the chipset generation so that it can set the
+    * right pointers.
+    */
+   brw->intel.gen = screen->gen;
+
+   brwInitVtbl( brw );
+
    brwInitDriverFunctions(screen, &functions);
 
    struct intel_context *intel = &brw->intel;
@@ -148,13 +155,10 @@ brwCreateContext(int api,
    if (!intelInitContext( intel, api, mesaVis, driContextPriv,
                          sharedContextPrivate, &functions )) {
       printf("%s: failed to init intel context\n", __FUNCTION__);
-      FREE(brw);
       *error = __DRI_CTX_ERROR_NO_MEMORY;
       return false;
    }
 
-   brwInitVtbl( brw );
-
    brw_init_surface_formats(brw);
 
    /* Initialize swrast, tnl driver tables: */
index 9951e7d..ca2e7a9 100644 (file)
@@ -249,6 +249,7 @@ void brwInitVtbl( struct brw_context *brw )
    brw->intel.vtbl.render_target_supported = brw_render_target_supported;
    brw->intel.vtbl.is_hiz_depth_format = brw_is_hiz_depth_format;
 
+   assert(brw->intel.gen >= 4);
    if (brw->intel.gen >= 7) {
       gen7_init_vtable_surface_functions(brw);
    } else if (brw->intel.gen >= 4) {