aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-09-21 08:22:07 -0600
committerBrian Paul <[email protected]>2011-09-21 08:22:07 -0600
commit0e6646db3248057b7750031d825535cd7a0e5aec (patch)
tree25fc910e905a30d3b7c0d04c84e71305a6e76ca9 /src/mesa/main/api_validate.c
parent51002968c97758c30511eefab1bd1358b8380e15 (diff)
mesa: check glBegin()/glDrawArrays()/etc mode with _mesa_valid_prim_mode()
We now raise an GL_INVALID_ENUM in glBegin() if mode is illegal, as was done in Yuanhan Liu's original patch. Take geometry shaders support into account too. Reviewed-by: Yuanhan Liu <[email protected]>
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 699b414f502..1fcf5cd68db 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -199,6 +199,27 @@ check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
/**
+ * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
+ * etc? The set of legal values depends on whether geometry shaders/programs
+ * are supported.
+ */
+GLboolean
+_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode)
+{
+ if (ctx->Extensions.ARB_geometry_shader4 &&
+ mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ return GL_FALSE;
+ }
+ else if (mode > GL_POLYGON) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
+}
+
+
+/**
* Error checking for glDrawElements(). Includes parameter checking
* and VBO bounds checking.
* \return GL_TRUE if OK to render, GL_FALSE if error found
@@ -216,7 +237,7 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
return GL_FALSE;
}
- if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" );
return GL_FALSE;
}
@@ -273,7 +294,7 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
return GL_FALSE;
}
- if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(mode)" );
return GL_FALSE;
}
@@ -332,7 +353,7 @@ _mesa_validate_DrawArrays(struct gl_context *ctx,
return GL_FALSE;
}
- if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return GL_FALSE;
}
@@ -362,7 +383,7 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
return GL_FALSE;
}
- if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glDrawArraysInstanced(mode=0x%x)", mode);
return GL_FALSE;
@@ -408,7 +429,7 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
return GL_FALSE;
}
- if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
+ if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glDrawElementsInstanced(mode = 0x%x)", mode);
return GL_FALSE;