[Mesa-dev] [PATCH 3/4] mesa: Fix the component type of unorm depth textures.

Brian Paul brianp at vmware.com
Fri Nov 11 12:55:20 PST 2011


On 11/11/2011 11:57 AM, Eric Anholt wrote:
> Fixes a failure in piglit gl-3.0-required-sized-formats
> ---
>   src/mesa/main/texparam.c |   18 +++++++++++++++++-
>   1 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> index e9bed23..fad864d 100644
> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -1116,13 +1116,29 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
>         case GL_TEXTURE_ALPHA_TYPE_ARB:
>         case GL_TEXTURE_LUMINANCE_TYPE_ARB:
>         case GL_TEXTURE_INTENSITY_TYPE_ARB:
> -      case GL_TEXTURE_DEPTH_TYPE_ARB:
>            if (!ctx->Extensions.ARB_texture_float)
>               goto invalid_pname;
>   	 if (texture_base_type_allows_channel(img, pname))
>   	    *params = _mesa_get_format_datatype(texFormat);
>   	 else
>   	    *params = GL_NONE;
> +	 break;
> +
> +      case GL_TEXTURE_DEPTH_TYPE_ARB:
> +         if (!ctx->Extensions.ARB_texture_float)
> +            goto invalid_pname;
> +	 if (texture_base_type_allows_channel(img, pname)) {
> +	    /* Mesa's gl_format has a datatype of GL_UNSIGNED_INT for Z16/Z24,
> +	     * but the only types of depth components in table 3.18 of the GL
> +	     * 3.0 specification are f32 or unsigned normalized.
> +	     */
> +	    if (_mesa_get_format_datatype(texFormat) == GL_FLOAT)
> +	       *params = GL_FLOAT;
> +	    else
> +	       *params = GL_UNSIGNED_NORMALIZED;
> +	 } else {
> +	    *params = GL_NONE;
> +	 }
>            break;
>
>         default:

Maybe we should change the format query to return 
GL_UNSIGNED_NORMALIZED for the Z16/Z24/etc formats.  It would seem to 
make more sense.  There might only be a handful of calls where we 
might need to compensate for the new value.

-Brian


More information about the mesa-dev mailing list