mesa/st: enable carry/borrow lowering pass
[mesa.git] / src / mesa / main / formatquery.c
index f08ab66f040572f2601523288700503dad813c2f..40eca8711cdf209681f7812a3f56e7679b5232f5 100644 (file)
  */
 
 #include "mtypes.h"
+#include "context.h"
 #include "glformats.h"
 #include "macros.h"
-#include "mfeatures.h"
 #include "enums.h"
 #include "fbobject.h"
 #include "formatquery.h"
 
+/* default implementation of QuerySamplesForFormat driverfunc, for
+ * non-multisample-capable drivers. */
+size_t
+_mesa_query_samples_for_format(struct gl_context *ctx, GLenum target,
+                               GLenum internalFormat, int samples[16])
+{
+   (void) target;
+   (void) internalFormat;
+   (void) ctx;
+
+   samples[0] = 1;
+   return 1;
+}
+
+
 void GLAPIENTRY
 _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
                           GLsizei bufSize, GLint *params)
@@ -37,6 +52,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
    GLsizei count = 0;
    GET_CURRENT_CONTEXT(ctx);
 
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
    if (!ctx->Extensions.ARB_internalformat_query) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInternalformativ");
       return;
@@ -56,9 +73,10 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
 
    case GL_TEXTURE_2D_MULTISAMPLE:
    case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-      /* Mesa does not currently support GL_ARB_texture_multisample, so these
-       * enums are not valid on this implementation either.
-       */
+      /* These enums are only valid if ARB_texture_multisample is supported */
+      if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample)
+         break;
+
    default:
       _mesa_error(ctx, GL_INVALID_ENUM,
                   "glGetInternalformativ(target=%s)",
@@ -93,7 +111,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
 
    switch (pname) {
    case GL_SAMPLES:
-      count = ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
+      count = ctx->Driver.QuerySamplesForFormat(ctx, target,
+            internalformat, buffer);
       break;
    case GL_NUM_SAMPLE_COUNTS: {
       /* The driver can return 0, and we should pass that along to the
@@ -112,7 +131,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
        *          returned."
        */
       const size_t num_samples =
-         ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
+         ctx->Driver.QuerySamplesForFormat(ctx, target, internalformat, buffer);
 
       /* QuerySamplesForFormat writes some stuff to buffer, so we have to
        * separately over-write it with the requested value.