mesa: add support for AlphaToCoverageDitherControlNV
[mesa.git] / src / mesa / main / attrib.c
index ce6c519737fccdfd6dd05a05d2ce62d2b6d8659c..e95bf19846b0c221c72378237530b310b89552a7 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "glheader.h"
-#include "util/imports.h"
+
 #include "accum.h"
 #include "arrayobj.h"
 #include "attrib.h"
@@ -60,6 +60,7 @@
 #include "state.h"
 #include "hash.h"
 #include <stdbool.h>
+#include "util/u_memory.h"
 
 
 /**
@@ -1518,6 +1519,8 @@ _mesa_PopAttrib(void)
 
                _mesa_SampleCoverage(ms->SampleCoverageValue,
                                        ms->SampleCoverageInvert);
+
+               _mesa_AlphaToCoverageDitherControlNV(ms->SampleAlphaToCoverageDitherControl);
             }
             break;
 
@@ -1607,6 +1610,7 @@ copy_array_attrib(struct gl_context *ctx,
    dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex;
    dest->_PrimitiveRestart = src->_PrimitiveRestart;
    dest->RestartIndex = src->RestartIndex;
+   memcpy(dest->_RestartIndex, src->_RestartIndex, sizeof(src->_RestartIndex));
    /* skip NewState */
    /* skip RebindArrays */
 
@@ -1666,21 +1670,24 @@ restore_array_attrib(struct gl_context *ctx,
    _mesa_BindVertexArray(src->VAO->Name);
 
    /* Restore or recreate the buffer objects by the names ... */
-   if (is_vao_name_zero || src->ArrayBufferObj->Name == 0 ||
+   if (is_vao_name_zero || !src->ArrayBufferObj ||
        _mesa_IsBuffer(src->ArrayBufferObj->Name)) {
       /* ... and restore its content */
       copy_array_attrib(ctx, dest, src, false);
 
       _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB,
-                       src->ArrayBufferObj->Name);
+                       src->ArrayBufferObj ?
+                          src->ArrayBufferObj->Name : 0);
    } else {
       copy_array_attrib(ctx, dest, src, true);
    }
 
-   if (is_vao_name_zero || src->VAO->IndexBufferObj->Name == 0 ||
-       _mesa_IsBuffer(src->VAO->IndexBufferObj->Name))
+   if (is_vao_name_zero || !src->VAO->IndexBufferObj ||
+       _mesa_IsBuffer(src->VAO->IndexBufferObj->Name)) {
       _mesa_BindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,
-                       src->VAO->IndexBufferObj->Name);
+                       src->VAO->IndexBufferObj ?
+                          src->VAO->IndexBufferObj->Name : 0);
+   }
 }
 
 /**