diff options
author | Nicolai Hähnle <[email protected]> | 2017-04-07 18:20:34 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-04-19 08:10:19 +0200 |
commit | 42d5465b9ba85b4918b9e6fb57994720e3c8a80b (patch) | |
tree | 2e66ed87dc79407f27754fc643d00ca02b11fa9e /src/mesa/main | |
parent | 756e9ebbdd84018382908d3556973a62dbda09ca (diff) |
mesa: move glMultiDrawArrays to vbo and fix error handling
When any count[i] is negative, we must skip all draws.
Moving to vbo makes the subsequent change easier.
v2:
- provide the function in all contexts, including GLES
- adjust validation accordingly to include the xfb check
v3:
- fix mix-up of pre- and post-xfb prim count (Nils Wallménius)
Cc: [email protected]
Reviewed-by: Timothy Arceri <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_validate.c | 54 | ||||
-rw-r--r-- | src/mesa/main/api_validate.h | 4 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 18 |
3 files changed, 58 insertions, 18 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 2e1829bb13a..e23be60b2b4 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -921,6 +921,60 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi } +/** + * Called to error check the function parameters. + * + * Note that glMultiDrawArrays is not part of GLES, so there's limited scope + * for sharing code with the validation of glDrawArrays. + */ +bool +_mesa_validate_MultiDrawArrays(struct gl_context *ctx, GLenum mode, + const GLsizei *count, GLsizei primcount) +{ + int i; + + FLUSH_CURRENT(ctx, 0); + + if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawArrays")) + return false; + + if (!check_valid_to_render(ctx, "glMultiDrawArrays")) + return false; + + if (primcount < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glMultiDrawArrays(primcount=%d)", + primcount); + return false; + } + + for (i = 0; i < primcount; ++i) { + if (count[i] < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glMultiDrawArrays(count[%d]=%d)", + i, count[i]); + return false; + } + } + + if (need_xfb_remaining_prims_check(ctx)) { + struct gl_transform_feedback_object *xfb_obj + = ctx->TransformFeedback.CurrentObject; + size_t xfb_prim_count = 0; + + for (i = 0; i < primcount; ++i) + xfb_prim_count += vbo_count_tessellated_primitives(mode, count[i], 1); + + if (xfb_obj->GlesRemainingPrims < xfb_prim_count) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMultiDrawArrays(exceeds transform feedback size)"); + return false; + } + xfb_obj->GlesRemainingPrims -= xfb_prim_count; + } + + return true; +} + + GLboolean _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, diff --git a/src/mesa/main/api_validate.h b/src/mesa/main/api_validate.h index de520c98dcb..93ec93d7bcb 100644 --- a/src/mesa/main/api_validate.h +++ b/src/mesa/main/api_validate.h @@ -48,6 +48,10 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name); extern GLboolean _mesa_validate_DrawArrays(struct gl_context *ctx, GLenum mode, GLsizei count); +extern bool +_mesa_validate_MultiDrawArrays(struct gl_context *ctx, GLenum mode, + const GLsizei *count, GLsizei primcount); + extern GLboolean _mesa_validate_DrawElements(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 233dc0dc419..205498501a3 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1539,24 +1539,6 @@ _mesa_UnlockArraysEXT( void ) } -/* GL_EXT_multi_draw_arrays */ -void GLAPIENTRY -_mesa_MultiDrawArrays( GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - FLUSH_VERTICES(ctx, 0); - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawArrays(ctx->CurrentClientDispatch, (mode, first[i], count[i])); - } - } -} - - /* GL_IBM_multimode_draw_arrays */ void GLAPIENTRY _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, |