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

Jason Ekstrand jason at jlekstrand.net
Sun Jul 15 02:58:41 UTC 2018


I'm not really sure what this doing.  Mind giving some more explanation?
Is this something that's an issue with Vulkan SPIR-V as well?

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),
>              };
>           } 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/20180714/557fff7f/attachment.html>


More information about the mesa-dev mailing list