summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/buffers.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-06-26 17:06:14 +0200
committerSamuel Pitoiset <[email protected]>2017-06-28 10:25:13 +0200
commit91fcba99147c487370ce8ea8ca65f8734174c7d9 (patch)
tree6e9df65d114fe46bff0c1b1107a41c49be70a1a3 /src/mesa/main/buffers.c
parent89bc3ed7a3c78d7cacb6ea486b708a3a3374fcd8 (diff)
mesa: create read_buffer_err() and always inline read_buffer()
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/buffers.c')
-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");
}