i965: Split brw_set_prim into brw/gen6 variants
[mesa.git] / src / mesa / drivers / dri / i965 / brw_draw.c
index 6c52bd52aa420961797037491c1e043eb59bafd1..39d38a57a4a9492e05eb6974ac0ff56d01c19231 100644 (file)
@@ -115,6 +115,19 @@ static GLuint brw_set_prim(struct brw_context *brw,
    return prim_to_hw_prim[mode];
 }
 
+static GLuint gen6_set_prim(struct brw_context *brw,
+                            const struct _mesa_prim *prim)
+{
+   DBG("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim->mode));
+
+   if (prim->mode != brw->primitive) {
+      brw->primitive = prim->mode;
+      brw->state.dirty.brw |= BRW_NEW_PRIMITIVE;
+   }
+
+   return prim_to_hw_prim[mode];
+}
+
 
 static GLuint trim(GLenum prim, GLuint length)
 {
@@ -177,6 +190,8 @@ static void brw_emit_prim(struct brw_context *brw,
    OUT_BATCH(base_vertex_location);
    ADVANCE_BATCH();
 
+   intel->batch.need_workaround_flush = true;
+
    if (intel->always_flush_cache) {
       intel_batchbuffer_emit_mi_flush(intel);
    }
@@ -266,66 +281,6 @@ static void brw_merge_inputs( struct brw_context *brw,
       brw->state.dirty.brw |= BRW_NEW_INPUT_DIMENSIONS;
 }
 
-/* XXX: could split the primitive list to fallback only on the
- * non-conformant primitives.
- */
-static GLboolean check_fallbacks( struct brw_context *brw,
-                                 const struct _mesa_prim *prim,
-                                 GLuint nr_prims )
-{
-   struct gl_context *ctx = &brw->intel.ctx;
-   GLuint i;
-
-   /* If we don't require strict OpenGL conformance, never 
-    * use fallbacks.  If we're forcing fallbacks, always
-    * use fallfacks.
-    */
-   if (brw->intel.conformance_mode == 0)
-      return GL_FALSE;
-
-   if (ctx->Polygon.SmoothFlag) {
-      for (i = 0; i < nr_prims; i++)
-        if (reduced_prim[prim[i].mode] == GL_TRIANGLES) 
-           return GL_TRUE;
-   }
-
-   /* BRW hardware will do AA lines, but they are non-conformant it
-    * seems.  TBD whether we keep this fallback:
-    */
-   if (ctx->Line.SmoothFlag) {
-      for (i = 0; i < nr_prims; i++)
-        if (reduced_prim[prim[i].mode] == GL_LINES) 
-           return GL_TRUE;
-   }
-
-   /* Stipple -- these fallbacks could be resolved with a little
-    * bit of work?
-    */
-   if (ctx->Line.StippleFlag) {
-      for (i = 0; i < nr_prims; i++) {
-        /* GS doesn't get enough information to know when to reset
-         * the stipple counter?!?
-         */
-        if (prim[i].mode == GL_LINE_LOOP || prim[i].mode == GL_LINE_STRIP) 
-           return GL_TRUE;
-           
-        if (prim[i].mode == GL_POLYGON &&
-            (ctx->Polygon.FrontMode == GL_LINE ||
-             ctx->Polygon.BackMode == GL_LINE))
-           return GL_TRUE;
-      }
-   }
-
-   if (ctx->Point.SmoothFlag) {
-      for (i = 0; i < nr_prims; i++)
-        if (prim[i].mode == GL_POINTS) 
-           return GL_TRUE;
-   }
-
-   /* Nothing stopping us from the fast path now */
-   return GL_FALSE;
-}
-
 /* May fail if out of video memory for texture or vbo upload, or on
  * fallback conditions.
  */
@@ -355,9 +310,6 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
     */
    brw_validate_textures( brw );
 
-   if (check_fallbacks(brw, prim, nr_prims))
-      return GL_FALSE;
-
    /* Bind all inputs, derive varying and size information:
     */
    brw_merge_inputs( brw, arrays );
@@ -396,7 +348,11 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
        */
       intel_batchbuffer_require_space(intel, estimated_max_prim_size, false);
 
-      hw_prim = brw_set_prim(brw, &prim[i]);
+      if (intel->gen < 6)
+        hw_prim = brw_set_prim(brw, &prim[i]);
+      else
+        hw_prim = gen6_set_prim(brw, &prim[i]);
+
       if (brw->state.dirty.brw) {
         brw_validate_state(brw);
 
@@ -497,6 +453,7 @@ void brw_draw_prims( struct gl_context *ctx,
     */
    if (!retval) {
        _swsetup_Wakeup(ctx);
+       _tnl_wakeup(ctx);
       _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
    }