meta: Make _mesa_meta_setup_sampler static
[mesa.git] / src / mesa / main / draw_validate.c
index 352263c5c7820645e837365099f9565163137fbe..5a1f6d2a194bbb5ebd24569a278c01c319b9d7a9 100644 (file)
@@ -28,7 +28,7 @@
 #include "arrayobj.h"
 #include "bufferobj.h"
 #include "context.h"
-#include "imports.h"
+
 #include "mtypes.h"
 #include "pipelineobj.h"
 #include "enums.h"
@@ -304,6 +304,25 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
                      "%s(tess ctrl shader is missing)", function);
          return false;
       }
+
+      /* From GL_EXT_color_buffer_float:
+       *
+       *     "Blending applies only if the color buffer has a fixed-point or
+       *     or floating-point format. If the color buffer has an integer
+       *     format, proceed to the next operation.  Furthermore, an
+       *     INVALID_OPERATION error is generated by DrawArrays and the other
+       *     drawing commands defined in section 2.8.3 (10.5 in ES 3.1) if
+       *     blending is enabled (see below) and any draw buffer has 32-bit
+       *     floating-point format components."
+       *
+       * However GL_EXT_float_blend removes this text.
+       */
+      if (!ctx->Extensions.EXT_float_blend &&
+          (ctx->DrawBuffer->_FP32Buffers & ctx->Color.BlendEnabled)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "%s(32-bit float output + blending)", function);
+         return false;
+      }
       break;
 
    case API_OPENGL_CORE:
@@ -754,7 +773,7 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx,
 
    /* Not using a VBO for indices, so avoid NULL pointer derefs later.
     */
-   if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) {
+   if (!ctx->Array.VAO->IndexBufferObj) {
       for (i = 0; i < primcount; i++) {
          if (!indices[i])
             return GL_FALSE;
@@ -1085,7 +1104,8 @@ valid_draw_indirect(struct gl_context *ctx,
     *      structure,  be in buffer objects,  and may not be called when
     *      the default vertex array object is bound."
     */
-   if (ctx->Array.VAO == ctx->Array.DefaultVAO) {
+   if (ctx->API != API_OPENGL_COMPAT &&
+       ctx->Array.VAO == ctx->Array.DefaultVAO) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "(no VAO bound)");
       return GL_FALSE;
    }
@@ -1099,7 +1119,7 @@ valid_draw_indirect(struct gl_context *ctx,
     * buffer bound.
     */
    if (_mesa_is_gles31(ctx) &&
-       ctx->Array.VAO->_Enabled & ~ctx->Array.VAO->VertexAttribBufferMask) {
+       ctx->Array.VAO->Enabled & ~ctx->Array.VAO->VertexAttribBufferMask) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(No VBO bound)", name);
       return GL_FALSE;
    }
@@ -1141,7 +1161,7 @@ valid_draw_indirect(struct gl_context *ctx,
       return GL_FALSE;
    }
 
-   if (!_mesa_is_bufferobj(ctx->DrawIndirectBuffer)) {
+   if (!ctx->DrawIndirectBuffer) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "%s: no buffer bound to DRAW_INDIRECT_BUFFER", name);
       return GL_FALSE;
@@ -1183,7 +1203,7 @@ valid_draw_indirect_elements(struct gl_context *ctx,
     * If no element array buffer is bound, an INVALID_OPERATION error is
     * generated.
     */
-   if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) {
+   if (!ctx->Array.VAO->IndexBufferObj) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "%s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER)", name);
       return GL_FALSE;
@@ -1192,10 +1212,10 @@ valid_draw_indirect_elements(struct gl_context *ctx,
    return valid_draw_indirect(ctx, mode, indirect, size, name);
 }
 
-static inline GLboolean
-valid_draw_indirect_multi(struct gl_context *ctx,
-                          GLsizei primcount, GLsizei stride,
-                          const char *name)
+GLboolean
+_mesa_valid_draw_indirect_multi(struct gl_context *ctx,
+                                GLsizei primcount, GLsizei stride,
+                                const char *name)
 {
 
    /* From the ARB_multi_draw_indirect specification:
@@ -1259,8 +1279,8 @@ _mesa_validate_MultiDrawArraysIndirect(struct gl_context *ctx,
    /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
    assert(stride != 0);
 
-   if (!valid_draw_indirect_multi(ctx, primcount, stride,
-                                  "glMultiDrawArraysIndirect"))
+   if (!_mesa_valid_draw_indirect_multi(ctx, primcount, stride,
+                                        "glMultiDrawArraysIndirect"))
       return GL_FALSE;
 
    /* number of bytes of the indirect buffer which will be read */
@@ -1287,8 +1307,8 @@ _mesa_validate_MultiDrawElementsIndirect(struct gl_context *ctx,
    /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
    assert(stride != 0);
 
-   if (!valid_draw_indirect_multi(ctx, primcount, stride,
-                                  "glMultiDrawElementsIndirect"))
+   if (!_mesa_valid_draw_indirect_multi(ctx, primcount, stride,
+                                        "glMultiDrawElementsIndirect"))
       return GL_FALSE;
 
    /* number of bytes of the indirect buffer which will be read */
@@ -1325,7 +1345,7 @@ valid_draw_indirect_parameters(struct gl_context *ctx,
     *  MultiDrawElementsIndirectCountARB if no buffer is bound to the
     *  PARAMETER_BUFFER_ARB binding point."
     */
-   if (!_mesa_is_bufferobj(ctx->ParameterBuffer)) {
+   if (!ctx->ParameterBuffer) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "%s: no buffer bound to PARAMETER_BUFFER", name);
       return GL_FALSE;
@@ -1366,8 +1386,8 @@ _mesa_validate_MultiDrawArraysIndirectCount(struct gl_context *ctx,
    /* caller has converted stride==0 to drawArraysNumParams * sizeof(GLuint) */
    assert(stride != 0);
 
-   if (!valid_draw_indirect_multi(ctx, maxdrawcount, stride,
-                                  "glMultiDrawArraysIndirectCountARB"))
+   if (!_mesa_valid_draw_indirect_multi(ctx, maxdrawcount, stride,
+                                        "glMultiDrawArraysIndirectCountARB"))
       return GL_FALSE;
 
    /* number of bytes of the indirect buffer which will be read */
@@ -1397,8 +1417,8 @@ _mesa_validate_MultiDrawElementsIndirectCount(struct gl_context *ctx,
    /* caller has converted stride==0 to drawElementsNumParams * sizeof(GLuint) */
    assert(stride != 0);
 
-   if (!valid_draw_indirect_multi(ctx, maxdrawcount, stride,
-                                  "glMultiDrawElementsIndirectCountARB"))
+   if (!_mesa_valid_draw_indirect_multi(ctx, maxdrawcount, stride,
+                                        "glMultiDrawElementsIndirectCountARB"))
       return GL_FALSE;
 
    /* number of bytes of the indirect buffer which will be read */