<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 4, 2017 12:46, "Lionel Landwerlin" <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="quoted-text">
    <div class="m_4648571355982990874moz-cite-prefix">On 04/01/17 18:16, Jason Ekstrand
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="auto">
        <div>
          <div class="gmail_extra">
            <div class="gmail_quote">On Jan 4, 2017 12:02, "Lionel
              Landwerlin" <<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a><wbr>>
              wrote:<br type="attribution">
              <blockquote class="m_4648571355982990874quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v2:
                Move relative push constant relative offset computation
                down to<br>
                    _vtn_load_store_tail() (Jason)<br>
              </blockquote>
            </div>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Hm... I may not have been particularly clear. I
          meant, more or less, to have get_io_offset (is that what its
          called?) return the offer in terms of base, offset, and range
          like the push constant intrinsic expects and then, for
          everything else, do an add to combine the base and indirect
          parts.  Does that make sense?  There's even a comment in there
          about how I was lazy and just trusted constant folding before.</div>
      </div>
    </blockquote>
    <br></div>
    I'm afraid I don't follow :(<br>
    You would like to get this as a nir pass?<br></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Go ahead and merge this or the previous version with my rb and I'll look into it layer.  I'm not even sure if my idea will be feasible.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    <blockquote type="cite"><div class="elided-text">
      <div dir="auto">
        <div dir="auto"><br>
        </div>
        <div dir="auto">
          <div class="gmail_extra">
            <div class="gmail_quote">
              <blockquote class="m_4648571355982990874quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div class="m_4648571355982990874quoted-text"><br>
                  Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a><wbr>><br>
                  ---<br>
                </div>
                 src/compiler/spirv/vtn_variab<wbr>les.c              |
                78 ++++++++++++++++++++-----<br>
                 src/intel/vulkan/anv_nir_lowe<wbr>r_push_constants.c | 
                1 -<br>
                 2 files changed, 65 insertions(+), 14 deletions(-)<br>
                <br>
                diff --git a/src/compiler/spirv/vtn_varia<wbr>bles.c
                b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
                index 040c65061c..e3845365bd 100644<br>
                --- a/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
                +++ b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
                @@ -434,8 +434,37 @@ vtn_type_block_size(struct vtn_type
                *type)<br>
                <div class="m_4648571355982990874elided-text"> }<br>
                  <br>
                   static void<br>
                  +vtn_access_chain_get_offset_s<wbr>ize(struct
                  vtn_access_chain *chain,<br>
                  +                                 unsigned
                  *access_offset,<br>
                  +                                 unsigned
                  *access_size)<br>
                  +{<br>
                  +   /* Only valid for push constants accesses now. */<br>
                  +   assert(chain->var->mode ==
                  vtn_variable_mode_push_constan<wbr>t);<br>
                  +<br>
                  +   struct vtn_type *type = chain->var->type;<br>
                  +<br>
                  +   *access_offset = 0;<br>
                  +<br>
                  +   for (unsigned i = 0; i < chain->length; i++)
                  {<br>
                  +      if (chain->link[i].mode !=
                  vtn_access_mode_literal)<br>
                  +         break;<br>
                  +<br>
                  +      if (glsl_type_is_struct(type->typ<wbr>e)) {<br>
                  +         *access_offset +=
                  type->offsets[chain->link[i].i<wbr>d];<br>
                  +         type = type->members[chain->link[i].i<wbr>d];<br>
                  +      } else {<br>
                  +         *access_offset += type->stride *
                  chain->link[i].id;<br>
                  +         type = type->array_element;<br>
                  +      }<br>
                  +   }<br>
                  +<br>
                  +   *access_size = vtn_type_block_size(type);<br>
                  +}<br>
                  +<br>
                  +static void<br>
                   _vtn_load_store_tail(struct vtn_builder *b,
                  nir_intrinsic_op op, bool load,<br>
                                        nir_ssa_def *index, nir_ssa_def
                  *offset,<br>
                </div>
                <div class="m_4648571355982990874quoted-text">+                     unsigned
                  access_offset, unsigned access_size,<br>
                </div>
                <div class="m_4648571355982990874quoted-text">                      struct
                  vtn_ssa_value **inout, const struct glsl_type *type)<br>
                </div>
                <div class="m_4648571355982990874quoted-text"> {<br>
                      nir_intrinsic_instr *instr =
                  nir_intrinsic_instr_create(b-><wbr>nb.shader, op);<br>
                </div>
                @@ -447,18 +476,25 @@ _vtn_load_store_tail(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">       instr->src[src++] =
                  nir_src_for_ssa((*inout)->def)<wbr>;<br>
                      }<br>
                  <br>
                  -   /* We set the base and size for push constant load
                  to the entire push<br>
                  -    * constant block for now.<br>
                  -    */<br>
                      if (op == nir_intrinsic_load_push_consta<wbr>nt) {<br>
                  -      nir_intrinsic_set_base(instr, 0);<br>
                  -      nir_intrinsic_set_range(instr, 128);<br>
                  +      assert(access_offset % 4 == 0);<br>
                  +<br>
                  +      nir_intrinsic_set_base(instr, access_offset);<br>
                  +      nir_intrinsic_set_range(instr, access_size);<br>
                      }<br>
                  <br>
                      if (index)<br>
                </div>
                       instr->src[src++] = nir_src_for_ssa(index);<br>
                <br>
                -   instr->src[src++] = nir_src_for_ssa(offset);<br>
                +   if (op == nir_intrinsic_load_push_consta<wbr>nt) {<br>
                <div class="m_4648571355982990874quoted-text">+      /* We need to subtract
                  the offset from where the intrinsic will load the<br>
                  +       * data. */<br>
                </div>
                +      instr->src[src++] =<br>
                +         nir_src_for_ssa(nir_isub(&b-><wbr>nb,
                offset,<br>
                +                                 
                nir_imm_int(&b->nb, access_offset)));<br>
                +   } else {<br>
                +      instr->src[src++] = nir_src_for_ssa(offset);<br>
                +   }<br>
                <br>
                    if (load) {<br>
                       nir_ssa_dest_init(&instr->ins<wbr>tr,
                &instr->dest,<br>
                @@ -476,6 +512,7 @@ _vtn_load_store_tail(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text"> static void<br>
                   _vtn_block_load_store(struct vtn_builder *b,
                  nir_intrinsic_op op, bool load,<br>
                                         nir_ssa_def *index, nir_ssa_def
                  *offset,<br>
                  +                      unsigned access_offset,
                  unsigned access_size,<br>
                                         struct vtn_access_chain *chain,
                  unsigned chain_idx,<br>
                                         struct vtn_type *type, struct
                  vtn_ssa_value **inout)<br>
                   {<br>
                </div>
                @@ -520,6 +557,7 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">                 
                   nir_iadd(&b->nb, offset,<br>
                                              nir_imm_int(&b->nb,
                  i * type->stride));<br>
                </div>
                <div class="m_4648571355982990874quoted-text">               
                  _vtn_load_store_tail(b, op, load, index, elem_offset,<br>
                </div>
                +                                    access_offset,
                access_size,<br>
                                                   
                 &(*inout)->elems[i],<br>
                                                   
                 glsl_vector_type(base_type, vec_width));<br>
                             }<br>
                @@ -541,8 +579,9 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                                offset = nir_iadd(&b->nb, offset,
                row_offset);<br>
                <div class="m_4648571355982990874quoted-text">                if (load)<br>
                                     *inout = vtn_create_ssa_value(b,
                  glsl_scalar_type(base_type));<br>
                </div>
                <div class="m_4648571355982990874quoted-text">-             
                   _vtn_load_store_tail(b, op, load, index, offset,
                  inout,<br>
                </div>
                -                                   
                glsl_scalar_type(base_type));<br>
                <div class="m_4648571355982990874quoted-text">+             
                   _vtn_load_store_tail(b, op, load, index, offset,<br>
                </div>
                +                                    access_offset,
                access_size,<br>
                +                                    inout,
                glsl_scalar_type(base_type));<br>
                <div class="m_4648571355982990874quoted-text">             } else {<br>
                                  /* Grabbing a column; picking one
                  element off each row */<br>
                                  unsigned num_comps =
                  glsl_get_vector_elements(type-<wbr>>type);<br>
                </div>
                @@ -562,6 +601,7 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">                   }<br>
                                     comp = &temp_val;<br>
                                     _vtn_load_store_tail(b, op, load,
                  index, elem_offset,<br>
                </div>
                +                                       access_offset,
                access_size,<br>
                                                        &comp,
                glsl_scalar_type(base_type));<br>
                <div class="m_4648571355982990874quoted-text">                   comps[i] =
                  comp->def;<br>
                                  }<br>
                </div>
                @@ -580,20 +620,25 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">             offset =
                  nir_iadd(&b->nb, offset, col_offset);<br>
                  <br>
                               _vtn_block_load_store(b, op, load, index,
                  offset,<br>
                  +                                  access_offset,
                  access_size,<br>
                                                     chain, chain_idx +
                  1,<br>
                                                   
                   type->array_element, inout);<br>
                            }<br>
                         } else if (chain == NULL) {<br>
                            /* Single whole vector */<br>
                            assert(glsl_type_is_vector_or_<wbr>scalar(type->type));<br>
                  -         _vtn_load_store_tail(b, op, load, index,
                  offset, inout, type->type);<br>
                  +         _vtn_load_store_tail(b, op, load, index,
                  offset,<br>
                </div>
                +                              access_offset,
                access_size,<br>
                +                              inout, type->type);<br>
                <div class="m_4648571355982990874quoted-text">       } else {<br>
                            /* Single component of a vector. Fall
                  through to array case. */<br>
                            nir_ssa_def *elem_offset =<br>
                               vtn_access_link_as_ssa(b,
                  chain->link[chain_idx], type->stride);<br>
                            offset = nir_iadd(&b->nb, offset,
                  elem_offset);<br>
                  <br>
                  -         _vtn_block_load_store(b, op, load, index,
                  offset, NULL, 0,<br>
                  +         _vtn_block_load_store(b, op, load, index,
                  offset,<br>
                  +                               access_offset,
                  access_size,<br>
                  +                               NULL, 0,<br>
                                                 
                  type->array_element, inout);<br>
                         }<br>
                         return;<br>
                </div>
                @@ -603,7 +648,9 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">       for (unsigned i = 0; i
                  < elems; i++) {<br>
                            nir_ssa_def *elem_off =<br>
                               nir_iadd(&b->nb, offset,
                  nir_imm_int(&b->nb, i * type->stride));<br>
                  -         _vtn_block_load_store(b, op, load, index,
                  elem_off, NULL, 0,<br>
                  +         _vtn_block_load_store(b, op, load, index,
                  elem_off,<br>
                  +                               access_offset,
                  access_size,<br>
                  +                               NULL, 0,<br>
                                                 
                  type->array_element, &(*inout)->elems[i]);<br>
                         }<br>
                         return;<br>
                </div>
                @@ -614,7 +661,9 @@ _vtn_block_load_store(struct
                vtn_builder *b, nir_intrinsic_op op, bool load,<br>
                <div class="m_4648571355982990874quoted-text">       for (unsigned i = 0; i
                  < elems; i++) {<br>
                            nir_ssa_def *elem_off =<br>
                               nir_iadd(&b->nb, offset,
                  nir_imm_int(&b->nb, type->offsets[i]));<br>
                  -         _vtn_block_load_store(b, op, load, index,
                  elem_off, NULL, 0,<br>
                  +         _vtn_block_load_store(b, op, load, index,
                  elem_off,<br>
                  +                               access_offset,
                  access_size,<br>
                  +                               NULL, 0,<br>
                                                  type->members[i],
                  &(*inout)->elems[i]);<br>
                         }<br>
                         return;<br>
                </div>
                @@ -629,6 +678,7 @@ static struct vtn_ssa_value *<br>
                <div class="m_4648571355982990874quoted-text"> vtn_block_load(struct
                  vtn_builder *b, struct vtn_access_chain *src)<br>
                   {<br>
                </div>
                <div class="m_4648571355982990874quoted-text">    nir_intrinsic_op op;<br>
                  +   unsigned access_offset = 0, access_size = 0;<br>
                      switch (src->var->mode) {<br>
                      case vtn_variable_mode_ubo:<br>
                         op = nir_intrinsic_load_ubo;<br>
                </div>
                @@ -638,6 +688,7 @@ vtn_block_load(struct vtn_builder
                *b, struct vtn_access_chain *src)<br>
                <div class="m_4648571355982990874quoted-text">       break;<br>
                      case vtn_variable_mode_push_constan<wbr>t:<br>
                         op = nir_intrinsic_load_push_consta<wbr>nt;<br>
                  +      vtn_access_chain_get_offset_si<wbr>ze(src,
                  &access_offset, &access_size);<br>
                </div>
                <div class="m_4648571355982990874quoted-text">       break;<br>
                      default:<br>
                         assert(!"Invalid block variable mode");<br>
                </div>
                @@ -650,6 +701,7 @@ vtn_block_load(struct vtn_builder
                *b, struct vtn_access_chain *src)<br>
                <div class="m_4648571355982990874quoted-text"><br>
                      struct vtn_ssa_value *value = NULL;<br>
                      _vtn_block_load_store(b, op, true, index, offset,<br>
                  +                         access_offset, access_size,<br>
                                            src, chain_idx, type,
                  &value);<br>
                      return value;<br>
                   }<br>
                </div>
                @@ -664,7 +716,7 @@ vtn_block_store(struct vtn_builder
                *b, struct vtn_ssa_value *src,<br>
                <div class="m_4648571355982990874elided-text">    offset =
                  vtn_access_chain_to_offset(b, dst, &index,
                  &type, &chain_idx, true);<br>
                  <br>
                      _vtn_block_load_store(b, nir_intrinsic_store_ssbo,
                  false, index, offset,<br>
                  -                         dst, chain_idx, type,
                  &src);<br>
                  +                         0, 0, dst, chain_idx, type,
                  &src);<br>
                   }<br>
                  <br>
                   static bool<br>
                  diff --git a/src/intel/vulkan/anv_nir_low<wbr>er_push_constants.c
                  b/src/intel/vulkan/anv_nir_low<wbr>er_push_constants.c<br>
                  index 64c155372f..b66552825b 100644<br>
                  --- a/src/intel/vulkan/anv_nir_low<wbr>er_push_constants.c<br>
                  +++ b/src/intel/vulkan/anv_nir_low<wbr>er_push_constants.c<br>
                  @@ -42,7 +42,6 @@ anv_nir_lower_push_constants(n<wbr>ir_shader
                  *shader)<br>
                                  continue;<br>
                  <br>
                               assert(intrin->const_index[0] % 4 ==
                  0);<br>
                  -            assert(intrin->const_index[1] == 128);<br>
                  <br>
                               /* We just turn them into uniform loads
                  */<br>
                               intrin->intrinsic =
                  nir_intrinsic_load_uniform;<br>
                  --<br>
                  2.11.0<br>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="m_4648571355982990874mimeAttachmentHeader"></fieldset>
      <br>
      </div><div class="quoted-text"><pre>______________________________<wbr>_________________
mesa-dev mailing list
<a class="m_4648571355982990874moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a>
<a class="m_4648571355982990874moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a>
</pre>
    </div></blockquote>
    <p><br>
    </p>
  </div>

</blockquote></div><br></div></div></div>