mesa: Add support for GL_NV_fill_rectangle
authorLyude <lyude@redhat.com>
Tue, 7 Mar 2017 02:47:00 +0000 (21:47 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 1 Apr 2017 01:41:20 +0000 (21:41 -0400)
Since we don't have the bits required to support this in OpenGLES yet,
this only enables support for Desktop OpenGL

Signed-off-by: Lyude <lyude@redhat.com>
Changes since v1:
- Simply _mesa_PolygonMode() a little bit
- Fix formatting in OpenGL spec excerpts
- Move polygon mode checking into _mesa_valid_to_render()
Changes since v3:
- Improve error message for invalid drawings with GL_FILL_RECTANGLE_NV

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/mesa/main/api_validate.c
src/mesa/main/extensions_table.h
src/mesa/main/mtypes.h
src/mesa/main/polygon.c

index 44d164ad3553aee0790d16fed17f02fb9cb3f1e7..af4f7cb4bf3d2035d063cfca78fde2cc5edd9793 100644 (file)
@@ -189,6 +189,19 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
       return GL_FALSE;
    }
 
+   /* 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."
+    */
+   if ((ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV) !=
+       (ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "GL_FILL_RECTANGLE_NV must be used as both front/back "
+                  "polygon mode or neither");
+      return GL_FALSE;
+   }
+
 #ifdef DEBUG
    if (ctx->_Shader->Flags & GLSL_LOG) {
       struct gl_program **prog = ctx->_Shader->CurrentProgram;
index ec717912cb8756ea4477dccda38fa8d1a03b03dc..f2eac2b1b524de96350a43647cdfb445fbee9762 100644 (file)
@@ -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)
index 401c35a31b708053b9eafb66ad79b1f550495ab4..6fb6a514f9fbed0ac7e68e32135e1a206b32a93e 100644 (file)
@@ -4014,6 +4014,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;
index 4caf62adfead612dcf189b20534035871c206ba2..1bb7190bc24aefb423f16630bbc2e8ab6f865a54 100644 (file)
@@ -131,8 +131,17 @@ _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)
+         break;
+      /* fall-through */
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glPolygonMode(mode)");
       return;
    }