<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 28, 2018 at 3:22 PM, Rhys Perry <span dir="ltr"><<a href="mailto:pendingchaos02@gmail.com" target="_blank">pendingchaos02@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Although the specs are written against compatibility GL 4.3 and allows core<br>
profile and GLES2+, it is exposed for GL 1.0+ and GLES1 and GLES2+.<br>
---<br>
</span> src/mapi/glapi/gen/gl_API.xml           |  47 ++++++++++++<br>
<span class=""> src/mapi/glapi/gen/gl_genexec.<wbr>py        |   1 +<br>
 src/mesa/Makefile.sources               |   2 +<br>
</span> src/mesa/main/attrib.c                  |  60 ++++++++++++---<br>
 src/mesa/main/<wbr>conservativeraster.c      | 128 ++++++++++++++++++++++++++++++<wbr>++<br>
 src/mesa/main/<wbr>conservativeraster.h      |  48 ++++++++++++<br>
 src/mesa/main/context.c                 |  10 +++<br>
 src/mesa/main/dlist.c                   |  86 +++++++++++++++++++++<br>
<span class=""> src/mesa/main/enable.c                  |  14 ++++<br>
 src/mesa/main/extensions_<wbr>table.h        |   4 +<br>
 src/mesa/main/get.c                     |   3 +<br>
</span> src/mesa/main/get_hash_params.<wbr>py        |  13 ++++<br>
<span class=""> src/mesa/main/mtypes.h                  |  28 ++++++-<br>
 src/mesa/main/tests/dispatch_<wbr>sanity.cpp |  27 +++++++<br>
</span> src/mesa/main/viewport.c                |  57 ++++++++++++++<br>
<span class=""> src/mesa/main/viewport.h                |   6 ++<br>
 src/mesa/meson.build                    |   2 +<br>
</span> 17 files changed, 525 insertions(+), 11 deletions(-)<br>
<div><div class="h5"> create mode 100644 src/mesa/main/<wbr>conservativeraster.c<br>
 create mode 100644 src/mesa/main/<wbr>conservativeraster.h<br>
<br>
diff --git a/src/mapi/glapi/gen/gl_API.<wbr>xml b/src/mapi/glapi/gen/gl_API.<wbr>xml<br>
index 38c1921047..db312370b1 100644<br>
--- a/src/mapi/glapi/gen/gl_API.<wbr>xml<br>
+++ b/src/mapi/glapi/gen/gl_API.<wbr>xml<br>
@@ -12871,6 +12871,53 @@<br>
   <enum name="CONSERVATIVE_<wbr>RASTERIZATION_INTEL" value="0x83FE"/><br>
 </category><br>
<br>
+<category name="GL_NV_conservative_<wbr>raster" number="465"><br>
+    <enum name="CONSERVATIVE_<wbr>RASTERIZATION_NV"       value="0x9346"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="SUBPIXEL_PRECISION_BIAS_<wbr>X_BITS_NV"   value="0x9347"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="SUBPIXEL_PRECISION_BIAS_<wbr>Y_BITS_NV"   value="0x9348"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="MAX_SUBPIXEL_PRECISION_<wbr>BIAS_BITS_NV" value="0x9349"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <function name="SubpixelPrecisionBiasNV" es1="1.0" es2="2.0" no_error="true"><br>
+        <param name="xbits" type="GLuint"/><br>
+        <param name="ybits" type="GLuint"/><br>
+    </function><br>
+</category><br>
+<br>
+<category name="GL_NV_conservative_<wbr>raster_dilate" number="480"><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>DILATE_NV"             value="0x9379"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>DILATE_RANGE_NV"       value="0x937A"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>DILATE_GRANULARITY_NV" value="0x937B"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <function name="<wbr>ConservativeRasterParameterfNV<wbr>" es1="1.0" es2="2.0" no_error="true"><br>
+        <param name="pname" type="GLenum"/><br>
+        <param name="param" type="GLfloat"/><br>
+    </function><br>
+</category><br>
+<br>
+<category name="GL_NV_conservative_pre_<wbr>snap_triangles" number="487"><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>MODE_NV"       value="0x954D"><br>
+        <size name="Get" mode="get"/><br>
+    </enum><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>MODE_POST_SNAP_NV"   value="0x954E"/><br>
+    <enum name="CONSERVATIVE_RASTER_<wbr>MODE_PRE_SNAP_TRIANGLES_NV"   value="0x954F"/><br>
+    <function name="<wbr>ConservativeRasterParameteriNV<wbr>" es1="1.0" es2="2.0" no_error="true"><br>
+        <param name="pname" type="GLenum"/><br>
+        <param name="param" type="GLint"/><br>
+    </function><br>
+</category><br>
+<br>
 <xi:include href="INTEL_performance_query.<wbr>xml" xmlns:xi="<a href="http://www.w3.org/2001/XInclude" rel="noreferrer" target="_blank">http://www.w3.org/<wbr>2001/XInclude</a>"/><br>
<br>
 <category name="GL_EXT_polygon_offset_<wbr>clamp" number="460"><br>
diff --git a/src/mapi/glapi/gen/gl_<wbr>genexec.py b/src/mapi/glapi/gen/gl_<wbr>genexec.py<br>
index aaff9f230b..be8013b62b 100644<br>
--- a/src/mapi/glapi/gen/gl_<wbr>genexec.py<br>
+++ b/src/mapi/glapi/gen/gl_<wbr>genexec.py<br>
@@ -62,6 +62,7 @@ header = """/**<br>
 #include "main/colortab.h"<br>
 #include "main/compute.h"<br>
 #include "main/condrender.h"<br>
+#include "main/conservativeraster.h"<br>
 #include "main/context.h"<br>
 #include "main/convolve.h"<br>
 #include "main/copyimage.h"<br>
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources<br>
index 0446078136..43ec55f580 100644<br>
--- a/src/mesa/Makefile.sources<br>
+++ b/src/mesa/Makefile.sources<br>
@@ -49,6 +49,8 @@ MAIN_FILES = \<br>
        main/condrender.c \<br>
        main/condrender.h \<br>
        main/config.h \<br>
+       main/conservativeraster.c \<br>
+       main/conservativeraster.h \<br>
        main/context.c \<br>
        main/context.h \<br>
        main/convolve.c \<br>
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c<br>
</div></div>index 9d3aa728a1..e785aa5549 100644<br>
<div><div class="h5">--- a/src/mesa/main/attrib.c<br>
+++ b/src/mesa/main/attrib.c<br>
@@ -138,6 +138,9 @@ struct gl_enable_attrib<br>
<br>
    /* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */<br>
    GLboolean sRGBEnabled;<br>
+<br>
+   /* GL_NV_conservative_raster */<br>
+   GLboolean ConservativeRasterization;<br>
 };<br>
<br>
<br>
@@ -178,6 +181,13 @@ struct texture_state<br>
 };<br>
<br>
<br>
+struct viewport_state<br>
+{<br>
+   struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS];<br>
+   GLuint SubpixelPrecisionBias[2];<br>
+};<br>
+<br>
+<br>
 /** An unused GL_*_BIT value */<br>
 #define DUMMY_BIT 0x10000000<br>
<br>
@@ -394,6 +404,9 @@ _mesa_PushAttrib(GLbitfield mask)<br>
<br>
       /* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */<br>
       attr->sRGBEnabled = ctx->Color.sRGBEnabled;<br>
+<br>
+      /* GL_NV_conservative_raster */<br>
+      attr-><wbr>ConservativeRasterization = ctx-><wbr>ConservativeRasterization;<br>
    }<br>
<br>
    if (mask & GL_EVAL_BIT) {<br>
@@ -545,11 +558,23 @@ _mesa_PushAttrib(GLbitfield mask)<br>
    }<br>
<br>
    if (mask & GL_VIEWPORT_BIT) {<br>
-      if (!push_attrib(ctx, &head, GL_VIEWPORT_BIT,<br>
-                       sizeof(struct gl_viewport_attrib)<br>
-                       * ctx->Const.MaxViewports,<br>
-                       (void*)&ctx->ViewportArray))<br>
+      struct viewport_state *viewstate = CALLOC_STRUCT(viewport_state);<br>
+      if (!viewstate) {<br>
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_VIEWPORT_BIT)<wbr>");<br>
+         goto end;<br>
+      }<br>
+<br>
+      if (!save_attrib_data(&head, GL_VIEWPORT_BIT, viewstate)) {<br>
+         free(viewstate);<br>
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_VIEWPORT_BIT)<wbr>");<br>
          goto end;<br>
+      }<br>
+<br>
+      memcpy(&viewstate-><wbr>ViewportArray, &ctx->ViewportArray,<br>
+             sizeof(struct gl_viewport_attrib)*ctx-><wbr>Const.MaxViewports);<br>
+<br>
</div></div>+      viewstate-><wbr>SubpixelPrecisionBias[0] = ctx->SubpixelPrecisionBias[0];<br>
+      viewstate-><wbr>SubpixelPrecisionBias[1] = ctx->SubpixelPrecisionBias[1];<br>
<div><div class="h5">    }<br>
<br>
    /* GL_ARB_multisample */<br>
@@ -714,6 +739,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)<br>
    TEST_AND_UPDATE(ctx->Color.<wbr>sRGBEnabled, enable->sRGBEnabled,<br>
                    GL_FRAMEBUFFER_SRGB);<br>
<br>
+   /* GL_NV_conservative_raster */<br>
+   if (ctx->Extensions.NV_<wbr>conservative_raster) {<br>
+      TEST_AND_UPDATE(ctx-><wbr>ConservativeRasterization,<br>
+                      enable-><wbr>ConservativeRasterization,<br>
+                      GL_CONSERVATIVE_RASTERIZATION_<wbr>NV);<br>
+   }<br>
+<br>
    /* texture unit enables */<br>
    for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {<br>
       const GLbitfield enabled = enable->Texture[i];<br>
@@ -1127,7 +1159,8 @@ _mesa_PopAttrib(void)<br>
                                       ctx->DriverFlags.<wbr>NewSampleAlphaToXEnable |<br>
                                       ctx->DriverFlags.NewSampleMask |<br>
                                       ctx->DriverFlags.<wbr>NewScissorTest |<br>
-                                      ctx->DriverFlags.NewStencil;<br>
+                                      ctx->DriverFlags.NewStencil |<br>
+                                      ctx->DriverFlags.<wbr>NewNvConservativeRasterization<wbr>;<br>
             }<br>
             break;<br>
          case GL_EVAL_BIT:<br>
@@ -1419,13 +1452,20 @@ _mesa_PopAttrib(void)<br>
          case GL_VIEWPORT_BIT:<br>
             {<br>
                unsigned i;<br>
-               const struct gl_viewport_attrib *vp;<br>
-               vp = (const struct gl_viewport_attrib *) attr->data;<br>
+               const struct viewport_state *viewstate;<br>
+               viewstate = (const struct viewport_state *) attr->data;<br>
<br>
                for (i = 0; i < ctx->Const.MaxViewports; i++) {<br>
-                  _mesa_set_viewport(ctx, i, vp[i].X, vp[i].Y, vp[i].Width,<br>
-                                     vp[i].Height);<br>
-                  _mesa_set_depth_range(ctx, i, vp[i].Near, vp[i].Far);<br>
</div></div>+                  const struct gl_viewport_attrib *vp = &viewstate->ViewportArray[i];<br>
<span class="">+                  _mesa_set_viewport(ctx, i, vp->X, vp->Y, vp->Width,<br>
+                                     vp->Height);<br>
+                  _mesa_set_depth_range(ctx, i, vp->Near, vp->Far);<br>
+               }<br>
+<br>
+               if (ctx->Extensions.NV_<wbr>conservative_raster) {<br>
+                  GLuint biasx = viewstate-><wbr>SubpixelPrecisionBias[0];<br>
+                  GLuint biasy = viewstate-><wbr>SubpixelPrecisionBias[1];<br>
+                  _mesa_SubpixelPrecisionBiasNV(<wbr>biasx, biasy);<br>
                }<br>
             }<br>
             break;<br>
diff --git a/src/mesa/main/<wbr>conservativeraster.c b/src/mesa/main/<wbr>conservativeraster.c<br>
new file mode 100644<br>
</span>index 0000000000..8a7241d2a8<br>
--- /dev/null<br>
+++ b/src/mesa/main/<wbr>conservativeraster.c<br>
@@ -0,0 +1,128 @@<br>
<div><div class="h5">+/*<br>
+ * Mesa 3-D graphics library<br>
+ *<br>
+ * Copyright (C) 2018 Rhys Perry<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included<br>
+ * in all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
+ * OTHER DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+<br>
+/**<br>
+ * \file conservativeraster.c<br>
+ * glConservativeRasterParameteri<wbr>NV and glConservativeRasterParameterf<wbr>NV functions<br>
+ */<br>
+<br>
+#include "conservativeraster.h"<br>
+#include "context.h"<br>
+#include "enums.h"<br>
+<br>
+static void<br>
+conservative_raster_<wbr>parameter(GLenum pname, GLdouble param,<br>
</div></div>+                              bool no_error, const char *func)<br></blockquote><div><br></div><div>The no_error parameter is useful only if the function has ALWAYS_INLINE. Same for other functions.<br><br></div><div>Marek<br></div></div><br></div></div>