diff options
author | Laura Ekstrand <[email protected]> | 2015-03-04 14:46:02 -0800 |
---|---|---|
committer | Laura Ekstrand <[email protected]> | 2015-03-09 13:33:54 -0700 |
commit | 311b3686fe7433b1624384f7d344cc23d6363df2 (patch) | |
tree | d84c91f8a29d712b06c1fd486a8977aa9766fbce /src/mesa/main/teximage.c | |
parent | 5f8c6eabbeb698b6dc653eda9dcf01704e53ae58 (diff) |
main: Add check_texture_buffer_target.
Creates a shared function to ensure that texture buffer target is
GL_TEXTURE_BUFFER. Helps to clean up the Tex[ture]Buffer[Range] functions.
v2: Review from Anuj Phogat
- Split rebase of Tex[ture]Buffer[Range]
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r-- | src/mesa/main/teximage.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index e8b5d2eb678..7f11bfc46b2 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5290,6 +5290,25 @@ _mesa_texture_buffer_range(struct gl_context *ctx, /** + * Make sure the texture buffer target is GL_TEXTURE_BUFFER. + * Return true if it is, and return false if it is not + * (and throw INVALID ENUM as dictated in the OpenGL 4.5 + * core spec, 02.02.2015, PDF page 245). + */ +static bool +check_texture_buffer_target(struct gl_context *ctx, GLenum target, + const char *caller) +{ + if (target != GL_TEXTURE_BUFFER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(texture target is not GL_TEXTURE_BUFFER)", caller); + return false; + } + else + return true; +} + +/** * Check for errors related to the texture buffer range. * Return false if errors are found, true if none are found. */ @@ -5348,11 +5367,11 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) GET_CURRENT_CONTEXT(ctx); - /* Need to catch this before it gets to _mesa_get_current_tex_object */ - if (target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)"); + /* Need to catch a bad target before it gets to + * _mesa_get_current_tex_object. + */ + if (!check_texture_buffer_target(ctx, target, "glTexBuffer")) return; - } if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBuffer"); @@ -5380,11 +5399,11 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, GET_CURRENT_CONTEXT(ctx); - /* Need to catch this before it gets to _mesa_get_current_tex_object */ - if (target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBufferRange(target)"); + /* Need to catch a bad target before it gets to + * _mesa_get_current_tex_object. + */ + if (!check_texture_buffer_target(ctx, target, "glTexBufferRange")) return; - } if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBufferRange"); @@ -5437,10 +5456,8 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) if (!texObj) return; - if (texObj->Target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTextureBuffer(target)"); + if (!check_texture_buffer_target(ctx, texObj->Target, "glTextureBuffer")) return; - } _mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj, 0, buffer ? -1 : 0, "glTextureBuffer"); |