diff options
author | Paul Berry <[email protected]> | 2012-12-13 09:30:09 -0800 |
---|---|---|
committer | Paul Berry <[email protected]> | 2012-12-18 08:31:38 -0800 |
commit | b87e65c3b61caeaa4f97a34d62e148e59a0dd5b8 (patch) | |
tree | d3cdac4f4cb681b525c9bae6e22865fc27b144b4 /src/mesa/main/transformfeedback.c | |
parent | febc237141ab06a478d05752dedc858c2b4b8599 (diff) |
mesa/gles3: Generate error on draw call if transform feedback would overflow.
In desktop GL, if a draw call would cause transform feedback buffers
to overflow, the draw call should succeed, and the extra primitives
should simply not be recorded in the transform feedback buffers.
In GLES3, however, if a draw call would cause transform feedback
buffers to overflow, the draw call is supposed to produce an
INVALID_OPERATION error and no drawing should occur.
This patch implements the GLES3-required behaviour.
Fixes GLES3 conformance test "transform_feedback_overflow.test".
Reviewed-by: Ian Romanick <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa/main/transformfeedback.c')
-rw-r--r-- | src/mesa/main/transformfeedback.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index d9c6e514e8f..b2818caa591 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -285,6 +285,7 @@ _mesa_BeginTransformFeedback(GLenum mode) struct gl_transform_feedback_object *obj; struct gl_transform_feedback_info *info; GLuint i; + unsigned vertices_per_prim; GET_CURRENT_CONTEXT(ctx); obj = ctx->TransformFeedback.CurrentObject; @@ -305,9 +306,13 @@ _mesa_BeginTransformFeedback(GLenum mode) switch (mode) { case GL_POINTS: + vertices_per_prim = 1; + break; case GL_LINES: + vertices_per_prim = 2; + break; case GL_TRIANGLES: - /* legal */ + vertices_per_prim = 3; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glBeginTransformFeedback(mode)"); @@ -333,6 +338,18 @@ _mesa_BeginTransformFeedback(GLenum mode) obj->Active = GL_TRUE; ctx->TransformFeedback.Mode = mode; + if (_mesa_is_gles3(ctx)) { + /* In GLES3, we are required to track the usage of the transform + * feedback buffer and report INVALID_OPERATION if a draw call tries to + * exceed it. So compute the maximum number of vertices that we can + * write without overflowing any of the buffers currently being used for + * feedback. + */ + unsigned max_vertices + = _mesa_compute_max_transform_feedback_vertices(obj, info); + obj->GlesRemainingPrims = max_vertices / vertices_per_prim; + } + assert(ctx->Driver.BeginTransformFeedback); ctx->Driver.BeginTransformFeedback(ctx, mode, obj); } |