diff options
author | Laura Ekstrand <[email protected]> | 2014-12-10 15:19:59 -0800 |
---|---|---|
committer | Laura Ekstrand <[email protected]> | 2015-01-08 11:37:29 -0800 |
commit | 86bb3be3193512c12c284bb2cc609fa78d27fc55 (patch) | |
tree | ab1f188fbf1cc6b7c786c371a5477bff9543f96a /src/mesa/main/texparam.c | |
parent | bf5c588cdea616e0fb57f904c38bc0eb5eb2b962 (diff) |
main: Added entry points for glGetTextureLevelParameteriv, fv.
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/main/texparam.c')
-rw-r--r-- | src/mesa/main/texparam.c | 138 |
1 files changed, 106 insertions, 32 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index bee37e4428f..6b8532f965b 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -1278,11 +1278,13 @@ static void get_tex_level_parameter_image(struct gl_context *ctx, const struct gl_texture_object *texObj, GLenum target, GLint level, - GLenum pname, GLint *params) + GLenum pname, GLint *params, + bool dsa) { const struct gl_texture_image *img = NULL; struct gl_texture_image dummy_image; mesa_format texFormat; + const char *suffix = dsa ? "ture" : ""; img = _mesa_select_tex_image(texObj, target, level); if (!img || img->TexFormat == MESA_FORMAT_NONE) { @@ -1390,11 +1392,12 @@ get_tex_level_parameter_image(struct gl_context *ctx, !_mesa_is_proxy_texture(target)) { *params = _mesa_format_image_size(texFormat, img->Width, img->Height, img->Depth); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameter[if]v(pname)"); - } + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTex%sLevelParameter[if]v(pname=%s)", suffix, + _mesa_lookup_enum_by_nr(pname)); + } break; case GL_TEXTURE_COMPRESSED: *params = (GLint) _mesa_is_format_compressed(texFormat); @@ -1441,7 +1444,7 @@ get_tex_level_parameter_image(struct gl_context *ctx, invalid_pname: _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname=%s)", + "glGetTex%sLevelParameter[if]v(pname=%s)", suffix, _mesa_lookup_enum_by_nr(pname)); } @@ -1449,12 +1452,13 @@ invalid_pname: static void get_tex_level_parameter_buffer(struct gl_context *ctx, const struct gl_texture_object *texObj, - GLenum pname, GLint *params) + GLenum pname, GLint *params, bool dsa) { const struct gl_buffer_object *bo = texObj->BufferObject; mesa_format texFormat = texObj->_BufferObjectFormat; GLenum internalFormat = texObj->BufferObjectFormat; GLenum baseFormat = _mesa_get_format_base_format(texFormat); + const char *suffix = dsa ? "ture" : ""; if (!bo) { /* undefined texture buffer object */ @@ -1524,7 +1528,8 @@ get_tex_level_parameter_buffer(struct gl_context *ctx, case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: /* Always illegal for GL_TEXTURE_BUFFER */ _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameter[if]v(pname)"); + "glGetTex%sLevelParameter[if]v(pname=%s)", suffix, + _mesa_lookup_enum_by_nr(pname)); break; /* GL_ARB_texture_float */ @@ -1552,57 +1557,126 @@ get_tex_level_parameter_buffer(struct gl_context *ctx, invalid_pname: _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname=%s)", + "glGetTex%sLevelParameter[if]v(pname=%s)", suffix, _mesa_lookup_enum_by_nr(pname)); } +/** + * This isn't exposed to the rest of the driver because it is a part of the + * OpenGL API that is rarely used. + */ +static void +get_tex_level_parameteriv(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum target, GLint level, + GLenum pname, GLint *params, + bool dsa) +{ + GLint maxLevels; + const char *suffix = dsa ? "ture" : ""; + + /* Check for errors */ + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTex%sLevelParameter[if]v(" + "current unit >= max combined texture units)", suffix); + return; + } + + if (!legal_get_tex_level_parameter_target(ctx, target, dsa)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTex%sLevelParameter[if]v(target=%s)", suffix, + _mesa_lookup_enum_by_nr(target)); + return; + } + + maxLevels = _mesa_max_texture_levels(ctx, target); + assert(maxLevels != 0); + + if (level < 0 || level >= maxLevels) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetTex%sLevelParameter[if]v(level out of range)", suffix); + return; + } + + /* Get the level parameter */ + if (target == GL_TEXTURE_BUFFER) { + get_tex_level_parameter_buffer(ctx, texObj, pname, params, dsa); + } + else { + get_tex_level_parameter_image(ctx, texObj, target, + level, pname, params, dsa); + } +} + void GLAPIENTRY _mesa_GetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ) { + struct gl_texture_object *texObj; GLint iparam; - _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) + return; + + get_tex_level_parameteriv(ctx, texObj, target, level, + pname, &iparam, false); + *params = (GLfloat) iparam; } - void GLAPIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { struct gl_texture_object *texObj; - GLint maxLevels; GET_CURRENT_CONTEXT(ctx); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameteriv(current unit)"); + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) return; - } - if (!legal_get_tex_level_parameter_target(ctx, target, false)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(target=0x%x)", target); - return; - } + get_tex_level_parameteriv(ctx, texObj, target, level, + pname, params, false); +} - maxLevels = _mesa_max_texture_levels(ctx, target); - assert(maxLevels != 0); +void GLAPIENTRY +_mesa_GetTextureLevelParameterfv(GLuint texture, GLint level, + GLenum pname, GLfloat *params) +{ + struct gl_texture_object *texObj; + GLint iparam; + GET_CURRENT_CONTEXT(ctx); - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); + texObj = _mesa_lookup_texture_err(ctx, texture, + "glGetTextureLevelParameterfv"); + if (!texObj) return; - } - texObj = _mesa_get_current_tex_object(ctx, target); + get_tex_level_parameteriv(ctx, texObj, texObj->Target, level, + pname, &iparam, true); - if (target == GL_TEXTURE_BUFFER) - get_tex_level_parameter_buffer(ctx, texObj, pname, params); - else - get_tex_level_parameter_image(ctx, texObj, target, level, pname, params); + *params = (GLfloat) iparam; } +void GLAPIENTRY +_mesa_GetTextureLevelParameteriv(GLuint texture, GLint level, + GLenum pname, GLint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_lookup_texture_err(ctx, texture, + "glGetTextureLevelParameteriv"); + if (!texObj) + return; + + get_tex_level_parameteriv(ctx, texObj, texObj->Target, level, + pname, params, true); +} void GLAPIENTRY _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) |