replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / main / draw_validate.c
index c0a234a2bc286c1cc07ce93ad26dc14c7424982c..4b624af1e2f18a629781cfab5c9f20eed1130ccc 100644 (file)
@@ -28,7 +28,7 @@
 #include "arrayobj.h"
 #include "bufferobj.h"
 #include "context.h"
-#include "imports.h"
+#include "util/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;
@@ -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;