summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/buffers.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d85974afe60..18e46adf84e 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -738,11 +738,10 @@ _mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
* renderbuffer for reading pixels.
* \param mode color buffer such as GL_FRONT, GL_BACK, etc.
*/
-static void
+static ALWAYS_INLINE void
read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLenum buffer, const char *caller)
+ GLenum buffer, const char *caller, bool no_error)
{
- GLbitfield supportedMask;
gl_buffer_index srcBuffer;
FLUSH_VERTICES(ctx, 0);
@@ -756,23 +755,29 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
}
else {
/* general case / window-system framebuffer */
- if (_mesa_is_gles3(ctx) && !is_legal_es3_readbuffer_enum(buffer))
+ if (!no_error &&_mesa_is_gles3(ctx) &&
+ !is_legal_es3_readbuffer_enum(buffer))
srcBuffer = BUFFER_NONE;
else
srcBuffer = read_buffer_enum_to_index(ctx, buffer);
- if (srcBuffer == BUFFER_NONE) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "%s(invalid buffer %s)", caller,
- _mesa_enum_to_string(buffer));
- return;
- }
- supportedMask = supported_buffer_bitmask(ctx, fb);
- if (((1 << srcBuffer) & supportedMask) == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid buffer %s)", caller,
- _mesa_enum_to_string(buffer));
- return;
+ if (!no_error) {
+ GLbitfield supportedMask;
+
+ if (srcBuffer == BUFFER_NONE) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "%s(invalid buffer %s)", caller,
+ _mesa_enum_to_string(buffer));
+ return;
+ }
+
+ supportedMask = supported_buffer_bitmask(ctx, fb);
+ if (((1 << srcBuffer) & supportedMask) == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid buffer %s)", caller,
+ _mesa_enum_to_string(buffer));
+ return;
+ }
}
}
@@ -788,11 +793,19 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
}
+static void
+read_buffer_err(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller)
+{
+ read_buffer(ctx, fb, buffer, caller, false);
+}
+
+
void GLAPIENTRY
_mesa_ReadBuffer(GLenum buffer)
{
GET_CURRENT_CONTEXT(ctx);
- read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
+ read_buffer_err(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
}
@@ -811,5 +824,5 @@ _mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
else
fb = ctx->WinSysReadBuffer;
- read_buffer(ctx, fb, src, "glNamedFramebufferReadBuffer");
+ read_buffer_err(ctx, fb, src, "glNamedFramebufferReadBuffer");
}