[Mesa-dev] [PATCH 22/29] i965: Merge intelInitContext into brwCreateContext.

Kenneth Graunke kenneth at whitecape.org
Fri Sep 27 16:46:01 PDT 2013


The split here was completely arbitrary.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_context.c   | 116 +++++++++++-------------------
 src/mesa/drivers/dri/i965/intel_context.h |  10 ---
 2 files changed, 43 insertions(+), 83 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 0ad9ead..76d481d 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -544,21 +544,42 @@ brwCreateContext(int api,
       return false;
    }
 
-   brw_process_driconf_options(brw);
+   /* Initialize the software rasterizer and helper modules.
+    *
+    * As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
+    * software fallbacks (which we have to support on legacy GL to do weird
+    * glDrawPixels(), glBitmap(), and other functions).
+    */
+   if (api != API_OPENGL_CORE && api != API_OPENGLES2) {
+      _swrast_CreateContext(ctx);
+   }
 
-   if (!intelInitContext( brw, api, major_version, minor_version,
-                          mesaVis, driContextPriv,
-			  sharedContextPrivate, &functions,
-			  dri_ctx_error)) {
-      intelDestroyContext(driContextPriv);
-      return false;
+   _vbo_CreateContext(ctx);
+   if (ctx->swrast_context) {
+      _tnl_CreateContext(ctx);
+      TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+      _swsetup_CreateContext(ctx);
+
+      /* Configure swrast to match hardware characteristics: */
+      _swrast_allow_pixel_fog(ctx, false);
+      _swrast_allow_vertex_fog(ctx, true);
    }
 
+   _mesa_meta_init(ctx);
+
+   brw_process_driconf_options(brw);
+   brw_process_intel_debug_variable(brw);
    brw_initialize_context_constants(brw);
 
    /* Reinitialize the context point state.  It depends on ctx->Const values. */
    _mesa_init_point(ctx);
 
+   intelInitExtensions(ctx);
+
+   intel_batchbuffer_init(brw);
+
+   intel_fbo_init(brw);
+
    if (brw->gen >= 6) {
       /* Create a new hardware context.  Using a hardware context means that
        * our GPU state will be saved/restored on context switch, allowing us
@@ -578,11 +599,6 @@ brwCreateContext(int api,
 
    brw_init_surface_formats(brw);
 
-   /* Initialize swrast, tnl driver tables: */
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   if (tnl)
-      tnl->Driver.RunPipeline = _tnl_run_pipeline;
-
    ctx->DriverFlags.NewTransformFeedback = BRW_NEW_TRANSFORM_FEEDBACK;
    ctx->DriverFlags.NewRasterizerDiscard = BRW_NEW_RASTERIZER_DISCARD;
    ctx->DriverFlags.NewUniformBuffer = BRW_NEW_UNIFORM_BUFFER;
@@ -603,6 +619,21 @@ brwCreateContext(int api,
    brw->urb.max_vs_entries = devinfo->urb.max_vs_entries;
    brw->urb.max_gs_entries = devinfo->urb.max_gs_entries;
 
+   /* Estimate the size of the mappable aperture into the GTT.  There's an
+    * ioctl to get the whole GTT size, but not one to get the mappable subset.
+    * It turns out it's basically always 256MB, though some ancient hardware
+    * was smaller.
+    */
+   uint32_t gtt_size = 256 * 1024 * 1024;
+
+   /* We don't want to map two objects such that a memcpy between them would
+    * just fault one mapping in and then the other over and over forever.  So
+    * we would need to divide the GTT size by 2.  Additionally, some GTT is
+    * taken up by things like the framebuffer and the ringbuffer and such, so
+    * be more conservative.
+    */
+   brw->max_gtt_map_object_size = gtt_size / 4;
+
    if (brw->gen == 6)
       brw->urb.gen6_gs_previously_active = false;
 
@@ -642,67 +673,6 @@ brwCreateContext(int api,
    return true;
 }
 
-bool
-intelInitContext(struct brw_context *brw,
-                 int api,
-                 unsigned major_version,
-                 unsigned minor_version,
-                 const struct gl_config * mesaVis,
-                 __DRIcontext * driContextPriv,
-                 void *sharedContextPrivate,
-                 struct dd_function_table *functions,
-                 unsigned *dri_ctx_error)
-{
-   struct gl_context *ctx = &brw->ctx;
-
-   /* Estimate the size of the mappable aperture into the GTT.  There's an
-    * ioctl to get the whole GTT size, but not one to get the mappable subset.
-    * It turns out it's basically always 256MB, though some ancient hardware
-    * was smaller.
-    */
-   uint32_t gtt_size = 256 * 1024 * 1024;
-
-   /* We don't want to map two objects such that a memcpy between them would
-    * just fault one mapping in and then the other over and over forever.  So
-    * we would need to divide the GTT size by 2.  Additionally, some GTT is
-    * taken up by things like the framebuffer and the ringbuffer and such, so
-    * be more conservative.
-    */
-   brw->max_gtt_map_object_size = gtt_size / 4;
-
-   /* Initialize the software rasterizer and helper modules.
-    *
-    * As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
-    * software fallbacks (which we have to support on legacy GL to do weird
-    * glDrawPixels(), glBitmap(), and other functions).
-    */
-   if (api != API_OPENGL_CORE && api != API_OPENGLES2) {
-      _swrast_CreateContext(ctx);
-   }
-
-   _vbo_CreateContext(ctx);
-   if (ctx->swrast_context) {
-      _tnl_CreateContext(ctx);
-      _swsetup_CreateContext(ctx);
-
-      /* Configure swrast to match hardware characteristics: */
-      _swrast_allow_pixel_fog(ctx, false);
-      _swrast_allow_vertex_fog(ctx, true);
-   }
-
-   _mesa_meta_init(ctx);
-
-   intelInitExtensions(ctx);
-
-   brw_process_intel_debug_variable(brw);
-
-   intel_batchbuffer_init(brw);
-
-   intel_fbo_init(brw);
-
-   return true;
-}
-
 void
 intelDestroyContext(__DRIcontext * driContextPriv)
 {
diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
index 9ec8c63..7856462 100644
--- a/src/mesa/drivers/dri/i965/intel_context.h
+++ b/src/mesa/drivers/dri/i965/intel_context.h
@@ -164,16 +164,6 @@ static INLINE void * __memcpy(void * to, const void * from, size_t n)
  * intel_context.c:
  */
 
-extern bool intelInitContext(struct brw_context *brw,
-                             int api,
-                             unsigned major_version,
-                             unsigned minor_version,
-                             const struct gl_config * mesaVis,
-                             __DRIcontext * driContextPriv,
-                             void *sharedContextPrivate,
-                             struct dd_function_table *functions,
-                             unsigned *dri_ctx_error);
-
 extern void intelFinish(struct gl_context * ctx);
 
 extern void intelInitDriverFunctions(struct dd_function_table *functions);
-- 
1.8.3.4



More information about the mesa-dev mailing list