<div dir="ltr"><div>Assuming the CTS is still happy with it after those changes,<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 23, 2018 at 1:16 PM, Chema Casanova <span dir="ltr"><<a href="mailto:jmcasanova@igalia.com" target="_blank">jmcasanova@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 23/02/18 20:09, Jason Ekstrand wrote:<br>
> On Fri, Feb 23, 2018 at 1:26 AM, Jose Maria Casanova Crespo<br>
</span><div><div class="h5">> <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a> <mailto:<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><wbr>> wrote:<br>
><br>
>     The introduction of 16-bit types with VK_KHR_16bit_storages implies that<br>
>     push constant offsets could be multiple of 2-bytes. Some assertions are<br>
>     relaxed so offsets can be multiple of 4-bytes or multiple of size of the<br>
>     base type.<br>
><br>
>     For 16-bit types, the push constant offset takes into account the<br>
>     internal offset in the 32-bit uniform bucket adding 2-bytes when we<br>
>     access<br>
>     not 32-bit aligned elements. In all 32-bit aligned cases it just<br>
>     becomes 0.<br>
>     ---<br>
>      src/compiler/spirv/vtn_<wbr>variables.c              |  1 -<br>
>      src/intel/compiler/brw_fs_<wbr>nir.cpp               | 16 +++++++++++-----<br>
>      src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c |  2 --<br>
>      3 files changed, 11 insertions(+), 8 deletions(-)<br>
><br>
>     diff --git a/src/compiler/spirv/vtn_<wbr>variables.c<br>
>     b/src/compiler/spirv/vtn_<wbr>variables.c<br>
>     index 81658afbd9..87236d0abd 100644<br>
>     --- a/src/compiler/spirv/vtn_<wbr>variables.c<br>
>     +++ b/src/compiler/spirv/vtn_<wbr>variables.c<br>
>     @@ -760,7 +760,6 @@ _vtn_load_store_tail(struct vtn_builder *b,<br>
>     nir_intrinsic_op op, bool load,<br>
>         }<br>
><br>
>         if (op == nir_intrinsic_load_push_<wbr>constant) {<br>
>     -      vtn_assert(access_offset % 4 == 0);<br>
><br>
>            nir_intrinsic_set_base(instr, access_offset);<br>
>            nir_intrinsic_set_range(<wbr>instr, access_size);<br>
>     diff --git a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
>     b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
>     index abf9098252..27611a21d0 100644<br>
>     --- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
>     +++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
>     @@ -3887,16 +3887,22 @@ fs_visitor::nir_emit_<wbr>intrinsic(const<br>
>     fs_builder &bld, nir_intrinsic_instr *instr<br>
>            break;<br>
><br>
>         case nir_intrinsic_load_uniform: {<br>
>     -      /* Offsets are in bytes but they should always be multiples<br>
>     of 4 */<br>
>     -      assert(instr->const_index[0] % 4 == 0);<br>
>     +      /* Offsets are in bytes but they should always be multiple of 4<br>
>     +       * or multiple of the size of the destination type. 2 for 16-bits<br>
>     +       * types.<br>
><br>
>     +       */<br>
>     +      assert(instr->const_index[0] % 4 == 0 ||<br>
>     +             instr->const_index[0] % type_sz(dest.type) == 0);<br>
><br>
><br>
> Doubles are required to be 8-byte aligned so we can just have the dest<br>
> type size check.<br>
<br>
</div></div>Changed locally.<br>
<span class=""><br>
>  <br>
><br>
>            fs_reg src(UNIFORM, instr->const_index[0] / 4, dest.type);<br>
><br>
>            nir_const_value *const_offset =<br>
>     nir_src_as_const_value(instr-><wbr>src[0]);<br>
>            if (const_offset) {<br>
>     -         /* Offsets are in bytes but they should always be<br>
>     multiples of 4 */<br>
>     -         assert(const_offset->u32[0] % 4 == 0);<br>
>     -         src.offset = const_offset->u32[0];<br>
>     +         assert(const_offset->u32[0] % 4 == 0 ||<br>
>     +                const_offset->u32[0] % type_sz(dest.type) == 0);<br>
><br>
><br>
> Same here.<br>
<br>
</span>Changed locally.<br>
<div class="HOEnZb"><div class="h5"><br>
>     +         /* For 16-bit types we add the module of the const_index[0]<br>
>     +          * offset to access to not 32-bit aligned element */<br>
>     +         src.offset = const_offset->u32[0] + instr->const_index[0] % 4;<br>
><br>
>               for (unsigned j = 0; j < instr->num_components; j++) {<br>
>                  bld.MOV(offset(dest, bld, j), offset(src, bld, j));<br>
>     diff --git a/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
>     b/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
>     index b66552825b..ad60d0c824 100644<br>
>     --- a/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
>     +++ b/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
>     @@ -41,8 +41,6 @@ anv_nir_lower_push_constants(<wbr>nir_shader *shader)<br>
>                  if (intrin->intrinsic != nir_intrinsic_load_push_<wbr>constant)<br>
>                     continue;<br>
><br>
>     -            assert(intrin->const_index[0] % 4 == 0);<br>
>     -<br>
>                  /* We just turn them into uniform loads */<br>
>                  intrin->intrinsic = nir_intrinsic_load_uniform;<br>
>               }<br>
>     --<br>
>     2.14.3<br>
><br>
><br>
</div></div></blockquote></div><br></div>