[Mesa-dev] [PATCH 1/2] mesa: Fold error generation into _mesa_valid_prim_mode().

Eric Anholt eric at anholt.net
Thu Mar 15 16:17:58 PDT 2012


On Thu, 15 Mar 2012 08:35:25 -0600, Brian Paul <brianp at vmware.com> wrote:
> 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. :(

When someone gets around to actually supporting geometry shaders, the
code will end up changing anyway due to the interactions with transform
feedback.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120315/b79017ef/attachment.pgp>


More information about the mesa-dev mailing list