glapi / teximage: implement EGLImageTargetTexStorageEXT
[mesa.git] / src / mesa / main / buffers.c
index 4e48b76fcb884a4affeccfbffebf85c47a848231..5dc00116ead04ac020e97cee355b7cde331f7b74 100644 (file)
@@ -35,6 +35,7 @@
 #include "context.h"
 #include "enums.h"
 #include "fbobject.h"
+#include "hash.h"
 #include "mtypes.h"
 #include "util/bitscan.h"
 #include "util/u_math.h"
@@ -84,8 +85,9 @@ supported_buffer_bitmask(const struct gl_context *ctx,
    return mask;
 }
 
-static GLenum
-back_to_front_if_single_buffered(const struct gl_context *ctx, GLenum buffer)
+GLenum
+_mesa_back_to_front_if_single_buffered(const struct gl_framebuffer *fb,
+                                       GLenum buffer)
 {
    /* If the front buffer is the only buffer, GL_BACK and all other flags
     * that include BACK select the front buffer for drawing. There are
@@ -109,7 +111,7 @@ back_to_front_if_single_buffered(const struct gl_context *ctx, GLenum buffer)
     *    but they are front buffers from the Mesa point of view,
     *    because they are always single buffered.
     */
-   if (!ctx->DrawBuffer->Visual.doubleBufferMode) {
+   if (!fb->Visual.doubleBufferMode) {
       switch (buffer) {
       case GL_BACK:
          buffer = GL_FRONT;
@@ -134,7 +136,7 @@ back_to_front_if_single_buffered(const struct gl_context *ctx, GLenum buffer)
 static GLbitfield
 draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
 {
-   buffer = back_to_front_if_single_buffered(ctx, buffer);
+   buffer = _mesa_back_to_front_if_single_buffered(ctx->DrawBuffer, buffer);
 
    switch (buffer) {
       case GL_NONE:
@@ -199,7 +201,7 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
 static gl_buffer_index
 read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer)
 {
-   buffer = back_to_front_if_single_buffered(ctx, buffer);
+   buffer = _mesa_back_to_front_if_single_buffered(ctx->ReadBuffer, buffer);
 
    switch (buffer) {
       case GL_FRONT:
@@ -376,6 +378,25 @@ _mesa_NamedFramebufferDrawBuffer_no_error(GLuint framebuffer, GLenum buf)
 }
 
 
+void GLAPIENTRY
+_mesa_FramebufferDrawBufferEXT(GLuint framebuffer, GLenum buf)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+      fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
+                                        "glFramebufferDrawBufferEXT");
+      if (!fb)
+         return;
+   }
+   else
+      fb = ctx->WinSysDrawBuffer;
+
+   draw_buffer_error(ctx, fb, buf, "glFramebufferDrawBufferEXT");
+}
+
+
 void GLAPIENTRY
 _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
 {
@@ -649,6 +670,24 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
    draw_buffers_error(ctx, ctx->DrawBuffer, n, buffers, "glDrawBuffers");
 }
 
+void GLAPIENTRY
+_mesa_FramebufferDrawBuffersEXT(GLuint framebuffer, GLsizei n,
+                                const GLenum *bufs)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+      fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
+                                        "glFramebufferDrawBuffersEXT");
+      if (!fb)
+         return;
+   }
+   else
+      fb = ctx->WinSysDrawBuffer;
+
+   draw_buffers_error(ctx, fb, n, bufs, "glFramebufferDrawBuffersEXT");
+}
 
 void GLAPIENTRY
 _mesa_NamedFramebufferDrawBuffers_no_error(GLuint framebuffer, GLsizei n,
@@ -959,6 +998,25 @@ _mesa_NamedFramebufferReadBuffer_no_error(GLuint framebuffer, GLenum src)
 }
 
 
+void GLAPIENTRY
+_mesa_FramebufferReadBufferEXT(GLuint framebuffer, GLenum buf)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+      fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
+                                        "glFramebufferReadBufferEXT");
+      if (!fb)
+         return;
+   }
+   else
+      fb = ctx->WinSysDrawBuffer;
+
+   read_buffer_err(ctx, fb, buf, "glFramebufferReadBufferEXT");
+}
+
+
 void GLAPIENTRY
 _mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
 {