OSDN Git Service

i965: Remove software geometry query code.
[android-x86/external-mesa.git] / src / mesa / drivers / dri / i965 / brw_draw.c
index cb8e682..4dd185e 100644 (file)
@@ -136,6 +136,14 @@ static void gen6_set_prim(struct brw_context *brw,
 }
 
 
+/**
+ * The hardware is capable of removing dangling vertices on its own; however,
+ * prior to Gen6, we sometimes convert quads into trifans (and quad strips
+ * into tristrips), since pre-Gen6 hardware requires a GS to render quads.
+ * This function manually trims dangling vertices from a draw call involving
+ * quads so that those dangling vertices won't get drawn when we convert to
+ * trifans/tristrips.
+ */
 static GLuint trim(GLenum prim, GLuint length)
 {
    if (prim == GL_QUAD_STRIP)
@@ -171,7 +179,11 @@ static void brw_emit_prim(struct brw_context *brw,
       start_vertex_location += brw->vb.start_vertex_bias;
    }
 
-   verts_per_instance = trim(prim->mode, prim->count);
+   /* We only need to trim the primitive count on pre-Gen6. */
+   if (intel->gen < 6)
+      verts_per_instance = trim(prim->mode, prim->count);
+   else
+      verts_per_instance = prim->count;
 
    /* If nothing to emit, just return. */
    if (verts_per_instance == 0)
@@ -193,7 +205,7 @@ static void brw_emit_prim(struct brw_context *brw,
    OUT_BATCH(verts_per_instance);
    OUT_BATCH(start_vertex_location);
    OUT_BATCH(prim->num_instances);
-   OUT_BATCH(0); // start instance location
+   OUT_BATCH(prim->base_instance);
    OUT_BATCH(base_vertex_location);
    ADVANCE_BATCH();
 
@@ -228,7 +240,7 @@ static void gen7_emit_prim(struct brw_context *brw,
       start_vertex_location += brw->vb.start_vertex_bias;
    }
 
-   verts_per_instance = trim(prim->mode, prim->count);
+   verts_per_instance = prim->count;
 
    /* If nothing to emit, just return. */
    if (verts_per_instance == 0)
@@ -249,7 +261,7 @@ static void gen7_emit_prim(struct brw_context *brw,
    OUT_BATCH(verts_per_instance);
    OUT_BATCH(start_vertex_location);
    OUT_BATCH(prim->num_instances);
-   OUT_BATCH(0); // start instance location
+   OUT_BATCH(prim->base_instance);
    OUT_BATCH(base_vertex_location);
    ADVANCE_BATCH();
 
@@ -262,7 +274,6 @@ static void gen7_emit_prim(struct brw_context *brw,
 static void brw_merge_inputs( struct brw_context *brw,
                       const struct gl_client_array *arrays[])
 {
-   struct brw_vertex_info old = brw->vb.info;
    GLuint i;
 
    for (i = 0; i < brw->vb.nr_buffers; i++) {
@@ -271,21 +282,11 @@ static void brw_merge_inputs( struct brw_context *brw,
    }
    brw->vb.nr_buffers = 0;
 
-   memset(&brw->vb.info, 0, sizeof(brw->vb.info));
-
    for (i = 0; i < VERT_ATTRIB_MAX; i++) {
       brw->vb.inputs[i].buffer = -1;
       brw->vb.inputs[i].glarray = arrays[i];
       brw->vb.inputs[i].attrib = (gl_vert_attrib) i;
-
-      if (arrays[i]->StrideB != 0)
-        brw->vb.info.sizes[i/16] |= (brw->vb.inputs[i].glarray->Size - 1) <<
-           ((i%16) * 2);
    }
-
-   /* Raise statechanges if input sizes have changed. */
-   if (memcmp(brw->vb.info.sizes, old.sizes, sizeof(old.sizes)) != 0)
-      brw->state.dirty.brw |= BRW_NEW_INPUT_DIMENSIONS;
 }
 
 /*
@@ -385,7 +386,6 @@ brw_update_primitive_count(struct brw_context *brw,
    uint32_t count
       = vbo_count_tessellated_primitives(prim->mode, prim->count,
                                          prim->num_instances);
-   brw->sol.primitives_generated += count;
    if (_mesa_is_xfb_active_and_unpaused(&brw->intel.ctx)) {
       /* Update brw->sol.svbi_0_max_index to reflect the amount by which the
        * hardware is going to increment SVBI 0 when this drawing operation
@@ -399,9 +399,6 @@ brw_update_primitive_count(struct brw_context *brw,
          (brw->sol.svbi_0_max_index - brw->sol.svbi_0_starting_index) / verts;
       uint32_t primitives_written = MIN2 (space_avail, count);
       brw->sol.svbi_0_starting_index += verts * primitives_written;
-
-      /* And update the TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query. */
-      brw->sol.primitives_written += primitives_written;
    }
 }
 
@@ -436,17 +433,17 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
 
    intel_prepare_render(intel);
 
+   /* This workaround has to happen outside of brw_upload_state() because it
+    * may flush the batchbuffer for a blit, affecting the state flags.
+    */
+   brw_workaround_depthstencil_alignment(brw, 0);
+
    /* Resolves must occur after updating renderbuffers, updating context state,
     * and finalizing textures but before setting up any hardware state for
     * this draw call.
     */
    brw_predraw_resolve_buffers(brw);
 
-   /* This workaround has to happen outside of brw_state_upload() because it
-    * may flush the batchbuffer for a blit, affecting the state flags.
-    */
-   brw_workaround_depthstencil_alignment(brw);
-
    /* Bind all inputs, derive varying and size information:
     */
    brw_merge_inputs( brw, arrays );
@@ -550,6 +547,7 @@ void brw_draw_prims( struct gl_context *ctx,
                     GLuint max_index,
                     struct gl_transform_feedback_object *tfb_vertcount )
 {
+   struct intel_context *intel = intel_context(ctx);
    const struct gl_client_array **arrays = ctx->Array._DrawArrays;
 
    if (!_mesa_check_conditional_render(ctx))