i965: Don't rebase the index buffer to min 0 if any arrays are in VBOs.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_draw_upload.c
index 9cbff24863d0adbd5192ac97b0d0745b93c1afc9..f24c4146adbe1cf4108d5e33a2e278de53677572 100644 (file)
@@ -247,14 +247,14 @@ static void wrap_buffers( struct brw_context *brw,
    brw->vb.upload.offset = 0;
 
    if (brw->vb.upload.bo != NULL)
-      dri_bo_unreference(brw->vb.upload.bo);
-   brw->vb.upload.bo = dri_bo_alloc(brw->intel.bufmgr, "temporary VBO",
-                                   size, 1);
+      drm_intel_bo_unreference(brw->vb.upload.bo);
+   brw->vb.upload.bo = drm_intel_bo_alloc(brw->intel.bufmgr, "temporary VBO",
+                                         size, 1);
 }
 
 static void get_space( struct brw_context *brw,
                       GLuint size,
-                      dri_bo **bo_return,
+                      drm_intel_bo **bo_return,
                       GLuint *offset_return )
 {
    size = ALIGN(size, 64);
@@ -265,7 +265,7 @@ static void get_space( struct brw_context *brw,
    }
 
    assert(*bo_return == NULL);
-   dri_bo_reference(brw->vb.upload.bo);
+   drm_intel_bo_reference(brw->vb.upload.bo);
    *bo_return = brw->vb.upload.bo;
    *offset_return = brw->vb.upload.offset;
    brw->vb.upload.offset += size;
@@ -361,10 +361,10 @@ static void brw_prepare_vertices(struct brw_context *brw)
            intel_buffer_object(input->glarray->BufferObj);
 
         /* Named buffer object: Just reference its contents directly. */
-        dri_bo_unreference(input->bo);
+        drm_intel_bo_unreference(input->bo);
         input->bo = intel_bufferobj_buffer(intel, intel_buffer,
                                            INTEL_READ);
-        dri_bo_reference(input->bo);
+        drm_intel_bo_reference(input->bo);
         input->offset = (unsigned long)input->glarray->Ptr;
         input->stride = input->glarray->StrideB;
         input->count = input->glarray->_MaxElement;
@@ -383,7 +383,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
          */
         assert(input->offset < input->bo->size);
       } else {
-        input->count = input->glarray->StrideB ? max_index + 1 - min_index : 1;
+        input->count = input->glarray->StrideB ? max_index + 1 : 1;
         if (input->bo != NULL) {
            /* Already-uploaded vertex data is present from a previous
             * prepare_vertices, but we had to re-validate state due to
@@ -414,15 +414,6 @@ static void brw_prepare_vertices(struct brw_context *brw)
         }
 
         upload[nr_uploads++] = input;
-        
-        /* We rebase drawing to start at element zero only when
-         * varyings are not in vbos, which means we can end up
-         * uploading non-varying arrays (stride != 0) when min_index
-         * is zero.  This doesn't matter as the amount to upload is
-         * the same for these arrays whether the draw call is rebased
-         * or not - we just have to upload the one element.
-         */
-        assert(min_index == 0 || input->glarray->StrideB == 0);
       }
    }
 
@@ -439,7 +430,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
         upload[i]->offset = upload[0]->offset +
            ((const unsigned char *)upload[i]->glarray->Ptr - ptr);
         upload[i]->bo = upload[0]->bo;
-        dri_bo_reference(upload[i]->bo);
+        drm_intel_bo_reference(upload[i]->bo);
       }
    }
    else {
@@ -476,7 +467,7 @@ static void brw_emit_vertices(struct brw_context *brw)
    if (brw->vb.nr_enabled == 0) {
       BEGIN_BATCH(3);
       OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | 1);
-      if (IS_GEN6(intel->intelScreen->deviceID)) {
+      if (intel->gen >= 6) {
         OUT_BATCH((0 << GEN6_VE0_INDEX_SHIFT) |
                   GEN6_VE0_VALID |
                   (BRW_SURFACEFORMAT_R32G32B32A32_FLOAT << BRW_VE0_FORMAT_SHIFT) |
@@ -553,7 +544,7 @@ static void brw_emit_vertices(struct brw_context *brw)
         break;
       }
 
-      if (IS_GEN6(intel->intelScreen->deviceID)) {
+      if (intel->gen >= 6) {
         OUT_BATCH((i << GEN6_VE0_INDEX_SHIFT) |
                   GEN6_VE0_VALID |
                   (format << BRW_VE0_FORMAT_SHIFT) |
@@ -596,7 +587,7 @@ static void brw_prepare_indices(struct brw_context *brw)
    struct intel_context *intel = &brw->intel;
    const struct _mesa_index_buffer *index_buffer = brw->ib.ib;
    GLuint ib_size;
-   dri_bo *bo = NULL;
+   drm_intel_bo *bo = NULL;
    struct gl_buffer_object *bufferobj;
    GLuint offset;
    GLuint ib_type_size;
@@ -638,13 +629,13 @@ static void brw_prepare_indices(struct brw_context *brw)
 
           get_space(brw, ib_size, &bo, &offset);
 
-          dri_bo_subdata(bo, offset, ib_size, map);
+          drm_intel_bo_subdata(bo, offset, ib_size, map);
 
            ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, bufferobj);
        } else {
          bo = intel_bufferobj_buffer(intel, intel_buffer_object(bufferobj),
                                      INTEL_READ);
-         dri_bo_reference(bo);
+         drm_intel_bo_reference(bo);
 
          /* Use CMD_3D_PRIM's start_vertex_offset to avoid re-uploading
           * the index buffer state when we're just moving the start index