mesa: add support for AlphaToCoverageDitherControlNV
authorIndrajit Kumar Das <indrajit-kumar.das@amd.com>
Tue, 21 Apr 2020 10:30:14 +0000 (16:00 +0530)
committerIndrajit Kumar Das <indrajit-kumar.das@amd.com>
Thu, 23 Apr 2020 06:32:45 +0000 (12:02 +0530)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4543>

13 files changed:
src/mapi/glapi/gen/NV_alpha_to_coverage_dither_control.xml [new file with mode: 0644]
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/meson.build
src/mapi/glapi/gen/static_data.py
src/mesa/main/attrib.c
src/mesa/main/extensions_table.h
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
src/mesa/state_tracker/st_atom_blend.c
src/mesa/state_tracker/st_extensions.c

diff --git a/src/mapi/glapi/gen/NV_alpha_to_coverage_dither_control.xml b/src/mapi/glapi/gen/NV_alpha_to_coverage_dither_control.xml
new file mode 100644 (file)
index 0000000..0ddc7b8
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_NV_alpha_to_coverage_dither_control" number="500" no_error="true">
+
+    <enum name="ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV"              value="0x934D" />
+    <enum name="ALPHA_TO_COVERAGE_DITHER_ENABLE_NV"               value="0x934E" />
+    <enum name="ALPHA_TO_COVERAGE_DITHER_DISABLE_NV"              value="0x934F" />
+
+    <enum name="ALPHA_TO_COVERAGE_DITHER_MODE_NV"                  value="0x92BF"/>
+
+    <function name="AlphaToCoverageDitherControlNV">
+        <param name="mode" type="GLenum"/>
+    </function>
+
+</category>
+
+</OpenGLAPI>
index 4188bbf198689cdc199dc210aa1c35f48e59a251..39c80dabbf44ed5eb7fa8fd4db4c68cbcac87a2b 100644 (file)
 
 <xi:include href="INTEL_performance_query.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="NV_alpha_to_coverage_dither_control.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 <category name="GL_EXT_polygon_offset_clamp" number="460">
     <enum name="POLYGON_OFFSET_CLAMP_EXT"             value="0x8E1B">
         <size name="Get" mode="get"/>
index 8f9a08f5294d429e031e641d5b0d0f63c132698c..f679ed3ee9ce001d8ef04e615fba68f5fd7b1709 100644 (file)
@@ -133,6 +133,7 @@ api_xml_files = files(
   'KHR_robustness.xml',
   'KHR_robustness_es.xml',
   'KHR_texture_compression_astc.xml',
+  'NV_alpha_to_coverage_dither_control.xml',
   'NV_copy_image.xml',
   'NV_conditional_render.xml',
   'NV_primitive_restart.xml',
index 99be40aac6e1830d3dcf111d82b9541d167867ac..9b15e329be9049ec1dc2fe5aca88c6f1a7050d01 100644 (file)
@@ -1642,6 +1642,7 @@ offsets = {
     "EGLImageTargetTextureStorageEXT" : 1606,
     "CopyImageSubDataNV": 1607,
     "ViewportSwizzleNV": 1608,
+    "AlphaToCoverageDitherControlNV": 1609,
 }
 
 functions = [
index 35231335813591473444792a4a89929478f022c4..e95bf19846b0c221c72378237530b310b89552a7 100644 (file)
@@ -1519,6 +1519,8 @@ _mesa_PopAttrib(void)
 
                _mesa_SampleCoverage(ms->SampleCoverageValue,
                                        ms->SampleCoverageInvert);
+
+               _mesa_AlphaToCoverageDitherControlNV(ms->SampleAlphaToCoverageDitherControl);
             }
             break;
 
index 66f5d2e9d9d78facbe8d8c984f222cd433ba5e62..18d5f8073bfc9c3888e4b6f3f41b192bbfca202b 100644 (file)
@@ -371,6 +371,7 @@ EXT(MESA_ycbcr_texture                      , MESA_ycbcr_texture
 
 EXT(NVX_gpu_memory_info                     , NVX_gpu_memory_info                    , GLL, GLC,  x ,  x , 2013)
 
+EXT(NV_alpha_to_coverage_dither_control     , NV_alpha_to_coverage_dither_control    , GLL, GLC,  x , ES2, 2017)
 EXT(NV_blend_square                         , dummy_true                             , GLL,  x ,  x ,  x , 1999)
 EXT(NV_compute_shader_derivatives           , NV_compute_shader_derivatives          , GLL, GLC,  x ,  32, 2018)
 EXT(NV_conditional_render                   , NV_conditional_render                  , GLL, GLC,  x , ES2, 2008)
index 31563679593b938d8d1af5561533dfd262c3338d..1e09c48aca0f2055eaee22be4f74fd013f6bfcaa 100644 (file)
@@ -382,6 +382,9 @@ descriptor=[
   [ "MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD", "CONTEXT_INT(Const.MaxDepthStencilFramebufferSamples), extra_AMD_framebuffer_multisample_advanced" ],
   [ "NUM_SUPPORTED_MULTISAMPLE_MODES_AMD", "CONTEXT_INT(Const.NumSupportedMultisampleModes), extra_AMD_framebuffer_multisample_advanced" ],
   [ "SUPPORTED_MULTISAMPLE_MODES_AMD", "LOC_CUSTOM, TYPE_INT_N, 0, extra_AMD_framebuffer_multisample_advanced" ],
+
+# GL_NV_alpha_to_coverage_dither_control
+  [ "ALPHA_TO_COVERAGE_DITHER_MODE_NV", "CONTEXT_ENUM(Multisample.SampleAlphaToCoverageDitherControl ), NO_EXTRA" ],
 ]},
 
 # GLES3 is not a typo.
index 62f1e9be5bc687ccb755725d0d2d72bb5f786b0d..1f1e8e7ada0638a28b03ed2716cee97a5ea629e4 100644 (file)
@@ -689,6 +689,9 @@ struct gl_multisample_attrib
 
    /** The GL spec defines this as an array but >32x MSAA is madness */
    GLbitfield SampleMaskValue;
+
+   /* NV_alpha_to_coverage_dither_control */
+   GLenum SampleAlphaToCoverageDitherControl;
 };
 
 
@@ -4387,6 +4390,7 @@ struct gl_extensions
    GLboolean EXT_shader_framebuffer_fetch_non_coherent;
    GLboolean MESA_shader_integer_functions;
    GLboolean MESA_ycbcr_texture;
+   GLboolean NV_alpha_to_coverage_dither_control;
    GLboolean NV_compute_shader_derivatives;
    GLboolean NV_conditional_render;
    GLboolean NV_copy_image;
index d494a43ac7d55f54ff4a104877b2f947575e6370..66eb0c8b98e65beec152f2e275e6d2690de536d8 100644 (file)
@@ -63,6 +63,7 @@ _mesa_init_multisample(struct gl_context *ctx)
 {
    ctx->Multisample.Enabled = GL_TRUE;
    ctx->Multisample.SampleAlphaToCoverage = GL_FALSE;
+   ctx->Multisample.SampleAlphaToCoverageDitherControl = GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV;
    ctx->Multisample.SampleAlphaToOne = GL_FALSE;
    ctx->Multisample.SampleCoverage = GL_FALSE;
    ctx->Multisample.SampleCoverageValue = 1.0;
@@ -351,3 +352,33 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
    return (GLuint) samples > ctx->Const.MaxSamples
       ? GL_INVALID_VALUE : GL_NO_ERROR;
 }
+
+void GLAPIENTRY
+_mesa_AlphaToCoverageDitherControlNV_no_error(GLenum mode)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+                                                   _NEW_MULTISAMPLE);
+   ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
+   ctx->Multisample.SampleAlphaToCoverageDitherControl = mode;
+}
+
+void GLAPIENTRY
+_mesa_AlphaToCoverageDitherControlNV(GLenum mode)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+                                                   _NEW_MULTISAMPLE);
+   ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
+   switch (mode) {
+      case GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV:
+      case GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV:
+      case GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV:
+         ctx->Multisample.SampleAlphaToCoverageDitherControl = mode;
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glAlphaToCoverageDitherControlNV(invalid parameter)");
+   }
+}
index 49683cacdc9e741f6c0b39794d8fcb8365d46a2a..9cd4724947a46d22bb5b256739856a530190bc2b 100644 (file)
@@ -58,4 +58,10 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
                          GLenum internalFormat, GLsizei samples,
                          GLsizei storageSamples);
 
+extern void GLAPIENTRY
+_mesa_AlphaToCoverageDitherControlNV_no_error(GLenum mode);
+
+extern void GLAPIENTRY
+_mesa_AlphaToCoverageDitherControlNV(GLenum mode);
+
 #endif
index 69dd56598e2402e31b3286b6f03116f4f99be811..0fe3c9c348c0503359d7647394e48a7062cb2d8b 100644 (file)
@@ -911,6 +911,10 @@ const struct function common_desktop_functions_possible[] = {
    { "glDepthRangeArrayv", 43, -1 },
    { "glDepthRangeIndexed", 43, -1 },
 
+/* GL 4.4 */
+   /* GL_NV_alpha_to_coverage_dither_control */
+   { "glAlphaToCoverageDitherControlNV", 44, -1 },
+
 /* GL 4.5 */
    /* aliased versions checked above */
    //{ "glGetGraphicsResetStatus", 45, -1 },
index 10e9b6a38c427e22ab70f7ab0d653ba28da7aca1..35c99b9f089575a2842484b3a0bb5cce0daed09c 100644 (file)
@@ -287,6 +287,9 @@ st_update_blend( struct st_context *st )
        */
       blend->alpha_to_coverage = ctx->Multisample.SampleAlphaToCoverage;
       blend->alpha_to_one = ctx->Multisample.SampleAlphaToOne;
+      blend->alpha_to_coverage_dither =
+         ctx->Multisample.SampleAlphaToCoverageDitherControl !=
+         GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV;
    }
 
    cso_set_blend(st->cso_context, blend);
index 42d8a5b9f517cf31a5670eb62f520c30a29f0799..b0ee3e2210a4187892a4a4cc1865f4538b8eb890 100644 (file)
@@ -799,6 +799,7 @@ void st_init_extensions(struct pipe_screen *screen,
       { o(INTEL_conservative_rasterization), PIPE_CAP_CONSERVATIVE_RASTER_INNER_COVERAGE },
       { o(INTEL_shader_atomic_float_minmax), PIPE_CAP_ATOMIC_FLOAT_MINMAX              },
       { o(MESA_tile_raster_order),           PIPE_CAP_TILE_RASTER_ORDER                },
+      { o(NV_alpha_to_coverage_dither_control), PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL },
       { o(NV_compute_shader_derivatives),    PIPE_CAP_COMPUTE_SHADER_DERIVATIVES       },
       { o(NV_conditional_render),            PIPE_CAP_CONDITIONAL_RENDER               },
       { o(NV_fill_rectangle),                PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE      },