[Mesa-dev] [PATCH 37/42] mesa: create read_buffer_err() and always inline read_buffer()
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Jun 27 11:20:40 UTC 2017
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/mesa/main/buffers.c | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d85974afe60..dfee7a4421e 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);
@@ -761,18 +760,23 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
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 +792,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 +823,5 @@ _mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
else
fb = ctx->WinSysReadBuffer;
- read_buffer(ctx, fb, src, "glNamedFramebufferReadBuffer");
+ read_buffer_err(ctx, fb, src, "glNamedFramebufferReadBuffer");
}
--
2.13.2
More information about the mesa-dev
mailing list