[Mesa-dev] [PATCH V2 1/9] glsl: Clean up apply_implicit_conversion

Kenneth Graunke kenneth at whitecape.org
Sun May 11 18:08:27 PDT 2014


On 05/04/2014 01:23 AM, Chris Forbes wrote:
> We're about to add new implicit conversions, first for ARB_gpu_shader5,
> and then later for ARB_gpu_shader_fp64. Pull out the opcode
> determination into its own function, and get rid of the bool -> float
> case that could never be hit anyway [since it fails the is_numeric()
> check].
> 
> V2: Retain the vector width mangling. It turns out this is necessary for
> the conversions done (and then thrown away) when determining the return
> type of arithmetic operators.
> 
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/glsl/ast_to_hir.cpp | 58 ++++++++++++++++++++++++++-----------------------
>  1 file changed, 31 insertions(+), 27 deletions(-)
> 
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 7516c33..b695132 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -164,6 +164,23 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
>  }
>  
>  
> +static ir_expression_operation
> +get_conversion_operation(const glsl_type *to, const glsl_type *from,
> +                         struct _mesa_glsl_parse_state *state)
> +{
> +   switch (to->base_type) {
> +   case GLSL_TYPE_FLOAT:
> +      switch (from->base_type) {
> +      case GLSL_TYPE_INT: return ir_unop_i2f;
> +      case GLSL_TYPE_UINT: return ir_unop_u2f;
> +      default: return (ir_expression_operation)0;
> +      }
> +
> +   default: return (ir_expression_operation)0;
> +   }
> +}
> +
> +
>  /**
>   * If a conversion is available, convert one operand to a different type
>   *
> @@ -185,9 +202,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
>     if (to->base_type == from->type->base_type)
>        return true;
>  
> -   /* This conversion was added in GLSL 1.20.  If the compilation mode is
> -    * GLSL 1.10, the conversion is skipped.
> -    */
> +   /* Prior to GLSL 1.10, there are no implicit conversions */

Prior to GLSL 1.20, you mean :)

With that fixed, patches 1-5 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>     if (!state->is_version(120, 0))
>        return false;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140511/1e43c247/attachment-0001.sig>


More information about the mesa-dev mailing list