<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 16, 2018 at 7:29 AM Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">OpenCL knows vector of size 8 and 16.<br>
<br>
v2: rebased on master (nir_swizzle rework)<br>
    rework more declarations with nir_component_mask_t<br>
    adjust print_var_decl<br>
<br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
---<br>
 src/compiler/nir/nir.c                        | 14 ++++----<br>
 src/compiler/nir/nir.h                        | 34 ++++++++++---------<br>
 src/compiler/nir/nir_builder.h                | 17 ++++++----<br>
 src/compiler/nir/nir_lower_alu_to_scalar.c    |  6 ++--<br>
 src/compiler/nir/nir_lower_io_to_scalar.c     |  4 +--<br>
 .../nir/nir_lower_load_const_to_scalar.c      |  2 +-<br>
 src/compiler/nir/nir_opt_constant_folding.c   |  2 +-<br>
 src/compiler/nir/nir_opt_copy_prop_vars.c     |  4 +--<br>
 src/compiler/nir/nir_print.c                  |  9 ++---<br>
 src/compiler/nir/nir_search.c                 |  8 ++---<br>
 src/compiler/nir/nir_validate.c               |  6 ++--<br>
 src/compiler/spirv/spirv_to_nir.c             |  2 +-<br>
 src/compiler/spirv/vtn_alu.c                  |  2 +-<br>
 13 files changed, 57 insertions(+), 53 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
index ca89a46f7d4..bc7f05b3e86 100644<br>
--- a/src/compiler/nir/nir.c<br>
+++ b/src/compiler/nir/nir.c<br>
@@ -251,7 +251,7 @@ nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src,<br>
    nir_src_copy(&dest->src, &src->src, &instr->instr);<br>
    dest->abs = src->abs;<br>
    dest->negate = src->negate;<br>
-   for (unsigned i = 0; i < 4; i++)<br>
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)<br>
       dest->swizzle[i] = src->swizzle[i];<br>
 }<br>
<br>
@@ -421,10 +421,8 @@ alu_src_init(nir_alu_src *src)<br>
 {<br>
    src_init(&src->src);<br>
    src->abs = src->negate = false;<br>
-   src->swizzle[0] = 0;<br>
-   src->swizzle[1] = 1;<br>
-   src->swizzle[2] = 2;<br>
-   src->swizzle[3] = 3;<br>
+   for (int i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i)<br>
+      src->swizzle[i] = i;<br>
 }<br>
<br>
 nir_alu_instr *<br>
@@ -1426,10 +1424,10 @@ nir_ssa_def_rewrite_uses_after(nir_ssa_def *def, nir_src new_src,<br>
       nir_if_rewrite_condition(use_src->parent_if, new_src);<br>
 }<br>
<br>
-uint8_t<br>
+nir_component_mask_t<br>
 nir_ssa_def_components_read(const nir_ssa_def *def)<br>
 {<br>
-   uint8_t read_mask = 0;<br>
+   nir_component_mask_t read_mask = 0;<br>
    nir_foreach_use(use, def) {<br>
       if (use->parent_instr->type == nir_instr_type_alu) {<br>
          nir_alu_instr *alu = nir_instr_as_alu(use->parent_instr);<br>
@@ -1437,7 +1435,7 @@ nir_ssa_def_components_read(const nir_ssa_def *def)<br>
          int src_idx = alu_src - &alu->src[0];<br>
          assert(src_idx >= 0 && src_idx < nir_op_infos[alu->op].num_inputs);<br>
<br>
-         for (unsigned c = 0; c < 4; c++) {<br>
+         for (unsigned c = 0; c < NIR_MAX_VEC_COMPONENTS; c++) {<br>
             if (!nir_alu_instr_channel_used(alu, src_idx, c))<br>
                continue;<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index 92ab3a699cc..d3e63be091f 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -57,6 +57,8 @@ extern "C" {<br>
<br>
 #define NIR_FALSE 0u<br>
 #define NIR_TRUE (~0u)<br>
+#define NIR_MAX_VEC_COMPONENTS 4<br>
+typedef uint8_t nir_component_mask_t;<br>
<br>
 /** Defines a cast function<br>
  *<br>
@@ -115,16 +117,16 @@ typedef enum {<br>
 } nir_rounding_mode;<br>
<br>
 typedef union {<br>
-   float f32[4];<br>
-   double f64[4];<br>
-   int8_t i8[4];<br>
-   uint8_t u8[4];<br>
-   int16_t i16[4];<br>
-   uint16_t u16[4];<br>
-   int32_t i32[4];<br>
-   uint32_t u32[4];<br>
-   int64_t i64[4];<br>
-   uint64_t u64[4];<br>
+   float f32[NIR_MAX_VEC_COMPONENTS];<br>
+   double f64[NIR_MAX_VEC_COMPONENTS];<br>
+   int8_t i8[NIR_MAX_VEC_COMPONENTS];<br>
+   uint8_t u8[NIR_MAX_VEC_COMPONENTS];<br>
+   int16_t i16[NIR_MAX_VEC_COMPONENTS];<br>
+   uint16_t u16[NIR_MAX_VEC_COMPONENTS];<br>
+   int32_t i32[NIR_MAX_VEC_COMPONENTS];<br>
+   uint32_t u32[NIR_MAX_VEC_COMPONENTS];<br>
+   int64_t i64[NIR_MAX_VEC_COMPONENTS];<br>
+   uint64_t u64[NIR_MAX_VEC_COMPONENTS];<br>
 } nir_const_value;<br>
<br>
 typedef struct nir_constant {<br>
@@ -135,7 +137,7 @@ typedef struct nir_constant {<br>
     * by the type associated with the \c nir_variable.  Constants may be<br>
     * scalars, vectors, or matrices.<br>
     */<br>
-   nir_const_value values[4];<br>
+   nir_const_value values[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    /* we could get this from the var->type but makes clone *much* easier to<br>
     * not have to care about the type.<br>
@@ -697,7 +699,7 @@ typedef struct {<br>
     * a statement like "foo.xzw = bar.zyx" would have a writemask of 1101b and<br>
     * a swizzle of {2, x, 1, 0} where x means "don't care."<br>
     */<br>
-   uint8_t swizzle[4];<br>
+   uint8_t swizzle[NIR_MAX_VEC_COMPONENTS];<br>
 } nir_alu_src;<br>
<br>
 typedef struct {<br>
@@ -712,7 +714,7 @@ typedef struct {<br>
<br>
    bool saturate;<br>
<br>
-   unsigned write_mask : 4; /* ignored if dest.is_ssa is true */<br>
+   unsigned write_mask : NIR_MAX_VEC_COMPONENTS; /* ignored if dest.is_ssa is true */<br>
 } nir_alu_dest;<br>
<br>
 typedef enum {<br>
@@ -841,14 +843,14 @@ typedef struct {<br>
    /**<br>
     * The number of components in each input<br>
     */<br>
-   unsigned input_sizes[4];<br>
+   unsigned input_sizes[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    /**<br>
     * The type of vector that each input takes. Note that negate and<br>
     * absolute value are only allowed on inputs with int or float type and<br>
     * behave differently on the two.<br>
     */<br>
-   nir_alu_type input_types[4];<br>
+   nir_alu_type input_types[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    nir_op_algebraic_property algebraic_properties;<br>
 } nir_op_info;<br>
@@ -2420,7 +2422,7 @@ void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src);<br>
 void nir_ssa_def_rewrite_uses_after(nir_ssa_def *def, nir_src new_src,<br>
                                     nir_instr *after_me);<br>
<br>
-uint8_t nir_ssa_def_components_read(const nir_ssa_def *def);<br>
+nir_component_mask_t nir_ssa_def_components_read(const nir_ssa_def *def);<br>
<br>
 /*<br>
  * finds the next basic block in source-code order, returns NULL if there is<br>
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h<br>
index ed61771150a..8c883f27619 100644<br>
--- a/src/compiler/nir/nir_builder.h<br>
+++ b/src/compiler/nir/nir_builder.h<br>
@@ -361,7 +361,8 @@ nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0,<br>
     * scalar value was passed into a multiply with a vector).<br>
     */<br>
    for (unsigned i = 0; i < op_info->num_inputs; i++) {<br>
-      for (unsigned j = instr->src[i].src.ssa->num_components; j < 4; j++) {<br>
+      for (unsigned j = instr->src[i].src.ssa->num_components;<br>
+           j < NIR_MAX_VEC_COMPONENTS; j++) {<br>
          instr->src[i].swizzle[j] = instr->src[i].src.ssa->num_components - 1;<br>
       }<br>
    }<br>
@@ -433,10 +434,10 @@ static inline nir_ssa_def *<br>
 nir_swizzle(nir_builder *build, nir_ssa_def *src, const unsigned *swiz,<br>
             unsigned num_components, bool use_fmov)<br>
 {<br>
-   assert(num_components <= 4);<br>
+   assert(num_components <= NIR_MAX_VEC_COMPONENTS);<br>
    nir_alu_src alu_src = { NIR_SRC_INIT };<br>
    alu_src.src = nir_src_for_ssa(src);<br>
-   for (unsigned i = 0; i < num_components && i < 4; i++)<br>
+   for (unsigned i = 0; i < num_components && i < NIR_MAX_VEC_COMPONENTS; i++)<br>
       alu_src.swizzle[i] = swiz[i];<br>
<br>
    return use_fmov ? nir_fmov_alu(build, alu_src, num_components) :<br>
@@ -486,11 +487,11 @@ nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c)<br>
 }<br>
<br>
 static inline nir_ssa_def *<br>
-nir_channels(nir_builder *b, nir_ssa_def *def, unsigned mask)<br>
+nir_channels(nir_builder *b, nir_ssa_def *def, nir_component_mask_t mask)<br>
 {<br>
-   unsigned num_channels = 0, swizzle[4] = { 0, 0, 0, 0 };<br>
+   unsigned num_channels = 0, swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 };<br>
<br>
-   for (unsigned i = 0; i < 4; i++) {<br>
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {<br>
       if ((mask & (1 << i)) == 0)<br>
          continue;<br>
       swizzle[num_channels++] = i;<br>
@@ -526,7 +527,9 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components)<br>
 static inline nir_ssa_def *<br>
 nir_ssa_for_alu_src(nir_builder *build, nir_alu_instr *instr, unsigned srcn)<br>
 {<br>
-   static uint8_t trivial_swizzle[4] = { 0, 1, 2, 3 };<br>
+   static uint8_t trivial_swizzle[NIR_MAX_VEC_COMPONENTS];<br>
+   for (int i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i)<br>
+      trivial_swizzle[i] = i;<br>
    nir_alu_src *src = &instr->src[srcn];<br>
    unsigned num_components = nir_ssa_alu_instr_src_components(instr, srcn);<br>
<br>
diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c b/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
index a0377dcb0be..742c8d8ee66 100644<br>
--- a/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
+++ b/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
@@ -209,9 +209,9 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)<br>
       return false;<br>
<br>
    unsigned num_components = instr->dest.dest.ssa.num_components;<br>
-   nir_ssa_def *comps[] = { NULL, NULL, NULL, NULL };<br>
+   nir_ssa_def *comps[NIR_MAX_VEC_COMPONENTS] = { NULL };<br>
<br>
-   for (chan = 0; chan < 4; chan++) {<br>
+   for (chan = 0; chan < NIR_MAX_VEC_COMPONENTS; chan++) {<br>
       if (!(instr->dest.write_mask & (1 << chan)))<br>
          continue;<br>
<br>
@@ -225,7 +225,7 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)<br>
                               0 : chan);<br>
<br>
          nir_alu_src_copy(&lower->src[i], &instr->src[i], lower);<br>
-         for (int j = 0; j < 4; j++)<br>
+         for (int j = 0; j < NIR_MAX_VEC_COMPONENTS; j++)<br>
             lower->src[i].swizzle[j] = instr->src[i].swizzle[src_chan];<br>
       }<br>
<br>
diff --git a/src/compiler/nir/nir_lower_io_to_scalar.c b/src/compiler/nir/nir_lower_io_to_scalar.c<br>
index f48da8be4cb..f0c2a6a95d6 100644<br>
--- a/src/compiler/nir/nir_lower_io_to_scalar.c<br>
+++ b/src/compiler/nir/nir_lower_io_to_scalar.c<br>
@@ -38,7 +38,7 @@ lower_load_input_to_scalar(nir_builder *b, nir_intrinsic_instr *intr)<br>
<br>
    assert(intr->dest.is_ssa);<br>
<br>
-   nir_ssa_def *loads[4];<br>
+   nir_ssa_def *loads[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    for (unsigned i = 0; i < intr->num_components; i++) {<br>
       nir_intrinsic_instr *chan_intr =<br>
@@ -177,7 +177,7 @@ lower_load_to_scalar_early(nir_builder *b, nir_intrinsic_instr *intr,<br>
<br>
    assert(intr->dest.is_ssa);<br>
<br>
-   nir_ssa_def *loads[4];<br>
+   nir_ssa_def *loads[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    nir_variable **chan_vars;<br>
    if (var->data.mode == nir_var_shader_in) {<br>
diff --git a/src/compiler/nir/nir_lower_load_const_to_scalar.c b/src/compiler/nir/nir_lower_load_const_to_scalar.c<br>
index 39447d42c23..b2e055f7dea 100644<br>
--- a/src/compiler/nir/nir_lower_load_const_to_scalar.c<br>
+++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c<br>
@@ -46,7 +46,7 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)<br>
    b.cursor = nir_before_instr(&lower->instr);<br>
<br>
    /* Emit the individual loads. */<br>
-   nir_ssa_def *loads[4];<br>
+   nir_ssa_def *loads[NIR_MAX_VEC_COMPONENTS];<br>
    for (unsigned i = 0; i < lower->def.num_components; i++) {<br>
       nir_load_const_instr *load_comp =<br>
          nir_load_const_instr_create(b.shader, 1, lower->def.bit_size);<br>
diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c<br>
index d011e4f6562..e2920e6b3fd 100644<br>
--- a/src/compiler/nir/nir_opt_constant_folding.c<br>
+++ b/src/compiler/nir/nir_opt_constant_folding.c<br>
@@ -41,7 +41,7 @@ struct constant_fold_state {<br>
 static bool<br>
 constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)<br>
 {<br>
-   nir_const_value src[4];<br>
+   nir_const_value src[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    if (!instr->dest.dest.is_ssa)<br>
       return false;<br>
diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
index de5de8b2968..d8c4cab34d7 100644<br>
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
@@ -389,7 +389,7 @@ load_from_ssa_entry_value(struct copy_prop_var_state *state,<br>
    const struct glsl_type *type = entry->dst->type;<br>
    unsigned num_components = glsl_get_vector_elements(type);<br>
<br>
-   uint8_t available = 0;<br>
+   nir_component_mask_t available = 0;<br>
    bool all_same = true;<br>
    for (unsigned i = 0; i < num_components; i++) {<br>
       if (value->ssa[i])<br>
@@ -422,7 +422,7 @@ load_from_ssa_entry_value(struct copy_prop_var_state *state,<br>
       intrin->intrinsic == nir_intrinsic_load_deref ? &intrin->dest.ssa : NULL;<br>
<br>
    bool keep_intrin = false;<br>
-   nir_ssa_def *comps[4];<br>
+   nir_ssa_def *comps[NIR_MAX_VEC_COMPONENTS];<br>
    for (unsigned i = 0; i < num_components; i++) {<br>
       if (value->ssa[i]) {<br>
          comps[i] = nir_channel(b, value->ssa[i], i);<br>
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c<br>
index 4fa12d2d207..93d1c02f23d 100644<br>
--- a/src/compiler/nir/nir_print.c<br>
+++ b/src/compiler/nir/nir_print.c<br>
@@ -186,9 +186,9 @@ print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state)<br>
    print_src(&instr->src[src].src, state);<br>
<br>
    bool print_swizzle = false;<br>
-   unsigned used_channels = 0;<br>
+   nir_component_mask_t used_channels = 0;<br>
<br>
-   for (unsigned i = 0; i < 4; i++) {<br>
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {<br>
       if (!nir_alu_instr_channel_used(instr, src, i))<br>
          continue;<br>
<br>
@@ -204,7 +204,7 @@ print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state)<br>
<br>
    if (print_swizzle || used_channels != live_channels) {<br>
       fprintf(fp, ".");<br>
-      for (unsigned i = 0; i < 4; i++) {<br>
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {<br>
          if (!nir_alu_instr_channel_used(instr, src, i))<br>
             continue;<br>
<br>
@@ -227,7 +227,7 @@ print_alu_dest(nir_alu_dest *dest, print_state *state)<br>
    if (!dest->dest.is_ssa &&<br>
        dest->write_mask != (1 << dest->dest.reg.reg->num_components) - 1) {<br>
       fprintf(fp, ".");<br>
-      for (unsigned i = 0; i < 4; i++)<br>
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)<br>
          if ((dest->write_mask >> i) & 1)<br>
             fprintf(fp, "%c", "xyzw"[i]);<br>
    }<br>
@@ -491,6 +491,7 @@ print_var_decl(nir_variable *var, print_state *state)<br>
       switch (var->data.mode) {<br>
       case nir_var_shader_in:<br>
       case nir_var_shader_out:<br>
+         assert(num_components <= 4);<br>
          if (num_components < 4 && num_components != 0) {<br>
             const char *xyzw = "xyzw";<br>
             for (int i = 0; i < num_components; i++)<br>
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c<br>
index 28b36b2b863..21fcbe7aaec 100644<br>
--- a/src/compiler/nir/nir_search.c<br>
+++ b/src/compiler/nir/nir_search.c<br>
@@ -41,7 +41,7 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,<br>
                  unsigned num_components, const uint8_t *swizzle,<br>
                  struct match_state *state);<br>
<br>
-static const uint8_t identity_swizzle[] = { 0, 1, 2, 3 };<br>
+static const uint8_t identity_swizzle[NIR_MAX_VEC_COMPONENTS] = { 0, 1, 2, 3 };<br>
<br>
 /**<br>
  * Check if a source produces a value of the given type.<br>
@@ -97,7 +97,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,<br>
             unsigned num_components, const uint8_t *swizzle,<br>
             struct match_state *state)<br>
 {<br>
-   uint8_t new_swizzle[4];<br>
+   uint8_t new_swizzle[NIR_MAX_VEC_COMPONENTS];<br>
<br>
    /* Searching only works on SSA values because, if it's not SSA, we can't<br>
     * know if the value changed between one instance of that value in the<br>
@@ -167,7 +167,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,<br>
          state->variables[var->variable].abs = false;<br>
          state->variables[var->variable].negate = false;<br>
<br>
-         for (unsigned i = 0; i < 4; ++i) {<br>
+         for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i) {<br>
             if (i < num_components)<br>
                state->variables[var->variable].swizzle[i] = new_swizzle[i];<br>
             else<br>
@@ -606,7 +606,7 @@ nir_alu_instr *<br>
 nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,<br>
                   const nir_search_value *replace, void *mem_ctx)<br>
 {<br>
-   uint8_t swizzle[4] = { 0, 0, 0, 0 };<br>
+   uint8_t swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 };<br>
<br>
    for (unsigned i = 0; i < instr->dest.dest.ssa.num_components; ++i)<br>
       swizzle[i] = i;<br>
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c<br>
index 7d7bf25436c..8e6f5bfb686 100644<br>
--- a/src/compiler/nir/nir_validate.c<br>
+++ b/src/compiler/nir/nir_validate.c<br>
@@ -230,9 +230,9 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state)<br>
<br>
    unsigned num_components = nir_src_num_components(src->src);<br>
    if (!src->src.is_ssa && src->src.reg.reg->is_packed)<br>
-      num_components = 4; /* can't check anything */<br>
-   for (unsigned i = 0; i < 4; i++) {<br>
-      validate_assert(state, src->swizzle[i] < 4);<br>
+      num_components = NIR_MAX_VEC_COMPONENTS; /* can't check anything */<br>
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {<br>
+      validate_assert(state, src->swizzle[i] < NIR_MAX_VEC_COMPONENTS);<br>
<br>
       if (nir_alu_instr_channel_used(instr, index, i))<br>
          validate_assert(state, src->swizzle[i] < num_components);<br>
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c<br>
index 48154303ff2..d778626420e 100644<br>
--- a/src/compiler/spirv/spirv_to_nir.c<br>
+++ b/src/compiler/spirv/spirv_to_nir.c<br>
@@ -3074,7 +3074,7 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,<br>
       unsigned elems = count - 3;<br>
       assume(elems >= 1);<br>
       if (glsl_type_is_vector_or_scalar(type)) {<br>
-         nir_ssa_def *srcs[4];<br>
+         nir_ssa_def *srcs[NIR_MAX_VEC_COMPONENTS];<br>
          for (unsigned i = 0; i < elems; i++)<br>
             srcs[i] = vtn_ssa_value(b, w[3 + i])->def;<br>
          val->ssa->def =<br>
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c<br>
index 5f9cc97fdfb..d7d17a825b7 100644<br>
--- a/src/compiler/spirv/vtn_alu.c<br>
+++ b/src/compiler/spirv/vtn_alu.c<br>
@@ -246,7 +246,7 @@ vtn_handle_bitcast(struct vtn_builder *b, struct vtn_ssa_value *dest,<br>
    unsigned dest_components = glsl_get_vector_elements(dest->type);<br>
    vtn_assert(src_bit_size * src_components == dest_bit_size * dest_components);<br>
<br>
-   nir_ssa_def *dest_chan[4];<br>
+   nir_ssa_def *dest_chan[NIR_MAX_VEC_COMPONENTS];<br>
    if (src_bit_size > dest_bit_size) {<br>
       vtn_assert(src_bit_size % dest_bit_size == 0);<br>
       unsigned divisor = src_bit_size / dest_bit_size;<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>