i965: Require hardware contexts (and thus Kernel 3.6) on Gen6+. 54/6654/1
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 16 May 2013 04:18:28 +0000 (21:18 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 20 May 2013 20:03:17 +0000 (13:03 -0700)
Hardware contexts are necessary to reasonably support OpenGL 3.2.
In particular, we currently maintain software counters for transform
feedback buffer offsets and counters, which relies on knowing the number
of primitives generated.  Geometry shaders violate that assumption.

At the time of writing, Debian has moved to Kernel 3.8, which means most
people probably have a newer kernel by now.  It's also worth noting that
this patch won't land until Mesa 10 which is currently targeted for
September.  By that point, even more people will have a newer kernel.

Also, don't bother trying to allocate contexts on pre-Gen6, as it
currently will always fail, and if this changes in the future, we'll
need to reevaluate our hw_ctx/gen checks.

This patch leaves the code for flagging BRW_NEW_CONTEXT on new
batchbuffers if hw_ctx == NULL since that still occurs pre-Gen6.

Also remove the Gen7+ check for kernel 3.3, since it's now redundant.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/intel/intel_screen.c

index 69b7e4d..2f5fedb 100644 (file)
@@ -143,6 +143,23 @@ brwCreateContext(int api,
       return false;
    }
 
+   if (intel->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
+       * to assume that the GPU is in the same state we left it in.
+       *
+       * This is required for transform feedback buffer offsets, query objects,
+       * and also allows us to reduce how much state we have to emit.
+       */
+      intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);
+
+      if (!intel->hw_ctx) {
+         fprintf(stderr, "Gen6+ requires Kernel 3.6 or later.\n");
+         ralloc_free(brw);
+         return false;
+      }
+   }
+
    brw_init_surface_formats(brw);
 
    /* Initialize swrast, tnl driver tables: */
@@ -374,7 +391,6 @@ brwCreateContext(int api,
 
    brw->prim_restart.in_progress = false;
    brw->prim_restart.enable_cut_index = false;
-   intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);
 
    brw_init_state( brw );
 
index 433f4ed..325304d 100644 (file)
@@ -1301,13 +1301,6 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
       intelScreen->gen = 2;
    }
 
-   if (intelScreen->gen == 7 &&
-       !intel_get_boolean(intelScreen->driScrnPriv,
-                          I915_PARAM_HAS_GEN7_SOL_RESET)) {
-      fprintf(stderr, "i965 requires Kernel 3.3 or later.\n");
-      return false;
-   }
-
    intelScreen->hw_has_separate_stencil = intelScreen->gen >= 6;
    intelScreen->hw_must_use_separate_stencil = intelScreen->gen >= 7;