Move vbo draw functions into struct dd_function_table.
For now just wrap the underlying vbo functions.
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
#include "tnl/tnl.h"
#include "swrast/swrast.h"
#include "swrast/s_renderbuffer.h"
+#include "vbo/vbo.h"
#include "driverfuncs.h"
#include "meta.h"
/* ATI_fragment_shader */
driver->NewATIfs = NULL;
+ /* Draw functions */
+ driver->Draw = _vbo_draw;
+ driver->DrawIndirect = _vbo_draw_indirect;
+
/* simple state commands */
driver->AlphaFunc = NULL;
driver->BlendColor = NULL;
struct gl_texture_object;
struct gl_memory_info;
struct util_queue_monitoring;
+struct _mesa_prim;
+struct _mesa_index_buffer;
/* GL_ARB_vertex_buffer_object */
/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
struct gl_shader_program *shader);
/*@}*/
+
+ /**
+ * \name Draw functions.
+ */
+ /*@{*/
+ /**
+ * For indirect array drawing:
+ *
+ * typedef struct {
+ * GLuint count;
+ * GLuint primCount;
+ * GLuint first;
+ * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ * } DrawArraysIndirectCommand;
+ *
+ * For indirect indexed drawing:
+ *
+ * typedef struct {
+ * GLuint count;
+ * GLuint primCount;
+ * GLuint firstIndex;
+ * GLint baseVertex;
+ * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ * } DrawElementsIndirectCommand;
+ */
+
+ /**
+ * Draw a number of primitives.
+ * \param prims array [nr_prims] describing what to draw (prim type,
+ * vertex count, first index, instance count, etc).
+ * \param ib index buffer for indexed drawing, NULL for array drawing
+ * \param index_bounds_valid are min_index and max_index valid?
+ * \param min_index lowest vertex index used
+ * \param max_index highest vertex index used
+ * \param tfb_vertcount if non-null, indicates which transform feedback
+ * object has the vertex count.
+ * \param tfb_stream If called via DrawTransformFeedbackStream, specifies
+ * the vertex stream buffer from which to get the vertex
+ * count.
+ * \param indirect If any prims are indirect, this specifies the buffer
+ * to find the "DrawArrays/ElementsIndirectCommand" data.
+ * This may be deprecated in the future
+ */
+ void (*Draw)(struct gl_context *ctx,
+ const struct _mesa_prim *prims, GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid,
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned tfb_stream, struct gl_buffer_object *indirect);
+
+
+ /**
+ * Draw a primitive, getting the vertex count, instance count, start
+ * vertex, etc. from a buffer object.
+ * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
+ * \param indirect_data buffer to get "DrawArrays/ElementsIndirectCommand"
+ * data
+ * \param indirect_offset offset of first primitive in indrect_data buffer
+ * \param draw_count number of primitives to draw
+ * \param stride stride, in bytes, between
+ * "DrawArrays/ElementsIndirectCommand" objects
+ * \param indirect_draw_count_buffer if non-NULL specifies a buffer to get
+ * the real draw_count value. Used for
+ * GL_ARB_indirect_parameters.
+ * \param indirect_draw_count_offset offset to the draw_count value in
+ * indirect_draw_count_buffer
+ * \param ib index buffer for indexed drawing, NULL otherwise.
+ */
+ void (*DrawIndirect)(struct gl_context *ctx, GLuint mode,
+ struct gl_buffer_object *indirect_data,
+ GLsizeiptr indirect_offset, unsigned draw_count,
+ unsigned stride,
+ struct gl_buffer_object *indirect_draw_count_buffer,
+ GLsizeiptr indirect_draw_count_offset,
+ const struct _mesa_index_buffer *ib);
+ /*@}*/
+
+
/**
* \name State-changing functions.
*
if (screen->get_param(screen, PIPE_CAP_STRING_MARKER))
functions->EmitStringMarker = st_emit_string_marker;
+ /* For now call through these into the vbo_set_draw_func... */
+ functions->Draw = _vbo_draw;
+ functions->DrawIndirect = _vbo_draw_indirect;
+
functions->Enable = st_Enable;
functions->UpdateState = st_invalidate_state;
functions->QueryMemoryInfo = st_query_memory_info;
};
+void
+_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
+ GLuint nr_prims, const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid, GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned tfb_stream, struct gl_buffer_object *indirect);
+
+
+void
+_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
+ struct gl_buffer_object *indirect_data,
+ GLsizeiptr indirect_offset, unsigned draw_count,
+ unsigned stride,
+ struct gl_buffer_object *indirect_draw_count_buffer,
+ GLsizeiptr indirect_draw_count_offset,
+ const struct _mesa_index_buffer *ib);
+
+
void
vbo_split_prims(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
struct vbo_context *vbo = vbo_context(ctx);
vbo->draw_indirect_prims = func;
}
+
+
+void
+_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
+ GLuint nr_prims, const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid, GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned tfb_stream, struct gl_buffer_object *indirect)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ vbo->draw_prims(ctx, prims, nr_prims, ib, index_bounds_valid,
+ min_index, max_index, tfb_vertcount, tfb_stream, indirect);
+}
+
+
+void
+_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
+ struct gl_buffer_object *indirect_data,
+ GLsizeiptr indirect_offset, unsigned draw_count,
+ unsigned stride,
+ struct gl_buffer_object *indirect_draw_count_buffer,
+ GLsizeiptr indirect_draw_count_offset,
+ const struct _mesa_index_buffer *ib)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ vbo->draw_indirect_prims(ctx, mode, indirect_data, indirect_offset,
+ draw_count, stride, indirect_draw_count_buffer,
+ indirect_draw_count_offset, ib);
+}
GLsizei count, GLuint numInstances, GLuint baseInstance,
GLuint drawID)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_prim prim;
if (skip_validated_draw(ctx))
prim.start = start;
prim.count = count;
- vbo->draw_prims(ctx, &prim, 1, NULL,
- GL_TRUE, start, start + count - 1, NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, &prim, 1, NULL,
+ GL_TRUE, start, start + count - 1, NULL, 0, NULL);
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
_mesa_flush(ctx);
GLint basevertex, GLuint numInstances,
GLuint baseInstance)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
struct _mesa_prim prim;
* for the latter case elsewhere.
*/
- vbo->draw_prims(ctx, &prim, 1, &ib,
- index_bounds_valid, start, end, NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, &prim, 1, &ib,
+ index_bounds_valid, start, end, NULL, 0, NULL);
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
_mesa_flush(ctx);
const GLvoid * const *indices,
GLsizei primcount, const GLint *basevertex)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
struct _mesa_prim *prim;
unsigned int index_type_size = sizeof_ib_type(type);
prim[i].basevertex = 0;
}
- vbo->draw_prims(ctx, prim, primcount, &ib,
- false, 0, ~0, NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, prim, primcount, &ib,
+ false, 0, ~0, NULL, 0, NULL);
}
else {
/* render one prim at a time */
else
prim[0].basevertex = 0;
- vbo->draw_prims(ctx, prim, 1, &ib, false, 0, ~0, NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, prim, 1, &ib, false, 0, ~0, NULL, 0, NULL);
}
}
struct gl_transform_feedback_object *obj,
GLuint stream, GLuint numInstances)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_prim prim;
if (_mesa_is_no_error_enabled(ctx)) {
* (like in DrawArrays), but we have no way to know how many vertices
* will be rendered. */
- vbo->draw_prims(ctx, &prim, 1, NULL, GL_FALSE, 0, ~0, obj, stream, NULL);
+ ctx->Driver.Draw(ctx, &prim, 1, NULL, GL_FALSE, 0, ~0, obj, stream, NULL);
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
_mesa_flush(ctx);
vbo_validated_drawarraysindirect(struct gl_context *ctx,
GLenum mode, const GLvoid *indirect)
{
- struct vbo_context *vbo = vbo_context(ctx);
-
vbo_bind_arrays(ctx);
- vbo->draw_indirect_prims(ctx, mode,
+ ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, (GLsizeiptr) indirect,
1 /* draw_count */ , 16 /* stride */ ,
NULL, 0, NULL);
const GLvoid *indirect,
GLsizei primcount, GLsizei stride)
{
- struct vbo_context *vbo = vbo_context(ctx);
GLsizeiptr offset = (GLsizeiptr) indirect;
if (primcount == 0)
vbo_bind_arrays(ctx);
- vbo->draw_indirect_prims(ctx, mode, ctx->DrawIndirectBuffer, offset,
+ ctx->Driver.DrawIndirect(ctx, mode, ctx->DrawIndirectBuffer, offset,
primcount, stride, NULL, 0, NULL);
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
GLenum mode, GLenum type,
const GLvoid *indirect)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
vbo_bind_arrays(ctx);
ib.obj = ctx->Array.VAO->IndexBufferObj;
ib.ptr = NULL;
- vbo->draw_indirect_prims(ctx, mode,
+ ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, (GLsizeiptr) indirect,
1 /* draw_count */ , 20 /* stride */ ,
NULL, 0, &ib);
const GLvoid *indirect,
GLsizei primcount, GLsizei stride)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
GLsizeiptr offset = (GLsizeiptr) indirect;
ib.obj = ctx->Array.VAO->IndexBufferObj;
ib.ptr = NULL;
- vbo->draw_indirect_prims(ctx, mode,
+ ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, offset,
primcount, stride, NULL, 0, &ib);
GLsizei maxdrawcount,
GLsizei stride)
{
- struct vbo_context *vbo = vbo_context(ctx);
GLsizeiptr offset = indirect;
if (maxdrawcount == 0)
vbo_bind_arrays(ctx);
- vbo->draw_indirect_prims(ctx, mode,
+ ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, offset,
maxdrawcount, stride,
ctx->ParameterBuffer, drawcount_offset, NULL);
GLsizei maxdrawcount,
GLsizei stride)
{
- struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
GLsizeiptr offset = (GLsizeiptr) indirect;
ib.obj = ctx->Array.VAO->IndexBufferObj;
ib.ptr = NULL;
- vbo->draw_indirect_prims(ctx, mode,
+ ctx->Driver.DrawIndirect(ctx, mode,
ctx->DrawIndirectBuffer, offset,
maxdrawcount, stride,
ctx->ParameterBuffer, drawcount_offset, &ib);
printf("%s %d %d\n", __func__, exec->vtx.prim_count,
exec->vtx.vert_count);
- vbo_context(ctx)->draw_prims(ctx,
- exec->vtx.prim,
- exec->vtx.prim_count,
- NULL,
- GL_TRUE,
- 0,
- exec->vtx.vert_count - 1,
- NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, exec->vtx.prim, exec->vtx.prim_count,
+ NULL, GL_TRUE, 0, exec->vtx.vert_count - 1,
+ NULL, 0, NULL);
/* Get new storage -- unless asked not to. */
if (!keepUnmapped)
GLuint sub_end_index;
GLuint restart_index = _mesa_primitive_restart_index(ctx, ib->index_size);
struct _mesa_prim temp_prim;
- struct vbo_context *vbo = vbo_context(ctx);
- vbo_draw_func draw_prims_func = vbo->draw_prims;
GLboolean map_ib = ib->obj->Name && !ib->obj->Mappings[MAP_INTERNAL].Pointer;
void *ptr;
temp_prim.count = MIN2(sub_end_index, end_index) - temp_prim.start;
if ((temp_prim.start == sub_prim->start) &&
(temp_prim.count == sub_prim->count)) {
- draw_prims_func(ctx, &temp_prim, 1, ib,
- GL_TRUE, sub_prim->min_index, sub_prim->max_index,
- NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, &temp_prim, 1, ib, GL_TRUE,
+ sub_prim->min_index, sub_prim->max_index,
+ NULL, 0, NULL);
} else {
- draw_prims_func(ctx, &temp_prim, 1, ib,
- GL_FALSE, -1, -1,
- NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, &temp_prim, 1, ib,
+ GL_FALSE, -1, -1,
+ NULL, 0, NULL);
}
}
if (sub_end_index >= end_index) {
if (node->vertex_count > 0) {
GLuint min_index = _vbo_save_get_min_index(node);
GLuint max_index = _vbo_save_get_max_index(node);
- vbo->draw_prims(ctx,
- node->prims,
- node->prim_count,
- NULL,
- GL_TRUE,
- min_index, max_index,
- NULL, 0, NULL);
+ ctx->Driver.Draw(ctx, node->prims, node->prim_count, NULL, GL_TRUE,
+ min_index, max_index, NULL, 0, NULL);
}
}