mesa/st: draw_vbo: initialize restart_index too
[mesa.git] / src / mesa / state_tracker / st_draw.c
index e9ffc18d915220b9cc4af306296c6d61b542ba5a..dee69783adae945044ac736dd48e56baf49c9952 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 
+#include "main/errors.h"
 #include "main/imports.h"
 #include "main/image.h"
 #include "main/bufferobj.h"
@@ -145,10 +146,6 @@ st_draw_vbo(struct gl_context *ctx,
    unsigned i;
    unsigned start = 0;
 
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
-   _vbo_update_inputs(ctx, &st->draw_arrays);
-
    prepare_draw(st, ctx);
 
    if (st->vertex_array_out_of_memory)
@@ -159,6 +156,7 @@ st_draw_vbo(struct gl_context *ctx,
    info.vertices_per_patch = ctx->TessCtrlProgram.patch_vertices;
    info.indirect = NULL;
    info.count_from_stream_output = NULL;
+   info.restart_index = 0;
 
    if (ib) {
       struct gl_buffer_object *bufobj = ib->obj;
@@ -177,6 +175,13 @@ st_draw_vbo(struct gl_context *ctx,
          /* indices are in a real VBO */
          info.has_user_indices = false;
          info.index.resource = st_buffer_object(bufobj)->buffer;
+
+         /* Return if the bound element array buffer doesn't have any backing
+          * storage. (nothing to do)
+          */
+         if (!info.index.resource)
+            return;
+
          start = pointer_to_offset(ib->ptr) / info.index_size;
       } else {
          /* indices are in user space memory */
@@ -247,10 +252,6 @@ st_indirect_draw_vbo(struct gl_context *ctx,
    struct pipe_draw_info info;
    struct pipe_draw_indirect_info indirect;
 
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
-   _vbo_update_inputs(ctx, &st->draw_arrays);
-
    assert(stride);
    prepare_draw(st, ctx);
 
@@ -419,15 +420,7 @@ st_draw_quad(struct st_context *st,
 
    u_upload_unmap(st->pipe->stream_uploader);
 
-   /* At the time of writing, cso_get_aux_vertex_buffer_slot() always returns
-    * zero.  If that ever changes we need to audit the calls to that function
-    * and make sure the slot number is used consistently everywhere.
-    */
-   assert(cso_get_aux_vertex_buffer_slot(st->cso_context) == 0);
-
-   cso_set_vertex_buffers(st->cso_context,
-                          cso_get_aux_vertex_buffer_slot(st->cso_context),
-                          1, &vb);
+   cso_set_vertex_buffers(st->cso_context, 0, 1, &vb);
 
    if (num_instances > 1) {
       cso_draw_arrays_instanced(st->cso_context, PIPE_PRIM_TRIANGLE_FAN, 0, 4,