mesa: add GL_NV_viewport_swizzle support
[mesa.git] / src / mesa / main / multisample.c
index 4341a5918e46f96f3eb7a6cf2f3881cf3d4fea56..d494a43ac7d55f54ff4a104877b2f947575e6370 100644 (file)
@@ -94,8 +94,8 @@ _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat * val)
 
       ctx->Driver.GetSamplePosition(ctx, ctx->DrawBuffer, index, val);
 
-      /* winsys FBOs are upside down */
-      if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
+      /* FBOs can be upside down (winsys always are)*/
+      if (ctx->DrawBuffer->FlipY)
          val[1] = 1.0f - val[1];
 
       return;
@@ -226,6 +226,58 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
       return GL_INVALID_OPERATION;
    }
 
+   if (ctx->Extensions.AMD_framebuffer_multisample_advanced &&
+       target == GL_RENDERBUFFER) {
+      if (!_mesa_is_depth_or_stencil_format(internalFormat)) {
+         /* From the AMD_framebuffer_multisample_advanced spec:
+          *
+          *    "An INVALID_OPERATION error is generated if <internalformat>
+          *     is a color format and <storageSamples> is greater than
+          *     the implementation-dependent limit MAX_COLOR_FRAMEBUFFER_-
+          *     STORAGE_SAMPLES_AMD."
+          */
+         if (samples > ctx->Const.MaxColorFramebufferSamples)
+            return GL_INVALID_OPERATION;
+
+         /* From the AMD_framebuffer_multisample_advanced spec:
+          *
+          *    "An INVALID_OPERATION error is generated if <internalformat>
+          *     is a color format and <storageSamples> is greater than
+          *     the implementation-dependent limit MAX_COLOR_FRAMEBUFFER_-
+          *     STORAGE_SAMPLES_AMD."
+          */
+         if (storageSamples > ctx->Const.MaxColorFramebufferStorageSamples)
+            return GL_INVALID_OPERATION;
+
+         /* From the AMD_framebuffer_multisample_advanced spec:
+          *
+          *    "An INVALID_OPERATION error is generated if <storageSamples> is
+          *     greater than <samples>."
+          */
+         if (storageSamples > samples)
+            return GL_INVALID_OPERATION;
+
+         /* Color renderbuffer sample counts are now fully validated
+          * according to AMD_framebuffer_multisample_advanced.
+          */
+         return GL_NO_ERROR;
+      } else {
+         /* From the AMD_framebuffer_multisample_advanced spec:
+          *
+          *    "An INVALID_OPERATION error is generated if <internalformat> is
+          *     a depth or stencil format and <storageSamples> is not equal to
+          *     <samples>."
+          */
+         if (storageSamples != samples)
+            return GL_INVALID_OPERATION;
+      }
+   } else {
+      /* If the extension is unsupported, it's not possible to set
+       * storageSamples differently.
+       */
+      assert(samples == storageSamples);
+   }
+
    /* If ARB_internalformat_query is supported, then treat its highest
     * returned sample count as the absolute maximum for this format; it is
     * allowed to exceed MAX_SAMPLES.