[PATCH vkd3d 4/6] vkd3d-shader/hlsl: Write SM4 bitwise AND instructions.

Giovanni Mascellani gmascellani at codeweavers.com
Tue Mar 15 07:52:05 CDT 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
Though it feels a little bit funny that type_is_integer() and 
type_is_float() are written with inconsistent styles. Any particular 
reason? If not, I would express a mild preference to have them written 
in a more consistent way, following the principle of least surprise.

Il 09/03/22 00:58, Zebediah Figura ha scritto:
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl_sm4.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
> index c4cfcac08..f635bfb0b 100644
> --- a/libs/vkd3d-shader/hlsl_sm4.c
> +++ b/libs/vkd3d-shader/hlsl_sm4.c
> @@ -1408,6 +1408,20 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer
>       write_sm4_instruction(buffer, &instr);
>   }
>   
> +static bool type_is_integer(const struct hlsl_type *type)
> +{
> +    switch (type->base_type)
> +    {
> +        case HLSL_TYPE_BOOL:
> +        case HLSL_TYPE_INT:
> +        case HLSL_TYPE_UINT:
> +            return true;
> +
> +        default:
> +            return false;
> +    }
> +}
> +
>   static bool type_is_float(const struct hlsl_type *type)
>   {
>       return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
> @@ -1609,6 +1623,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
>               }
>               break;
>   
> +        case HLSL_OP2_BIT_AND:
> +            assert(type_is_integer(dst_type));
> +            write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2);
> +            break;
> +
>           case HLSL_OP2_DIV:
>               switch (dst_type->base_type)
>               {



More information about the wine-devel mailing list