[Mesa-dev] [PATCH 3/6] mesa: Add support for GL_NV_fill_rectangle

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Mar 23 16:29:49 UTC 2017



On 03/23/2017 04:27 PM, Lyude wrote:
> Since we don't have the bits required to support this in OpenGLES yet,
> this only enables support for OpenGL 4.3.
>
> Signed-off-by: Lyude <lyude at redhat.com>
> ---
>  src/mesa/main/api_validate.c     | 13 +++++++++++++
>  src/mesa/main/extensions_table.h |  1 +
>  src/mesa/main/mtypes.h           |  1 +
>  src/mesa/main/polygon.c          | 15 +++++++++++++--
>  4 files changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 44d164a..bec6407 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -609,6 +609,19 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
>        }
>     }
>
> +   /* From the GL_NV_fill_rectangle spec:
> +    *
> +    * An INVALID_OPERATION error is generated by Begin or any Draw command if
> +    * only one of the front and back polygon mode is FILL_RECTANGLE_NV.
> +    */

I think usually we do:

/* The GL_NV_fill_rectangle spec says:
  *
  * "And INVALID_OPERATION ...
  *  only one ...."
  */

Note the extra space. :)

> +   if ((ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV) !=
> +       (ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV)) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "GL_NV_fill_rectangle can only be used on both the front "
> +                  "and back polygon mode, not one or the other");
> +      return GL_FALSE;
> +   }
> +
>     return GL_TRUE;
>  }
>
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
> index ec71791..f2eac2b 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -320,6 +320,7 @@ EXT(NV_conditional_render                   , NV_conditional_render
>  EXT(NV_depth_clamp                          , ARB_depth_clamp                        , GLL, GLC,  x ,  x , 2001)
>  EXT(NV_draw_buffers                         , dummy_true                             ,  x ,  x ,  x , ES2, 2011)
>  EXT(NV_fbo_color_attachments                , dummy_true                             ,  x ,  x ,  x , ES2, 2010)
> +EXT(NV_fill_rectangle                       , NV_fill_rectangle                      , GLL, GLC,  x ,  x , 2015)
>  EXT(NV_fog_distance                         , NV_fog_distance                        , GLL,  x ,  x ,  x , 2001)
>  EXT(NV_image_formats                        , ARB_shader_image_load_store            ,  x ,  x ,  x ,  31, 2014)
>  EXT(NV_light_max_exponent                   , dummy_true                             , GLL,  x ,  x ,  x , 1999)
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index be78b96..88b8e2b 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -4016,6 +4016,7 @@ struct gl_extensions
>     GLboolean MESA_shader_integer_functions;
>     GLboolean MESA_ycbcr_texture;
>     GLboolean NV_conditional_render;
> +   GLboolean NV_fill_rectangle;
>     GLboolean NV_fog_distance;
>     GLboolean NV_point_sprite;
>     GLboolean NV_primitive_restart;
> diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
> index 60af88f..2b57f36 100644
> --- a/src/mesa/main/polygon.c
> +++ b/src/mesa/main/polygon.c
> @@ -131,8 +131,19 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
>                    _mesa_enum_to_string(face),
>                    _mesa_enum_to_string(mode));
>
> -   if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) {
> -      _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" );
> +   switch (mode) {
> +   case GL_POINT:
> +   case GL_LINE:
> +   case GL_FILL:
> +      break;
> +   case GL_FILL_RECTANGLE_NV:
> +      if (!ctx->Extensions.NV_fill_rectangle) {
> +         _mesa_error(ctx, GL_INVALID_ENUM, "glPolygonMode(mode)");
> +         return;
> +      }
> +      break;
> +   default:
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glPolygonMode(mode)");
>        return;
>     }
>
>


More information about the mesa-dev mailing list