[Mesa-dev] [PATCH 1/2] vbo: Make vbo_sw_primitive_restart optionally count primitives.
Paul Berry
stereotype441 at gmail.com
Fri Oct 11 22:56:26 CEST 2013
This will be necessary in order to get the i965 back-end to produce
the correct value of gl_PrimitiveIDIn when using software primitive
restart.
---
src/mesa/drivers/dri/i965/brw_primitive_restart.c | 2 +-
src/mesa/vbo/vbo.h | 3 ++-
src/mesa/vbo/vbo_exec_array.c | 2 +-
src/mesa/vbo/vbo_primitive_restart.c | 16 +++++++++++++++-
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
index 2ee6055..2572c12 100644
--- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c
+++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
@@ -175,7 +175,7 @@ brw_handle_primitive_restart(struct gl_context *ctx,
/* Not all the primitive draw modes are supported by the cut index,
* so take the software path
*/
- vbo_sw_primitive_restart(ctx, prims, nr_prims, ib);
+ vbo_sw_primitive_restart(ctx, prims, nr_prims, ib, NULL);
}
brw->prim_restart.in_progress = false;
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index c4472e9..ec3b6f5 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -182,7 +182,8 @@ void
vbo_sw_primitive_restart(struct gl_context *ctx,
const struct _mesa_prim *prim,
GLuint nr_prims,
- const struct _mesa_index_buffer *ib);
+ const struct _mesa_index_buffer *ib,
+ GLuint *prim_count);
void GLAPIENTRY
_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 1670409..afe2a15 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -579,7 +579,7 @@ vbo_handle_primitive_restart(struct gl_context *ctx,
ctx->Const.PrimitiveRestartInSoftware &&
ctx->Array._PrimitiveRestart) {
/* Handle primitive restart in software */
- vbo_sw_primitive_restart(ctx, prim, nr_prims, ib);
+ vbo_sw_primitive_restart(ctx, prim, nr_prims, ib, NULL);
} else {
/* Call driver directly for draw_prims */
vbo->draw_prims(ctx, prim, nr_prims, ib,
diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c
index 418f882..13a8c43 100644
--- a/src/mesa/vbo/vbo_primitive_restart.c
+++ b/src/mesa/vbo/vbo_primitive_restart.c
@@ -158,12 +158,17 @@ find_sub_primitives(const void *elements, unsigned element_size,
*
* This function breaks up calls into the driver so primitive restart
* support is not required in the driver.
+ *
+ * If a non-NULL value is passed in prim_count, then prior to each draw call,
+ * that value is updated to contain the number of primitives previously
+ * processed.
*/
void
vbo_sw_primitive_restart(struct gl_context *ctx,
const struct _mesa_prim *prims,
GLuint nr_prims,
- const struct _mesa_index_buffer *ib)
+ const struct _mesa_index_buffer *ib,
+ GLuint *prim_count)
{
GLuint prim_num;
struct sub_primitive *sub_prims;
@@ -197,6 +202,9 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
ctx->Driver.UnmapBuffer(ctx, ib->obj);
}
+ if (prim_count != NULL)
+ *prim_count = 0;
+
/* Loop over the primitives, and use the located sub-primitives to draw
* each primitive with a break to implement each primitive restart.
*/
@@ -220,6 +228,12 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
GL_FALSE, -1, -1,
NULL);
}
+ if (prim_count != NULL) {
+ *prim_count +=
+ vbo_count_tessellated_primitives(temp_prim.mode,
+ temp_prim.count,
+ temp_prim.num_instances);
+ }
}
if (sub_end_index >= end_index) {
break;
--
1.8.4
More information about the mesa-dev
mailing list