[Mesa-dev] [PATCH 6/6] nir/spirv: handle functions with scalar and vector params

Jason Ekstrand jason at jlekstrand.net
Mon Jul 16 04:36:26 UTC 2018


On Thu, Jul 12, 2018 at 4:30 AM Karol Herbst <kherbst at redhat.com> wrote:

> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>  src/compiler/spirv/vtn_cfg.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
> index ed1ab5d1c2c..2b01ede6f81 100644
> --- a/src/compiler/spirv/vtn_cfg.c
> +++ b/src/compiler/spirv/vtn_cfg.c
> @@ -90,7 +90,10 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder
> *b, SpvOp opcode,
>        }
>
>        for (unsigned i = 0; i < func_type->length; i++) {
> -         if (func_type->params[i]->base_type ==
> vtn_base_type_sampled_image) {
> +         enum vtn_base_type base_type = func_type->params[i]->base_type;
> +         const struct glsl_type *type = func_type->params[i]->type;
> +
> +         if (base_type == vtn_base_type_sampled_image) {
>              /* Sampled images are two pointer parameters */
>              func->params[idx++] = (nir_parameter) {
>                 .num_components = 1, .bit_size = 32,
> @@ -98,14 +101,22 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder
> *b, SpvOp opcode,
>              func->params[idx++] = (nir_parameter) {
>                 .num_components = 1, .bit_size = 32,
>              };
> -         } else if (func_type->params[i]->base_type ==
> vtn_base_type_pointer &&
> -                    func_type->params[i]->type != NULL) {
> +         } else if (base_type == vtn_base_type_pointer && type != NULL) {
>              /* Pointers with as storage class get passed by-value */
> -
> assert(glsl_type_is_vector_or_scalar(func_type->params[i]->type));
> +            assert(glsl_type_is_vector_or_scalar(type));
> +            func->params[idx++] = (nir_parameter) {
> +               .num_components = glsl_get_vector_elements(type),
> +               .bit_size = glsl_get_bit_size(type),
> +            };
> +         } else if (base_type == vtn_base_type_scalar) {
> +            func->params[idx++] = (nir_parameter) {
> +               .num_components = 1,
> +               .bit_size = glsl_get_bit_size(type),
> +            };
> +         } else if (base_type == vtn_base_type_vector) {
>              func->params[idx++] = (nir_parameter) {
> -               .num_components =
> -                  glsl_get_vector_elements(func_type->params[i]->type),
> -               .bit_size = glsl_get_bit_size(func_type->params[i]->type),
> +               .num_components = glsl_get_components(type),
> +               .bit_size = glsl_get_bit_size(type),
>

This will also handle the scalar case; you don't need to separate them.

This change alters the pre-pass part where we build up the function
prototype.  However, it doesn't change any code in vtn_cfg.  Are you sure
it works?  I strongly suspect it'll just blow up (or miscompile) further
down the line.

--Jason


>              };
>           } else {
>              /* Everything else is a regular pointer */
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180715/c07e242f/attachment.html>


More information about the mesa-dev mailing list