[Mesa-dev] [PATCH 23/41] main: Added entry points for glGetTextureLevelParameteriv, fv.
Brian Paul
brianp at vmware.com
Tue Dec 16 07:46:05 PST 2014
On 12/15/2014 06:22 PM, Laura Ekstrand wrote:
> ---
> src/mapi/glapi/gen/ARB_direct_state_access.xml | 14 +++
> src/mesa/main/texparam.c | 136 ++++++++++++++++++++-----
> src/mesa/main/texparam.h | 9 ++
> 3 files changed, 131 insertions(+), 28 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 9658fd1..c4213eb 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -116,5 +116,19 @@
> <param name="texture" type="GLuint" />
> </function>
>
> + <function name="GetTextureLevelParameterfv" offset="assign">
> + <param name="texture" type="GLuint" />
> + <param name="level" type="GLint" />
> + <param name="pname" type="GLenum" />
> + <param name="params" type="GLfloat *" />
> + </function>
> +
> + <function name="GetTextureLevelParameteriv" offset="assign">
> + <param name="texture" type="GLuint" />
> + <param name="level" type="GLint" />
> + <param name="pname" type="GLenum" />
> + <param name="params" type="GLint *" />
> + </function>
> +
> </category>
> </OpenGLAPI>
> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> index 6e3a877..51fbd2a 100644
> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -1285,7 +1285,8 @@ 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,
> + const char *func)
> {
> const struct gl_texture_image *img = NULL;
> struct gl_texture_image dummy_image;
> @@ -1400,7 +1401,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
> }
> else {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glGetTexLevelParameter[if]v(pname)");
> + "%s(pname)", func);
> }
> break;
> case GL_TEXTURE_COMPRESSED:
> @@ -1448,7 +1449,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
>
> invalid_pname:
> _mesa_error(ctx, GL_INVALID_ENUM,
> - "glGetTexLevelParameter[if]v(pname=%s)",
> + "%s(pname=%s)", func,
> _mesa_lookup_enum_by_nr(pname));
> }
>
> @@ -1456,7 +1457,8 @@ 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,
> + const char *func)
> {
> const struct gl_buffer_object *bo = texObj->BufferObject;
> mesa_format texFormat = texObj->_BufferObjectFormat;
> @@ -1531,7 +1533,7 @@ 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)");
> + "%s(pname)", func);
> break;
>
> /* GL_ARB_texture_float */
> @@ -1559,57 +1561,135 @@ get_tex_level_parameter_buffer(struct gl_context *ctx,
>
> invalid_pname:
> _mesa_error(ctx, GL_INVALID_ENUM,
> - "glGetTexLevelParameter[if]v(pname=%s)",
> + "%s(pname=%s)", func,
> _mesa_lookup_enum_by_nr(pname));
> }
>
>
> +static bool
> +levels_valid( struct gl_context *ctx, GLenum target, GLint level,
> + const char *func)
s/levels/level/ and add a comment on the function?
> +{
> + GLint maxLevels;
> +
> + /* Need this because glGetTexLevelParameteri and f are different. We don't
> + * want to keep track of both the dsa flag and iv, i, f, etc. That's too
> + * much work. */
> + bool dsa = strstr(func, "Texture") ? true : false;
This seems kind of clunky.
> +
> + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "%s(current unit)", func);
> + return false;
> + }
> +
> + if (!legal_get_tex_level_parameter_target(ctx, target, dsa)) {
> + _mesa_error(ctx, GL_INVALID_ENUM,
> + "%s(target=0x%x)", func, target);
> + return false;
> + }
> +
> + maxLevels = _mesa_max_texture_levels(ctx, target);
> + assert(maxLevels != 0);
> +
> + if (level < 0 || level >= maxLevels) {
> + _mesa_error( ctx, GL_INVALID_VALUE, "%s", func );
> + return false;
> + }
> +
> + return true;
> +}
> +
> +/**
> + * 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,
> + const char *func )
> +{
> + if (!levels_valid(ctx, target, level, func))
> + return;
> +
> + if (target == GL_TEXTURE_BUFFER) {
> + get_tex_level_parameter_buffer(ctx, texObj, pname, params, func);
> + }
> + else {
> + get_tex_level_parameter_image(ctx, texObj, target,
> + level, pname, params, func);
> + }
> +}
> +
> 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, "glGetTexLevelParameterfv");
> +
> *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, "glGetTexLevelParameteriv");
> +}
>
> - 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, "glGetTextureLevelParameterfv");
>
> - 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, "glGetTextureLevelParameteriv");
> +}
>
> void GLAPIENTRY
> _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
> diff --git a/src/mesa/main/texparam.h b/src/mesa/main/texparam.h
> index a2fb3ff..05aeb8a 100644
> --- a/src/mesa/main/texparam.h
> +++ b/src/mesa/main/texparam.h
> @@ -81,6 +81,15 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
> GLenum pname, GLint *params );
>
> extern void GLAPIENTRY
> +_mesa_GetTextureLevelParameterfv( GLuint texture, GLint level,
> + GLenum pname, GLfloat *params );
> +
> +extern void GLAPIENTRY
> +_mesa_GetTextureLevelParameteriv( GLuint texture, GLint level,
> + GLenum pname, GLint *params );
> +
> +
> +extern void GLAPIENTRY
> _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params );
>
> extern void GLAPIENTRY
>
More information about the mesa-dev
mailing list