st/mesa: add support for indirect drawing
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 5 Apr 2013 12:29:37 +0000 (14:29 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Jul 2014 22:47:10 +0000 (00:47 +0200)
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_extensions.c

index 02624617ba882ea4d94713cdbb9fa5ca5b8a2679..3b4d28d47cf8f870a6097863d163dc9fa38666eb 100644 (file)
@@ -225,6 +225,9 @@ st_bufferobj_data(struct gl_context *ctx,
    case GL_UNIFORM_BUFFER:
       bind = PIPE_BIND_CONSTANT_BUFFER;
       break;
+   case GL_DRAW_INDIRECT_BUFFER:
+      bind = PIPE_BIND_COMMAND_ARGS_BUFFER;
+      break;
    default:
       bind = 0;
    }
index c8189faade58cb8dad212c52e978e7ad1a01d547..64d6ef52514ade994d15784bbfc70ac330420162 100644 (file)
@@ -244,6 +244,14 @@ st_draw_vbo(struct gl_context *ctx,
       }
    }
 
+   if (indirect) {
+      info.indirect = st_buffer_object(indirect)->buffer;
+
+      /* Primitive restart is not handled by the VBO module in this case. */
+      info.primitive_restart = ctx->Array._PrimitiveRestart;
+      info.restart_index = ctx->Array.RestartIndex;
+   }
+
    /* do actual drawing */
    for (i = 0; i < nr_prims; i++) {
       info.mode = translate_prim(ctx, prims[i].mode);
@@ -256,6 +264,7 @@ st_draw_vbo(struct gl_context *ctx,
          info.min_index = info.start;
          info.max_index = info.start + info.count - 1;
       }
+      info.indirect_offset = prims[i].indirect_offset;
 
       if (ST_DEBUG & DEBUG_DRAW) {
          debug_printf("st/draw: mode %s  start %u  count %u  indexed %d\n",
@@ -265,7 +274,7 @@ st_draw_vbo(struct gl_context *ctx,
                       info.indexed);
       }
 
-      if (info.count_from_stream_output) {
+      if (info.count_from_stream_output || info.indirect) {
          cso_draw_vbo(st->cso_context, &info);
       }
       else if (info.primitive_restart) {
index 3b6681ea65b1623e618aeca350c7612bc463b70c..bfad04fc9b3f5601e522c3e7c8017897429d0a23 100644 (file)
@@ -432,6 +432,7 @@ void st_init_extensions(struct st_context *st)
       { o(ARB_texture_multisample),          PIPE_CAP_TEXTURE_MULTISAMPLE              },
       { o(ARB_texture_query_lod),            PIPE_CAP_TEXTURE_QUERY_LOD                },
       { o(ARB_sample_shading),               PIPE_CAP_SAMPLE_SHADING                   },
+      { o(ARB_draw_indirect),                PIPE_CAP_DRAW_INDIRECT                    }
    };
 
    /* Required: render target and sampler support */