summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-07-08 16:18:03 -0700
committerKenneth Graunke <[email protected]>2016-08-08 10:01:30 -0700
commit23b2bcd460c5e91b528913526f16b8e5fd7d4278 (patch)
tree81b0caf113a0b992bf66e81c7d5faacbcc89d08f /src/mesa/main/api_validate.c
parent522b5d45668bf13493901d5e4ed1ec9e75ae1324 (diff)
mesa: Share code between _mesa_validate_DrawArrays[_Instanced].
Mostly, I want to share the GLES 3 transform feedback handling, though most of the rest of the code is identical as well. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c89
1 files changed, 25 insertions, 64 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 038b5a9cd73..2ee2cd8df5a 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -515,30 +515,24 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
"glDrawRangeElements");
}
-
-/**
- * Called from the tnl module to error check the function parameters and
- * verify that we really can draw something.
- * \return GL_TRUE if OK to render, GL_FALSE if error found
- */
-GLboolean
-_mesa_validate_DrawArrays(struct gl_context *ctx, GLenum mode, GLsizei count)
+static bool
+validate_draw_arrays(struct gl_context *ctx, const char *func,
+ GLenum mode, GLsizei count, GLsizei numInstances)
{
struct gl_transform_feedback_object *xfb_obj
= ctx->TransformFeedback.CurrentObject;
FLUSH_CURRENT(ctx, 0);
if (count < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
- return GL_FALSE;
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(count)", func);
+ return false;
}
- if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArrays")) {
- return GL_FALSE;
- }
+ if (!_mesa_valid_prim_mode(ctx, mode, func))
+ return false;
- if (!check_valid_to_render(ctx, "glDrawArrays"))
- return GL_FALSE;
+ if (!check_valid_to_render(ctx, func))
+ return false;
/* From the GLES3 specification, section 2.14.2 (Transform Feedback
* Primitive Capture):
@@ -557,16 +551,27 @@ _mesa_validate_DrawArrays(struct gl_context *ctx, GLenum mode, GLsizei count)
size_t prim_count = vbo_count_tessellated_primitives(mode, count, 1);
if (xfb_obj->GlesRemainingPrims < prim_count) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawArrays(exceeds transform feedback size)");
- return GL_FALSE;
+ "%s(exceeds transform feedback size)", func);
+ return false;
}
xfb_obj->GlesRemainingPrims -= prim_count;
}
if (count == 0)
- return GL_FALSE;
+ return false;
- return GL_TRUE;
+ return true;
+}
+
+/**
+ * Called from the tnl module to error check the function parameters and
+ * verify that we really can draw something.
+ * \return GL_TRUE if OK to render, GL_FALSE if error found
+ */
+GLboolean
+_mesa_validate_DrawArrays(struct gl_context *ctx, GLenum mode, GLsizei count)
+{
+ return validate_draw_arrays(ctx, "glDrawArrays", mode, count, 1);
}
@@ -574,26 +579,12 @@ GLboolean
_mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first,
GLsizei count, GLsizei numInstances)
{
- struct gl_transform_feedback_object *xfb_obj
- = ctx->TransformFeedback.CurrentObject;
- FLUSH_CURRENT(ctx, 0);
-
- if (count < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glDrawArraysInstanced(count=%d)", count);
- return GL_FALSE;
- }
-
if (first < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glDrawArraysInstanced(start=%d)", first);
return GL_FALSE;
}
- if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArraysInstanced")) {
- return GL_FALSE;
- }
-
if (numInstances <= 0) {
if (numInstances < 0)
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -601,37 +592,7 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
return GL_FALSE;
}
- if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)"))
- return GL_FALSE;
-
- /* From the GLES3 specification, section 2.14.2 (Transform Feedback
- * Primitive Capture):
- *
- * The error INVALID_OPERATION is generated by DrawArrays and
- * DrawArraysInstanced if recording the vertices of a primitive to the
- * buffer objects being used for transform feedback purposes would result
- * in either exceeding the limits of any buffer object’s size, or in
- * exceeding the end position offset + size − 1, as set by
- * BindBufferRange.
- *
- * This is in contrast to the behaviour of desktop GL, where the extra
- * primitives are silently dropped from the transform feedback buffer.
- */
- if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
- size_t prim_count
- = vbo_count_tessellated_primitives(mode, count, numInstances);
- if (xfb_obj->GlesRemainingPrims < prim_count) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawArraysInstanced(exceeds transform feedback size)");
- return GL_FALSE;
- }
- xfb_obj->GlesRemainingPrims -= prim_count;
- }
-
- if (count == 0)
- return GL_FALSE;
-
- return GL_TRUE;
+ return validate_draw_arrays(ctx, "glDrawArraysInstanced", mode, count, 1);
}