[Mesa-dev] [PATCH 2/2] spirv: update arguments for vtn_nir_alu_op_for_spirv_opcode()
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 14 14:53:53 UTC 2018
On March 14, 2018 03:42:04 Samuel Iglesias Gonsálvez <siglesias at igalia.com>
wrote:
> We don't need anymore the source and destination's data type, just
> their bitsize.
>
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> ---
> src/compiler/spirv/spirv_to_nir.c | 4 ++--
> src/compiler/spirv/vtn_alu.c | 30 ++++++++++++++++++------------
> src/compiler/spirv/vtn_private.h | 2 +-
> 3 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c
> b/src/compiler/spirv/spirv_to_nir.c
> index 3de45c47371..516fce1ecec 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -1703,8 +1703,8 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
> };
>
> nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
> - src_alu_type,
> - dst_alu_type);
> +
> nir_alu_type_get_type_size(src_alu_type),
> +
> nir_alu_type_get_type_size(dst_alu_type));
> nir_const_value src[4];
>
> for (unsigned i = 0; i < count - 4; i++) {
> diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
> index 15158b39520..3720a9484ff 100644
> --- a/src/compiler/spirv/vtn_alu.c
> +++ b/src/compiler/spirv/vtn_alu.c
> @@ -275,7 +275,7 @@ vtn_handle_bitcast(struct vtn_builder *b, struct
> vtn_ssa_value *dest,
> nir_op
> vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
> SpvOp opcode, bool *swap,
> - nir_alu_type src, nir_alu_type dst)
> + unsigned src_bit_size, unsigned dst_bit_size)
> {
> /* Indicates that the first two arguments should be swapped. This is
> * used for implementing greater-than and less-than-or-equal.
> @@ -388,8 +388,8 @@ vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
> default:
> unreachable("Invalid opcode");
> }
> - src_type |= nir_alu_type_get_type_size(src);
> - dst_type |= nir_alu_type_get_type_size(dst);
> + src_type |= src_bit_size;
> + dst_type |= dst_bit_size;
> return nir_type_conversion_op(src_type, dst_type, nir_rounding_mode_undef);
> }
> /* Derivatives: */
> @@ -575,10 +575,12 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
> case SpvOpFUnordLessThanEqual:
> case SpvOpFUnordGreaterThanEqual: {
> bool swap;
> - nir_alu_type src_alu_type =
> nir_get_nir_type_for_glsl_type(vtn_src[0]->type);
> - nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type);
> + unsigned src_bit_size =
> +
> nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(vtn_src[0]->type));
> + unsigned dst_bit_size =
> + nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(type));
Just use glsl_type_get_bit_size
> nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
> - src_alu_type, dst_alu_type);
> + src_bit_size, dst_bit_size);
>
> if (swap) {
> nir_ssa_def *tmp = src[0];
> @@ -602,10 +604,12 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
> case SpvOpFOrdLessThanEqual:
> case SpvOpFOrdGreaterThanEqual: {
> bool swap;
> - nir_alu_type src_alu_type =
> nir_get_nir_type_for_glsl_type(vtn_src[0]->type);
> - nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type);
> + unsigned src_bit_size =
> +
> nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(vtn_src[0]->type));
> + unsigned dst_bit_size =
> + nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(type));
Same here
> nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
> - src_alu_type, dst_alu_type);
> + src_bit_size, dst_bit_size);
>
> if (swap) {
> nir_ssa_def *tmp = src[0];
> @@ -640,10 +644,12 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
>
> default: {
> bool swap;
> - nir_alu_type src_alu_type =
> nir_get_nir_type_for_glsl_type(vtn_src[0]->type);
> - nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type);
> + unsigned src_bit_size =
> +
> nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(vtn_src[0]->type));
> + unsigned dst_bit_size =
> + nir_alu_type_get_type_size(nir_get_nir_type_for_glsl_type(type));
And here
With those changes made, rb.
> nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap,
> - src_alu_type, dst_alu_type);
> + src_bit_size, dst_bit_size);
>
> if (swap) {
> nir_ssa_def *tmp = src[0];
> diff --git a/src/compiler/spirv/vtn_private.h
> b/src/compiler/spirv/vtn_private.h
> index a8fa612384f..70f660fbd48 100644
> --- a/src/compiler/spirv/vtn_private.h
> +++ b/src/compiler/spirv/vtn_private.h
> @@ -708,7 +708,7 @@ void vtn_foreach_execution_mode(struct vtn_builder *b,
> struct vtn_value *value,
>
> nir_op vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
> SpvOp opcode, bool *swap,
> - nir_alu_type src, nir_alu_type dst);
> + unsigned src_bit_size, unsigned
> dst_bit_size);
>
> void vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
> const uint32_t *w, unsigned count);
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list