diff options
author | Brian Paul <[email protected]> | 2013-05-01 19:15:32 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-05-02 09:03:14 -0600 |
commit | bb459f6295736d55ab5855d7b19e5e49aaf9af41 (patch) | |
tree | 6938a45cfe91d7c6689aa6697a63f255bc2adf93 /src/mesa | |
parent | 8be093e2f6301ff9c2728b8a24c83b401e80f070 (diff) |
mesa: refactor _mesa_valid_prim_mode()
...in terms of new _mesa_is_valid_prim_mode(). We need a mode validater
function that doesn't depend on current state for the display list code.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/api_validate.c | 33 | ||||
-rw-r--r-- | src/mesa/main/api_validate.h | 5 |
2 files changed, 24 insertions, 14 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 19f5ab5592c..30a1953505a 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -201,12 +201,11 @@ 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. + * Note: This may be called during display list compilation. */ -GLboolean -_mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) +bool +_mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode) { - bool valid_enum; - switch (mode) { case GL_POINTS: case GL_LINES: @@ -215,24 +214,32 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) case GL_TRIANGLES: case GL_TRIANGLE_STRIP: case GL_TRIANGLE_FAN: - valid_enum = true; - break; + return true; case GL_QUADS: case GL_QUAD_STRIP: case GL_POLYGON: - valid_enum = (ctx->API == API_OPENGL_COMPAT); - break; + return (ctx->API == API_OPENGL_COMPAT); case GL_LINES_ADJACENCY: case GL_LINE_STRIP_ADJACENCY: case GL_TRIANGLES_ADJACENCY: case GL_TRIANGLE_STRIP_ADJACENCY: - valid_enum = _mesa_is_desktop_gl(ctx) - && ctx->Extensions.ARB_geometry_shader4; - break; + return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4; default: - valid_enum = false; - break; + return false; } +} + + +/** + * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), + * etc? Also, do additional checking related to transformation feedback. + * Note: this function cannot be called during glNewList(GL_COMPILE) because + * this code depends on current transform feedback state. + */ +GLboolean +_mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) +{ + bool valid_enum = _mesa_is_valid_prim_mode(ctx, mode); if (!valid_enum) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); diff --git a/src/mesa/main/api_validate.h b/src/mesa/main/api_validate.h index b5164e8ef13..a5004b8a389 100644 --- a/src/mesa/main/api_validate.h +++ b/src/mesa/main/api_validate.h @@ -28,7 +28,7 @@ #ifndef API_VALIDATE_H #define API_VALIDATE_H - +#include <stdbool.h> #include "glheader.h" struct gl_buffer_object; @@ -42,6 +42,9 @@ _mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, struct gl_buffer_object *elementBuf); +extern bool +_mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode); + extern GLboolean _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name); |