[Mesa-dev] [PATCH 14/23] i965: Remove remaining uses of ctx->Const.UniformBooleanTrue in visitors

Matt Turner mattst88 at gmail.com
Tue Apr 21 10:53:01 PDT 2015


On Fri, Apr 17, 2015 at 7:11 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> Since commit 2881b123, we have used 0/~0 for representing booleans on all
> gens.  However, we still had a bunch of places in the visitor code where we
> were still referring to ctx->Const.UniformBooleanTrue.  Since this is
> always ~0, we can just remove them.
>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |  4 +---
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 14 +++++---------
>  2 files changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index a99b12ef..8a43e3a 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -2641,9 +2641,7 @@ fs_visitor::visit(ir_constant *ir)
>             emit(MOV(dst_reg, fs_reg(ir->value.i[i])));
>             break;
>          case GLSL_TYPE_BOOL:
> -            emit(MOV(dst_reg,
> -                     fs_reg(ir->value.b[i] != 0 ? (int)ctx->Const.UniformBooleanTrue
> -                                                : 0)));
> +            emit(MOV(dst_reg, fs_reg(ir->value.b[i] != 0 ? ~0 : 0)));
>             break;
>          default:
>             unreachable("Non-float/uint/int/bool constant");
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index 20e6109..32eb75b 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -1635,7 +1635,7 @@ vec4_visitor::visit(ir_expression *ir)
>           ir->operands[1]->type->is_vector()) {
>          emit(CMP(dst_null_d(), op[0], op[1], BRW_CONDITIONAL_Z));
>          emit(MOV(result_dst, src_reg(0)));
> -         inst = emit(MOV(result_dst, src_reg((int)ctx->Const.UniformBooleanTrue)));
> +         inst = emit(MOV(result_dst, src_reg(~0 /* boolean true */)));

I don't think we need the comment.

>          inst->predicate = BRW_PREDICATE_ALIGN16_ALL4H;
>        } else {
>          emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_Z));
> @@ -1653,7 +1653,7 @@ vec4_visitor::visit(ir_expression *ir)
>          emit(CMP(dst_null_d(), op[0], op[1], BRW_CONDITIONAL_NZ));
>
>          emit(MOV(result_dst, src_reg(0)));
> -         inst = emit(MOV(result_dst, src_reg((int)ctx->Const.UniformBooleanTrue)));
> +         inst = emit(MOV(result_dst, src_reg(~0 /* boolean true */)));

Here as well.

>          inst->predicate = BRW_PREDICATE_ALIGN16_ANY4H;
>        } else {
>          emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_NZ));
> @@ -1667,7 +1667,7 @@ vec4_visitor::visit(ir_expression *ir)
>        emit(CMP(dst_null_d(), op[0], src_reg(0), BRW_CONDITIONAL_NZ));
>        emit(MOV(result_dst, src_reg(0)));
>
> -      inst = emit(MOV(result_dst, src_reg((int)ctx->Const.UniformBooleanTrue)));
> +      inst = emit(MOV(result_dst, src_reg(~0 /* boolean true */)));

Here as well.

>        inst->predicate = BRW_PREDICATE_ALIGN16_ANY4H;
>        break;
>
> @@ -1862,9 +1862,7 @@ vec4_visitor::visit(ir_expression *ir)
>                                              const_offset % 16 / 4,
>                                              const_offset % 16 / 4);
>
> -      /* UBO bools are any nonzero int.  We need to convert them to use the
> -       * value of true stored in ctx->Const.UniformBooleanTrue.
> -       */
> +      /* UBO bools are any nonzero int.  We need to convert them to 0/~0. */
>        if (ir->type->base_type == GLSL_TYPE_BOOL) {
>           emit(CMP(result_dst, packed_consts, src_reg(0u),
>                    BRW_CONDITIONAL_NZ));
> @@ -2370,9 +2368,7 @@ vec4_visitor::emit_constant_values(dst_reg *dst, ir_constant *ir)
>          emit(MOV(*dst, src_reg(ir->value.u[i])));
>          break;
>        case GLSL_TYPE_BOOL:
> -         emit(MOV(*dst,
> -                  src_reg(ir->value.b[i] != 0 ? (int)ctx->Const.UniformBooleanTrue
> -                                              : 0)));
> +         emit(MOV(*dst, src_reg(ir->value.b[i] != 0 ? ~0 : 0)));
>          break;
>        default:
>          unreachable("Non-float/uint/int/bool constant");
> --
> 2.3.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list