mesa: Add missing include guards
[mesa.git] / src / mesa / main / fbobject.c
index 284990d7d003f29043caffe6ca08a26546b4ea83..c3dded6b928ab106d43992fc4164f63d86b399f4 100644 (file)
@@ -1410,7 +1410,7 @@ allocate_renderbuffer_locked(struct gl_context *ctx, GLuint renderbuffer,
 
 
 static void
-bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
+bind_renderbuffer(GLenum target, GLuint renderbuffer)
 {
    struct gl_renderbuffer *newRb;
    GET_CURRENT_CONTEXT(ctx);
@@ -1430,9 +1430,10 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
          /* ID was reserved, but no real renderbuffer object made yet */
          newRb = NULL;
       }
-      else if (!newRb && !allow_user_names) {
+      else if (!newRb && ctx->API == API_OPENGL_CORE) {
          /* All RB IDs must be Gen'd */
-         _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)");
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glBindRenderbuffer(non-gen name)");
          return;
       }
 
@@ -1455,22 +1456,16 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
 void GLAPIENTRY
 _mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer)
 {
-   GET_CURRENT_CONTEXT(ctx);
-
    /* OpenGL ES glBindRenderbuffer and glBindRenderbufferOES use this same
     * entry point, but they allow the use of user-generated names.
     */
-   bind_renderbuffer(target, renderbuffer, _mesa_is_gles(ctx));
+   bind_renderbuffer(target, renderbuffer);
 }
 
 void GLAPIENTRY
 _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
 {
-   /* This function should not be in the dispatch table for core profile /
-    * OpenGL 3.1, so execution should never get here in those cases -- no
-    * need for an explicit test.
-    */
-   bind_renderbuffer(target, renderbuffer, true);
+   bind_renderbuffer(target, renderbuffer);
 }
 
 /**
@@ -1503,6 +1498,7 @@ framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
       if (!ctx->Extensions.MESA_framebuffer_flip_y)
          goto invalid_pname_enum;
       cannot_be_winsys_fbo = true;
+      break;
    default:
       goto invalid_pname_enum;
    }
@@ -2080,7 +2076,7 @@ _mesa_base_fbo_format(const struct gl_context *ctx, GLenum internalFormat)
       return _mesa_has_EXT_texture_snorm(ctx) || _mesa_has_EXT_render_snorm(ctx)
          ? GL_RG : 0;
    case GL_RG_SNORM:
-      _mesa_has_EXT_texture_snorm(ctx) ? GL_RG : 0;
+      return _mesa_has_EXT_texture_snorm(ctx) ? GL_RG : 0;
    case GL_RG16_SNORM:
       return _mesa_has_EXT_texture_snorm(ctx) ||
              (_mesa_has_EXT_render_snorm(ctx) &&
@@ -2797,7 +2793,7 @@ check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
 
 
 static void
-bind_framebuffer(GLenum target, GLuint framebuffer, bool allow_user_names)
+bind_framebuffer(GLenum target, GLuint framebuffer)
 {
    struct gl_framebuffer *newDrawFb, *newReadFb;
    GLboolean bindReadBuf, bindDrawBuf;
@@ -2828,9 +2824,10 @@ bind_framebuffer(GLenum target, GLuint framebuffer, bool allow_user_names)
          /* ID was reserved, but no real framebuffer object made yet */
          newDrawFb = NULL;
       }
-      else if (!newDrawFb && !allow_user_names) {
+      else if (!newDrawFb && ctx->API == API_OPENGL_CORE) {
          /* All FBO IDs must be Gen'd */
-         _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)");
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glBindFramebuffer(non-gen name)");
          return;
       }
 
@@ -2919,23 +2916,17 @@ _mesa_bind_framebuffers(struct gl_context *ctx,
 void GLAPIENTRY
 _mesa_BindFramebuffer(GLenum target, GLuint framebuffer)
 {
-   GET_CURRENT_CONTEXT(ctx);
-
    /* OpenGL ES glBindFramebuffer and glBindFramebufferOES use this same entry
     * point, but they allow the use of user-generated names.
     */
-   bind_framebuffer(target, framebuffer, _mesa_is_gles(ctx));
+   bind_framebuffer(target, framebuffer);
 }
 
 
 void GLAPIENTRY
 _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
 {
-   /* This function should not be in the dispatch table for core profile /
-    * OpenGL 3.1, so execution should never get here in those cases -- no
-    * need for an explicit test.
-    */
-   bind_framebuffer(target, framebuffer, true);
+   bind_framebuffer(target, framebuffer);
 }
 
 
@@ -3292,13 +3283,14 @@ check_texture_target(struct gl_context *ctx, GLenum target,
    case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
       return true;
    case GL_TEXTURE_CUBE_MAP:
-      /* We don't need to check the extension (GL_ARB_direct_state_access) or
-       * GL version (4.5) for GL_TEXTURE_CUBE_MAP because DSA is always
-       * enabled in core profile.  This can be called from
-       * _mesa_FramebufferTextureLayer in compatibility profile (OpenGL 3.0),
-       * so we do have to check the profile.
+      /* GL_TEXTURE_CUBE_MAP is only allowed by OpenGL 4.5 here, which
+       * includes the DSA API.
+       *
+       * Because DSA is only enabled for GL 3.1+ and this can be called
+       * from _mesa_FramebufferTextureLayer in compatibility profile,
+       * we need to check the version.
        */
-      return ctx->API == API_OPENGL_CORE;
+      return _mesa_is_desktop_gl(ctx) && ctx->Version >= 31;
    }
 
    _mesa_error(ctx, GL_INVALID_OPERATION,