[Mesa-dev] [PATCH] st/glsl->tgsi: fix u64 to bool comparisons.

Nicolai Hähnle nhaehnle at gmail.com
Thu Sep 14 09:34:36 UTC 2017


On 14.09.2017 11:01, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> Otherwise we end up using a 32-bit comparison which didn't end well.
> 
> Timothy caught this while playing around with some opt passes.
> 
> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


> 
> ---
>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index cf6e8f8..9b15b61 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -205,6 +205,7 @@ public:
>      st_src_reg st_src_reg_for_double(double val);
>      st_src_reg st_src_reg_for_float(float val);
>      st_src_reg st_src_reg_for_int(int val);
> +   st_src_reg st_src_reg_for_int64(int64_t val);
>      st_src_reg st_src_reg_for_type(enum glsl_base_type type, int val);
>   
>      /**
> @@ -909,6 +910,19 @@ glsl_to_tgsi_visitor::st_src_reg_for_int(int val)
>   }
>   
>   st_src_reg
> +glsl_to_tgsi_visitor::st_src_reg_for_int64(int64_t val)
> +{
> +   st_src_reg src(PROGRAM_IMMEDIATE, -1, GLSL_TYPE_INT64);
> +   union gl_constant_value uval[2];
> +
> +   memcpy(uval, &val, sizeof(uval));
> +   src.index = add_constant(src.file, uval, 1, GL_DOUBLE, &src.swizzle);
> +   src.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_X, SWIZZLE_Y);
> +
> +   return src;
> +}
> +
> +st_src_reg
>   glsl_to_tgsi_visitor::st_src_reg_for_type(enum glsl_base_type type, int val)
>   {
>      if (native_integers)
> @@ -2141,7 +2155,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
>         break;
>      }
>      case ir_unop_i642b:
> -      emit_asm(ir, TGSI_OPCODE_U64SNE, result_dst, op[0], st_src_reg_for_int(0));
> +      emit_asm(ir, TGSI_OPCODE_U64SNE, result_dst, op[0], st_src_reg_for_int64(0));
>         break;
>      case ir_unop_i642f:
>         emit_asm(ir, TGSI_OPCODE_I642F, result_dst, op[0]);
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list