i965: Move a bunch of code from intelInitContext to brwCreateContext.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 25 Sep 2013 22:57:08 +0000 (15:57 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 13 Oct 2013 07:10:43 +0000 (00:10 -0700)
Now that intelInitContext isn't shared between i915 and i965, the split
is fairly arbitrary.  This patch moves a bunch of the basic context
creation and generation checking code up to the top-level function
(and slightly earlier).

More will follow.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/intel_context.c

index 5494fcd632420e882b5f26da84812af20de39405..3846d3d0b07930af2e5e759c221ce308d47f15fe 100644 (file)
@@ -31,6 +31,7 @@
 
 
 #include "main/api_exec.h"
+#include "main/context.h"
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/points.h"
@@ -286,8 +287,10 @@ brwCreateContext(gl_api api,
                 void *sharedContextPrivate)
 {
    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+   struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
    struct intel_screen *screen = sPriv->driverPrivate;
    struct dd_function_table functions;
+   struct gl_config visual;
 
    struct brw_context *brw = rzalloc(NULL, struct brw_context);
    if (!brw) {
@@ -296,17 +299,55 @@ brwCreateContext(gl_api api,
       return false;
    }
 
-   /* brwInitVtbl needs to know the chipset generation so that it can set the
-    * right pointers.
-    */
+   driContextPriv->driverPrivate = brw;
+   brw->driContext = driContextPriv;
+   brw->intelScreen = screen;
+   brw->bufmgr = screen->bufmgr;
    brw->gen = screen->gen;
 
+   const int devID = screen->deviceID;
+   if (IS_SNB_GT1(devID) || IS_IVB_GT1(devID) || IS_HSW_GT1(devID))
+      brw->gt = 1;
+   else if (IS_SNB_GT2(devID) || IS_IVB_GT2(devID) || IS_HSW_GT2(devID))
+      brw->gt = 2;
+   else if (IS_HSW_GT3(devID))
+      brw->gt = 3;
+   else
+      brw->gt = 0;
+
+   if (IS_HASWELL(devID)) {
+      brw->is_haswell = true;
+   } else if (IS_BAYTRAIL(devID)) {
+      brw->is_baytrail = true;
+      brw->gt = 1;
+   } else if (IS_G4X(devID)) {
+      brw->is_g4x = true;
+   }
+
+   brw->has_separate_stencil = screen->hw_has_separate_stencil;
+   brw->must_use_separate_stencil = screen->hw_must_use_separate_stencil;
+   brw->has_hiz = brw->gen >= 6;
+   brw->has_llc = screen->hw_has_llc;
+   brw->has_swizzling = screen->hw_has_swizzling;
+
    brwInitVtbl( brw );
 
    brwInitDriverFunctions(screen, &functions);
 
    struct gl_context *ctx = &brw->ctx;
 
+   if (mesaVis == NULL) {
+      memset(&visual, 0, sizeof visual);
+      mesaVis = &visual;
+   }
+
+   if (!_mesa_initialize_context(ctx, api, mesaVis, shareCtx, &functions)) {
+      *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY;
+      printf("%s: failed to init mesa context\n", __FUNCTION__);
+      intelDestroyContext(driContextPriv);
+      return false;
+   }
+
    if (!intelInitContext( brw, api, major_version, minor_version,
                           mesaVis, driContextPriv,
                          sharedContextPrivate, &functions,
index 850b18cd65e63145669dc9b37a892bde24db33f0..430967b52429d189f7594ad5a66fc0127ec5766b 100644 (file)
@@ -367,11 +367,9 @@ intelInitContext(struct brw_context *brw,
                  unsigned *dri_ctx_error)
 {
    struct gl_context *ctx = &brw->ctx;
-   struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct intel_screen *intelScreen = sPriv->driverPrivate;
    int bo_reuse_mode;
-   struct gl_config visual;
 
    /* GLX uses DRI2 invalidate events to handle window resizing.
     * Unfortunately, EGL does not - libEGL is written in XCB (not Xlib),
@@ -385,51 +383,6 @@ intelInitContext(struct brw_context *brw,
       functions->Viewport = intel_viewport;
    }
 
-   if (mesaVis == NULL) {
-      memset(&visual, 0, sizeof visual);
-      mesaVis = &visual;
-   }
-
-   brw->intelScreen = intelScreen;
-   brw->bufmgr = intelScreen->bufmgr;
-
-   driContextPriv->driverPrivate = brw;
-   brw->driContext = driContextPriv;
-
-   if (!_mesa_initialize_context(&brw->ctx, api, mesaVis, shareCtx,
-                                 functions)) {
-      *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY;
-      printf("%s: failed to init mesa context\n", __FUNCTION__);
-      return false;
-   }
-
-   brw->gen = intelScreen->gen;
-
-   const int devID = intelScreen->deviceID;
-   if (IS_SNB_GT1(devID) || IS_IVB_GT1(devID) || IS_HSW_GT1(devID))
-      brw->gt = 1;
-   else if (IS_SNB_GT2(devID) || IS_IVB_GT2(devID) || IS_HSW_GT2(devID))
-      brw->gt = 2;
-   else if (IS_HSW_GT3(devID))
-      brw->gt = 3;
-   else
-      brw->gt = 0;
-
-   if (IS_HASWELL(devID)) {
-      brw->is_haswell = true;
-   } else if (IS_BAYTRAIL(devID)) {
-      brw->is_baytrail = true;
-      brw->gt = 1;
-   } else if (IS_G4X(devID)) {
-      brw->is_g4x = true;
-   }
-
-   brw->has_separate_stencil = brw->intelScreen->hw_has_separate_stencil;
-   brw->must_use_separate_stencil = brw->intelScreen->hw_must_use_separate_stencil;
-   brw->has_hiz = brw->gen >= 6;
-   brw->has_llc = brw->intelScreen->hw_has_llc;
-   brw->has_swizzling = brw->intelScreen->hw_has_swizzling;
-
    memset(&ctx->TextureFormatSupported,
          0, sizeof(ctx->TextureFormatSupported));