Re: [Mesa-dev] [PATCH] spirv: split constant initializers on in/out structs

2018-02-05 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

On Tue, Jan 23, 2018 at 5:11 AM, Iago Toral Quiroga 
wrote:

> The SPIR-V parser splits in/out struct variables and creates
> a separate variable for each first-level member of the struct.
> When the struct variable has an initializer this means that we also
> need to split the initializer.
> ---
>  src/compiler/spirv/vtn_variables.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_
> variables.c
> index eb306d0c4a..ead68b4784 100644
> --- a/src/compiler/spirv/vtn_variables.c
> +++ b/src/compiler/spirv/vtn_variables.c
> @@ -1837,7 +1837,15 @@ vtn_create_variable(struct vtn_builder *b, struct
> vtn_value *val,
> interface_type->members[i]->type;
>  var->members[i]->data.mode = nir_mode;
>  var->members[i]->data.patch = var->patch;
> +
> +if (initializer) {
> +   assert(i < initializer->num_elements);
> +   var->members[i]->constant_initializer =
> +  nir_constant_clone(initializer->elements[i],
> var->members[i]);
> +}
>   }
> +
>

Mind adding a comment?

/* We dealt with any initializers during the splitting above. */


> + initializer = NULL;
>} else {
>   var->var = rzalloc(b->shader, nir_variable);
>   var->var->name = ralloc_strdup(var->var, val->name);
> --
> 2.14.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] spirv: split constant initializers on in/out structs

2018-02-04 Thread Iago Toral
This is still unreviewed.

Jason, since you reviewed the other patch I sent related to output
initializers, could you have a look at this one too?

Iago

On Tue, 2018-01-23 at 14:11 +0100, Iago Toral Quiroga wrote:
> The SPIR-V parser splits in/out struct variables and creates
> a separate variable for each first-level member of the struct.
> When the struct variable has an initializer this means that we also
> need to split the initializer.
> ---
>  src/compiler/spirv/vtn_variables.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/compiler/spirv/vtn_variables.c
> b/src/compiler/spirv/vtn_variables.c
> index eb306d0c4a..ead68b4784 100644
> --- a/src/compiler/spirv/vtn_variables.c
> +++ b/src/compiler/spirv/vtn_variables.c
> @@ -1837,7 +1837,15 @@ vtn_create_variable(struct vtn_builder *b,
> struct vtn_value *val,
> interface_type->members[i]->type;
>  var->members[i]->data.mode = nir_mode;
>  var->members[i]->data.patch = var->patch;
> +
> +if (initializer) {
> +   assert(i < initializer->num_elements);
> +   var->members[i]->constant_initializer =
> +  nir_constant_clone(initializer->elements[i], var-
> >members[i]);
> +}
>   }
> +
> + initializer = NULL;
>} else {
>   var->var = rzalloc(b->shader, nir_variable);
>   var->var->name = ralloc_strdup(var->var, val->name);
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] spirv: split constant initializers on in/out structs

2018-01-29 Thread Iago Toral
Anyone willing to review this?

On Tue, 2018-01-23 at 14:11 +0100, Iago Toral Quiroga wrote:
> The SPIR-V parser splits in/out struct variables and creates
> a separate variable for each first-level member of the struct.
> When the struct variable has an initializer this means that we also
> need to split the initializer.
> ---
>  src/compiler/spirv/vtn_variables.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/compiler/spirv/vtn_variables.c
> b/src/compiler/spirv/vtn_variables.c
> index eb306d0c4a..ead68b4784 100644
> --- a/src/compiler/spirv/vtn_variables.c
> +++ b/src/compiler/spirv/vtn_variables.c
> @@ -1837,7 +1837,15 @@ vtn_create_variable(struct vtn_builder *b,
> struct vtn_value *val,
> interface_type->members[i]->type;
>  var->members[i]->data.mode = nir_mode;
>  var->members[i]->data.patch = var->patch;
> +
> +if (initializer) {
> +   assert(i < initializer->num_elements);
> +   var->members[i]->constant_initializer =
> +  nir_constant_clone(initializer->elements[i], var-
> >members[i]);
> +}
>   }
> +
> + initializer = NULL;
>} else {
>   var->var = rzalloc(b->shader, nir_variable);
>   var->var->name = ralloc_strdup(var->var, val->name);
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] spirv: split constant initializers on in/out structs

2018-01-23 Thread Iago Toral Quiroga
The SPIR-V parser splits in/out struct variables and creates
a separate variable for each first-level member of the struct.
When the struct variable has an initializer this means that we also
need to split the initializer.
---
 src/compiler/spirv/vtn_variables.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index eb306d0c4a..ead68b4784 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1837,7 +1837,15 @@ vtn_create_variable(struct vtn_builder *b, struct 
vtn_value *val,
interface_type->members[i]->type;
 var->members[i]->data.mode = nir_mode;
 var->members[i]->data.patch = var->patch;
+
+if (initializer) {
+   assert(i < initializer->num_elements);
+   var->members[i]->constant_initializer =
+  nir_constant_clone(initializer->elements[i], 
var->members[i]);
+}
  }
+
+ initializer = NULL;
   } else {
  var->var = rzalloc(b->shader, nir_variable);
  var->var->name = ralloc_strdup(var->var, val->name);
-- 
2.14.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev