[Mesa-dev] [PATCH v3 2/4] mesa: extract need_xfb_remaining_prims_check
Nicolai Hähnle
nhaehnle at gmail.com
Tue Apr 18 13:35:12 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
The same logic needs to be applied to glMultiDrawArrays.
Cc: mesa-stable at lists.freedesktop.org
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
src/mesa/main/api_validate.c | 48 ++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 8f83432..2e1829b 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -809,39 +809,24 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
if (end < start) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)");
return GL_FALSE;
}
return validate_DrawElements_common(ctx, mode, count, type, indices,
"glDrawRangeElements");
}
+
static bool
-validate_draw_arrays(struct gl_context *ctx, const char *func,
- GLenum mode, GLsizei count, GLsizei numInstances)
+need_xfb_remaining_prims_check(const struct gl_context *ctx)
{
- struct gl_transform_feedback_object *xfb_obj
- = ctx->TransformFeedback.CurrentObject;
- FLUSH_CURRENT(ctx, 0);
-
- if (count < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(count)", func);
- return false;
- }
-
- if (!_mesa_valid_prim_mode(ctx, mode, func))
- return false;
-
- if (!check_valid_to_render(ctx, func))
- return 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.
*
@@ -855,23 +840,46 @@ validate_draw_arrays(struct gl_context *ctx, const char *func,
* "(13) Does this extension change how transform feedback operates
* compared to unextended OpenGL ES 3.0 or 3.1?
*
* RESOLVED: Yes. Because dynamic geometry amplification in a geometry
* shader can make it difficult if not impossible to predict the amount
* of geometry that may be generated in advance of executing the shader,
* the draw-time error for transform feedback buffer overflow conditions
* is removed and replaced with the GL behavior (primitives are not
* written and the corresponding counter is not updated)..."
*/
- if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx) &&
- !_mesa_has_OES_geometry_shader(ctx) &&
- !_mesa_has_OES_tessellation_shader(ctx)) {
+ return _mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx) &&
+ !_mesa_has_OES_geometry_shader(ctx) &&
+ !_mesa_has_OES_tessellation_shader(ctx);
+}
+
+
+static bool
+validate_draw_arrays(struct gl_context *ctx, const char *func,
+ GLenum mode, GLsizei count, GLsizei numInstances)
+{
+ FLUSH_CURRENT(ctx, 0);
+
+ if (count < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(count)", func);
+ return false;
+ }
+
+ if (!_mesa_valid_prim_mode(ctx, mode, func))
+ return false;
+
+ if (!check_valid_to_render(ctx, func))
+ return false;
+
+ if (need_xfb_remaining_prims_check(ctx)) {
+ struct gl_transform_feedback_object *xfb_obj
+ = ctx->TransformFeedback.CurrentObject;
size_t prim_count = vbo_count_tessellated_primitives(mode, count, numInstances);
if (xfb_obj->GlesRemainingPrims < prim_count) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(exceeds transform feedback size)", func);
return false;
}
xfb_obj->GlesRemainingPrims -= prim_count;
}
if (count == 0)
--
2.9.3
More information about the mesa-dev
mailing list