[Mesa-dev] [PATCH 2/2] mesa: check bits per channel for GL_RGBA_SIGNED_COMPONENTS_EXT query

Roland Scheidegger sroland at vmware.com
Tue Jan 7 11:05:08 PST 2014


Am 07.01.2014 17:35, schrieb Brian Paul:
> If a channel has zero bits it's not signed.
> ---
>  src/mesa/main/get.c |   28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index c45a8d1..bb138c8 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -769,13 +769,27 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
>           /* Note: we only check the 0th color attachment. */
>           const struct gl_renderbuffer *rb =
>              ctx->DrawBuffer->_ColorDrawBuffers[0];
> -         const GLboolean is_signed =
> -            rb ? _mesa_is_format_signed(rb->Format) : GL_FALSE;
> -         /* At this time, all color channels have same signedness */
> -         v->value_int_4[0] =
> -         v->value_int_4[1] =
> -         v->value_int_4[2] =
> -         v->value_int_4[3] = is_signed;
> +         if (rb && _mesa_is_format_signed(rb->Format)) {
> +            /* Issue 17 of GL_EXT_packed_float:  If a component (such as
> +             * alpha) has zero bits, the component should not be considered
> +             * signed and so the bit for the respective component should be
> +             * zeroed.
> +             */
> +            v->value_int_4[0] =
> +               _mesa_get_format_bits(rb->Format, GL_RED_BITS) > 0;
> +            v->value_int_4[1] =
> +               _mesa_get_format_bits(rb->Format, GL_GREEN_BITS) > 0;
> +            v->value_int_4[2] =
> +               _mesa_get_format_bits(rb->Format, GL_BLUE_BITS) > 0;
> +            v->value_int_4[3] =
> +               _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS) > 0;
> +         }
> +         else {
> +            v->value_int_4[0] =
> +            v->value_int_4[1] =
> +            v->value_int_4[2] =
> +            v->value_int_4[3] = 0;
> +         }
>        }
>        break;
>  
> 

Series looks good to me. Though I really wonder who would care if a
zero-bit component is considered to be signed or not :-).

Roland


More information about the mesa-dev mailing list