[Mesa-dev] [PATCH 2/2] mesa: simplify code setting boolean uniforms

Matt Turner mattst88 at gmail.com
Thu Mar 19 08:26:47 PDT 2015


On Thu, Mar 19, 2015 at 7:53 AM, Brian Paul <brianp at vmware.com> wrote:
> src[i] is a union.  Just check if src[i].u is non-zero to choose
> between ctx->Const.UniformBooleanTrue and zero.
> ---
>  src/mesa/main/uniform_query.cpp | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
> index 2ab5528..9ce45ee 100644
> --- a/src/mesa/main/uniform_query.cpp
> +++ b/src/mesa/main/uniform_query.cpp
> @@ -785,11 +785,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
>        const unsigned elems = components * count;
>
>        for (unsigned i = 0; i < elems; i++) {
> -        if (basicType == GLSL_TYPE_FLOAT) {
> -            dst[i].i = src[i].f != 0.0f ? ctx->Const.UniformBooleanTrue : 0;

I guess this also handles -0.0f as well, which isn't 0u. I'm not sure
if that's desired behavior or not?

> -        } else {
> -            dst[i].i = src[i].i != 0    ? ctx->Const.UniformBooleanTrue : 0;
> -        }
> +         dst[i].i = src[i].u ? ctx->Const.UniformBooleanTrue : 0;
>        }
>     }
>
> --
> 1.9.1


More information about the mesa-dev mailing list