summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2012-03-14 14:44:22 -0700
committerEric Anholt <eric@anholt.net>2012-03-19 22:01:53 -0700
commit56118ef9292caa947216d6b0a75c6ae588419556 (patch)
tree6c90f3b763463fde7899f316fa99282359424b5f /src/mesa/main/api_validate.c
parent7ca4f07b5b77ccac0a9b60dc5ac9082906b5947e (diff)
downloadexternal_mesa3d-56118ef9292caa947216d6b0a75c6ae588419556.zip
external_mesa3d-56118ef9292caa947216d6b0a75c6ae588419556.tar.gz
external_mesa3d-56118ef9292caa947216d6b0a75c6ae588419556.tar.bz2
mesa: Validate the drawing primitive against the transform feedback mode.
Fixes piglit GL_EXT_transform_feedback/negative-prims. Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 17da5d0..02495a1 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -29,6 +29,7 @@
#include "imports.h"
#include "mfeatures.h"
#include "mtypes.h"
+#include "enums.h"
#include "vbo/vbo.h"
@@ -215,9 +216,49 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
_mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode);
return GL_FALSE;
}
- else {
- return GL_TRUE;
+
+ /* From the GL_EXT_transform_feedback spec:
+ *
+ * "The error INVALID_OPERATION is generated if Begin, or any command
+ * that performs an explicit Begin, is called when:
+ *
+ * * a geometry shader is not active and <mode> does not match the
+ * allowed begin modes for the current transform feedback state as
+ * given by table X.1.
+ *
+ * * a geometry shader is active and the output primitive type of the
+ * geometry shader does not match the allowed begin modes for the
+ * current transform feedback state as given by table X.1.
+ *
+ */
+ if (ctx->TransformFeedback.CurrentObject->Active &&
+ !ctx->TransformFeedback.CurrentObject->Paused) {
+ GLboolean pass = GL_TRUE;
+
+ switch (mode) {
+ case GL_POINTS:
+ pass = ctx->TransformFeedback.Mode == GL_POINTS;
+ break;
+ case GL_LINES:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ pass = ctx->TransformFeedback.Mode == GL_LINES;
+ break;
+ default:
+ pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
+ break;
+ }
+ if (!pass) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(mode=%s vs transform feedback %s)",
+ name,
+ _mesa_lookup_prim_by_nr(mode),
+ _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode));
+ return GL_FALSE;
+ }
}
+
+ return GL_TRUE;
}