[Mesa-dev] [PATCH 1/2] mesa: Fold error generation into _mesa_valid_prim_mode().
Brian Paul
brianp at vmware.com
Thu Mar 15 07:35:25 PDT 2012
On 03/14/2012 04:25 PM, Eric Anholt wrote:
> We want to start emitting an INVALID_OPERATION from here for transform
> feedback. Note that this forced dlist.c to almost not use this
> function, since it wants different behavior during dlist compile.
> Just pull the non-TF, non-GS test out for compile, because:
>
> 1) TF doesn't matter in that case because there's no drawing.
> 2) I don't think we're going to see GSes and display lists in the same
> context, if we don't do GL_ARB_compatibility.
> ---
> src/mesa/main/api_validate.c | 24 +++++++++---------------
> src/mesa/main/api_validate.h | 2 +-
> src/mesa/main/dlist.c | 10 ++++++++--
> src/mesa/vbo/vbo_exec_api.c | 3 +--
> 4 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 4e94f47..17da5d0 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -204,13 +204,15 @@ check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
> * are supported.
> */
> GLboolean
> -_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode)
> +_mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
> {
> if (ctx->Extensions.ARB_geometry_shader4&&
> mode> GL_TRIANGLE_STRIP_ADJACENCY_ARB) {
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode);
> return GL_FALSE;
> }
> else if (mode> GL_POLYGON) {
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode);
> return GL_FALSE;
> }
> else {
Actually, I think the above code is wrong. If ARB_gs is true and
mode=GL_TRIANGLES_ADJACENCY_ARB then the first if test will be false
and the second will be true and we'll incorrectly generate an error.
What we really want is:
GLenum maxPrim = ctx->Extensions.ARB_geometry_shader4 ?
GL_TRIANGLE_STRIP_ADJACENCY_ARB : GL_POLYGON;
if (prim > maxPrim) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode);
return GL_FALSE;
}
BTW, I think that I'm the original author of that mistake. :(
-Brian
More information about the mesa-dev
mailing list