From: Kenneth Graunke Date: Wed, 25 Sep 2013 22:57:08 +0000 (-0700) Subject: i965: Move a bunch of code from intelInitContext to brwCreateContext. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0fb525b87ceae543d581a5755ca547b54c58aa76;p=mesa.git i965: Move a bunch of code from intelInitContext to brwCreateContext. 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 Reviewed-by: Ian Romanick --- diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 5494fcd6324..3846d3d0b07 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -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, diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 850b18cd65e..430967b5242 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -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));