mesa: Add new functions and enums required by GL_ARB_sample_shading
authorAnuj Phogat <anuj.phogat@gmail.com>
Fri, 30 Aug 2013 19:52:38 +0000 (12:52 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Fri, 1 Nov 2013 23:01:47 +0000 (16:01 -0700)
New functions added by GL_ARB_sample_shading:
glMinSampleShadingARB()

New enums:
GL_SAMPLE_SHADING_ARB
GL_MIN_SAMPLE_SHADING_VALUE_ARB

V2: Update comments.
    Create new GL4x.xml.
    Remove redundant code in get.c.
    Update the API_XML list in Makefile.am.
    Add extra_gl40_ARB_sample_shading predicate to get.c.

V3:
   Fix make check failure.
   Add checks for desktop GL.
   Use GLfloat in place of GLclampf in glMinSampleShading().
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ken Graunke <kenneth@whitecape.org>
src/mapi/glapi/gen/ARB_sample_shading.xml [new file with mode: 0644]
src/mapi/glapi/gen/GL4x.xml [new file with mode: 0644]
src/mapi/glapi/gen/Makefile.am
src/mapi/glapi/gen/gl_API.xml
src/mesa/main/enable.c
src/mesa/main/get.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h
src/mesa/main/multisample.c
src/mesa/main/multisample.h
src/mesa/main/tests/dispatch_sanity.cpp

diff --git a/src/mapi/glapi/gen/ARB_sample_shading.xml b/src/mapi/glapi/gen/ARB_sample_shading.xml
new file mode 100644 (file)
index 0000000..cc8296a
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+<OpenGLAPI>
+
+<category name="GL_ARB_sample_shading" number="70">
+
+   <enum name="SAMPLE_SHADING_ARB"                          value="0x8C36"/>
+   <enum name="MIN_SAMPLE_SHADING_VALUE_ARB"                value="0x8C37"/>
+
+   <function name="MinSampleShadingARB" alias="MinSampleShading">
+      <param name="value" type="GLfloat"/>
+   </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/src/mapi/glapi/gen/GL4x.xml b/src/mapi/glapi/gen/GL4x.xml
new file mode 100644 (file)
index 0000000..6706278
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+<OpenGLAPI>
+
+<category name="4.0">
+  <enum name="SAMPLE_SHADING"                          value="0x8C36"/>
+  <enum name="MIN_SAMPLE_SHADING_VALUE"                value="0x8C37"/>
+
+  <function name="MinSampleShading" offset="assign">
+    <param name="value" type="GLfloat"/>
+  </function>
+</category>
+
+<category name="4.3">
+
+</category>
+
+</OpenGLAPI>
index 3902452163ccf6dac2a84c566fecda95679d80dd..cbbf659dd01da48e18894d1d8b061c4e16e692d5 100644 (file)
@@ -108,6 +108,7 @@ API_XML = \
        ARB_invalidate_subdata.xml \
        ARB_map_buffer_range.xml \
        ARB_robustness.xml \
+       ARB_sample_shading.xml \
        ARB_sampler_objects.xml \
        ARB_seamless_cube_map.xml \
        ARB_shader_atomic_counters.xml \
@@ -144,7 +145,9 @@ API_XML = \
        NV_texture_barrier.xml \
        NV_vdpau_interop.xml \
        OES_EGL_image.xml \
-       GL3x.xml
+       GL3x.xml \
+       GL4x.xml
+
 
 
 COMMON = $(API_XML) \
index 45d69b40a03ab4bca8a4f12a10fa4ebfe4fc1682..69014c5d2f0949c04b3697bfe5158fb420401cf7 100644 (file)
 <xi:include href="ARB_draw_buffers_blend.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 <xi:include href="AMD_draw_buffers_blend.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
-<!-- 70. GL_ARB_sample_shading -->
+<xi:include href="ARB_sample_shading.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 <xi:include href="ARB_texture_cube_map_array.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 <xi:include href="ARB_texture_gather.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 <!-- 73. GL_ARB_texture_query_lod -->
 
 <xi:include href="NV_vdpau_interop.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="GL4x.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 </OpenGLAPI>
index 5e2fd80d22703461e23fca5c84c1bfaaa45a0d3b..dd6a772f96c6266e9b15b965a15e80d12047b90c 100644 (file)
@@ -802,6 +802,17 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          ctx->Multisample.SampleCoverageInvert = state;
          break;
 
+      /* GL_ARB_sample_shading */
+      case GL_SAMPLE_SHADING:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         CHECK_EXTENSION(ARB_sample_shading, cap);
+         if (ctx->Multisample.SampleShading == state)
+            return;
+         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         ctx->Multisample.SampleShading = state;
+         break;
+
       /* GL_IBM_rasterpos_clip */
       case GL_RASTER_POSITION_UNCLIPPED_IBM:
          if (ctx->API != API_OPENGL_COMPAT)
@@ -1594,6 +1605,13 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(ARB_texture_multisample);
          return ctx->Multisample.SampleMask;
 
+      /* ARB_sample_shading */
+      case GL_SAMPLE_SHADING:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         CHECK_EXTENSION(ARB_sample_shading);
+         return ctx->Multisample.SampleShading;
+
       default:
          goto invalid_enum_error;
    }
index 6e72ff5c298eace815408a2651a72b221112183d..6a0de0c165ca9bc6c1ac71d0bdc6feb664d7354d 100644 (file)
@@ -131,6 +131,7 @@ enum value_extra {
    EXTRA_VERSION_30,
    EXTRA_VERSION_31,
    EXTRA_VERSION_32,
+   EXTRA_VERSION_40,
    EXTRA_API_GL,
    EXTRA_API_GL_CORE,
    EXTRA_API_ES2,
@@ -391,6 +392,7 @@ extra_NV_primitive_restart[] = {
 static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
 static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
 static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
+static const int extra_version_40[] = { EXTRA_VERSION_40, EXTRA_END };
 
 static const int extra_gl30_es3[] = {
     EXTRA_VERSION_30,
@@ -410,6 +412,12 @@ static const int extra_gl32_ARB_geometry_shader4[] = {
     EXTRA_END
 };
 
+static const int extra_gl40_ARB_sample_shading[] = {
+   EXTRA_VERSION_40,
+   EXT(ARB_sample_shading),
+   EXTRA_END
+};
+
 static const int
 extra_ARB_vertex_program_api_es2[] = {
    EXT(ARB_vertex_program),
index 9f79f340683821aba71243104b84579fc90e2450..0851b7b708990e0326bdcf8897712748b2b0aa47 100644 (file)
@@ -83,6 +83,9 @@ descriptor=[
   [ "SAMPLE_BUFFERS_ARB", "BUFFER_INT(Visual.sampleBuffers), extra_new_buffers" ],
   [ "SAMPLES_ARB", "BUFFER_INT(Visual.samples), extra_new_buffers" ],
 
+# GL_ARB_sample_shading
+  [ "MIN_SAMPLE_SHADING_VALUE_ARB", "CONTEXT_FLOAT(Multisample.MinSampleShadingValue), extra_gl40_ARB_sample_shading" ],
+
 # GL_SGIS_generate_mipmap
   [ "GENERATE_MIPMAP_HINT_SGIS", "CONTEXT_ENUM(Hint.GenerateMipmap), NO_EXTRA" ],
 
index 476888b508b84be1e68c677abba925172f3d7f7a..4774c8eb04c3cbd106c6bfebcb99dc01205bb288 100644 (file)
@@ -872,6 +872,8 @@ struct gl_multisample_attrib
    GLboolean SampleCoverage;
    GLfloat SampleCoverageValue;
    GLboolean SampleCoverageInvert;
+   GLboolean SampleShading;
+   GLfloat MinSampleShadingValue;
 
    /* ARB_texture_multisample / GL3.2 additions */
    GLboolean SampleMask;
index bd97c50960ef1b59c7ad9727a3269e1478280211..599cdee74075431071821b2a6ca50f6a6e8d89cf 100644 (file)
@@ -119,6 +119,24 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask)
    ctx->Multisample.SampleMaskValue = mask;
 }
 
+/**
+ * Called via glMinSampleShadingARB
+ */
+void GLAPIENTRY
+_mesa_MinSampleShading(GLclampf value)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!ctx->Extensions.ARB_sample_shading || !_mesa_is_desktop_gl(ctx)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMinSampleShading");
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, 0);
+
+   ctx->Multisample.MinSampleShadingValue = CLAMP(value, 0.0, 1.0);
+   ctx->NewState |= _NEW_MULTISAMPLE;
+}
 
 /**
  * Helper for checking a requested sample count against the limit
index 66848d2696fffbaa4adda7315d7935df3cc4a2da..7441d3ee9416e6a06888fc893cc47726531e5626 100644 (file)
@@ -44,6 +44,8 @@ _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat* val);
 extern void GLAPIENTRY
 _mesa_SampleMaski(GLuint index, GLbitfield mask);
 
+extern void GLAPIENTRY
+_mesa_MinSampleShading(GLclampf value);
 
 extern GLenum
 _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
index 408dbc0ca747138102d1b288629a7d557aa0acf6..58cff9b60fa541485acf1089dfca40a26afd9884 100644 (file)
@@ -542,7 +542,7 @@ const struct function gl_core_functions_possible[] = {
    { "glVertexAttribDivisor", 33, -1 },
 
    /* GL 4.0 */
-// { "glMinSampleShading", 40, -1 },                    // XXX: Add to xml
+   { "glMinSampleShading", 40, -1 },                    // XXX: Add to xml
 // { "glBlendEquationi", 40, -1 },                      // XXX: Add to xml
 // { "glBlendEquationSeparatei", 40, -1 },              // XXX: Add to xml
 // { "glBlendFunci", 40, -1 },                          // XXX: Add to xml
@@ -603,7 +603,7 @@ const struct function gl_core_functions_possible[] = {
    { "glBlendEquationSeparateiARB", 43, -1 },
    { "glBlendFunciARB", 43, -1 },
    { "glBlendFuncSeparateiARB", 43, -1 },
-// { "glMinSampleShadingARB", 43, -1 },                 // XXX: Add to xml
+   { "glMinSampleShadingARB", 43, -1 },                 // XXX: Add to xml
 // { "glNamedStringARB", 43, -1 },                      // XXX: Add to xml
 // { "glDeleteNamedStringARB", 43, -1 },                // XXX: Add to xml
 // { "glCompileShaderIncludeARB", 43, -1 },             // XXX: Add to xml