[Mesa-dev] [PATCH] ir_to_mesa: Stop converting uniform booleans.

Matt Turner mattst88 at gmail.com
Mon Sep 8 14:30:49 PDT 2014


On Mon, Sep 8, 2014 at 2:28 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Excess conversions considered harmful.
>
> Recently Matt reworked the boolean uniform handling to use the value of
> UniformBooleanTrue, rather than integer 1, when uploading uniforms:
>
>     mesa: Upload boolean uniforms using UniformBooleanTrue.
>     glsl: Use UniformBooleanTrue value for uniform initializers.
>
> Marek then set the default to 1.0f for drivers without native integer
> support:
>
>     mesa: set UniformBooleanTrue = 1.0f by default
>
> However, ir_to_mesa was assuming a value of integer 1, and arranging for
> it to be converted to 1.0f on upload.  Since Marek's commit, we were
> uploading 1.0f = 0x3f800000 which was being interpreted as the integer
> value 1065353216 and converted to float as 1.06535322E9, which broke
> assumptions in ir_to_mesa that "true" was exactly 1.0f.
>
> +13 Piglits on classic swrast (fs-bool-less-compare-true,
> {vs,fs}-op-not-bool-using-if, glsl-1.20/execution/uniform-initializer).
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83573
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/program/ir_to_mesa.cpp | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 49e4a7a..293fe34 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -2505,12 +2505,7 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
>             columns = storage->type->matrix_columns;
>             break;
>          case GLSL_TYPE_BOOL:
> -           if (ctx->Const.NativeIntegers) {
> -              format = (ctx->Const.UniformBooleanTrue == 1)
> -                 ? uniform_bool_int_0_1 : uniform_bool_int_0_not0;
> -           } else {
> -              format = uniform_bool_float;
> -           }
> +           format = uniform_native;
>             columns = 1;
>             break;
>          case GLSL_TYPE_SAMPLER:
> --

Nice. Thanks for fixing my bug! (and for doing the annoying work to
get swrast going)

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list