<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 5, 2017 at 9:08 AM, 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">El 30/11/17 a las 23:58, Jason Ekstrand escribió:<br>
<span class="">> On Wed, Nov 29, 2017 at 6:50 PM, 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>
> load_ubo is using 32-bit loads as uniforms surfaces have a 32-bit<br>
> surface format defined. So when reading 16-bit components with the<br>
> sampler we need to unshuffle two 16-bit components from each 32-bit<br>
> component.<br>
><br>
> Using the sampler avoids the use of the byte_scattered_read message<br>
> that needs one message for each component and is supposed to be<br>
> slower.<br>
><br>
> In the case of SKL+ we take advantage of a hardware feature that<br>
> automatically defines a channel mask based on the rlen value, so on<br>
> SKL+ we only use half of the registers without using a header in the<br>
> payload.<br>
> ---<br>
> src/intel/compiler/brw_fs.<wbr>cpp | 31<br>
> +++++++++++++++++++++++++++---<wbr>-<br>
> src/intel/compiler/brw_fs_<wbr>generator.cpp | 10 ++++++++--<br>
> 2 files changed, 35 insertions(+), 6 deletions(-)<br>
><br>
> diff --git a/src/intel/compiler/brw_fs.<wbr>cpp<br>
> b/src/intel/compiler/brw_fs.<wbr>cpp<br>
> index 1ca4d416b2..9c543496ba 100644<br>
> --- a/src/intel/compiler/brw_fs.<wbr>cpp<br>
> +++ b/src/intel/compiler/brw_fs.<wbr>cpp<br>
> @@ -184,9 +184,17 @@ fs_visitor::VARYING_PULL_<wbr>CONSTANT_LOAD(const<br>
> fs_builder &bld,<br>
> * a double this means we are only loading 2 elements worth of<br>
> data.<br>
> * We also want to use a 32-bit data type for the dst of the<br>
> load operation<br>
> * so other parts of the driver don't get confused about the<br>
> size of the<br>
> - * result.<br>
> + * result. On the case of 16-bit data we only need half of the<br>
> 32-bit<br>
> + * components on SKL+ as we take advance of using message<br>
> return size to<br>
> + * define an xy channel mask.<br>
> */<br>
> - fs_reg vec4_result = bld.vgrf(BRW_REGISTER_TYPE_F, 4);<br>
> + fs_reg vec4_result;<br>
> + if (type_sz(dst.type) == 2 && (devinfo->gen >= 9)) {<br>
> + vec4_result = bld.vgrf(BRW_REGISTER_TYPE_F, 2);<br>
> + vec4_result = retype(vec4_result, BRW_REGISTER_TYPE_HF);<br>
> + } else {<br>
> + vec4_result = bld.vgrf(BRW_REGISTER_TYPE_F, 4);<br>
> + }<br>
><br>
> fs_inst *inst =<br>
> bld.emit(FS_OPCODE_VARYING_<wbr>PULL_CONSTANT_LOAD_LOGICAL,<br>
> vec4_result, surf_index, vec4_offset);<br>
> inst->size_written = 4 *<br>
> vec4_result.component_size(<wbr>inst->exec_size);<br>
> @@ -197,8 +205,23 @@ fs_visitor::VARYING_PULL_<wbr>CONSTANT_LOAD(const<br>
> fs_builder &bld,<br>
> }<br>
><br>
> vec4_result.type = dst.type;<br>
> - bld.MOV(dst, offset(vec4_result, bld,<br>
> - (const_offset & 0xf) /<br>
> type_sz(vec4_result.type)));<br>
> +<br>
> + if (type_sz(dst.type) == 2) {<br>
> + /* 16-bit types need to be unshuffled as each pair of<br>
> 16-bit components<br>
> + * is packed on a 32-bit compoment because we are using a<br>
> 32-bit format<br>
> + * in the surface of uniform that is read by the sampler.<br>
> + * TODO: On BDW+ mark when an uniform has 16-bit type so we<br>
> could setup a<br>
> + * surface format of 16-bit and use the 16-bit return<br>
> format at the<br>
> + * sampler.<br>
> + */<br>
> + vec4_result.stride = 2;<br>
> + bld.MOV(dst, byte_offset(offset(vec4_<wbr>result, bld,<br>
> + (const_offset & 0x7) / 4),<br>
> + (const_offset & 0x7) / 2 % 2 * 2));<br>
> + } else {<br>
> + bld.MOV(dst, offset(vec4_result, bld,<br>
> + (const_offset & 0xf) /<br>
> type_sz(vec4_result.type)));<br>
> + }<br>
><br>
><br>
> This seems overly complicated. How about something like<br>
<br>
> fs_reg dw = offset(vec4_result, bld, (const_offset & 0xf) / 4);<br>
> switch (type_sz(dst.type)) {<br>
> case 2:<br>
> shuffle_32bit_load_result_to_<wbr>16bit_data(bld, dst, dw, 1);<br>
> bld.MOV(dst, subscript(dw, dst.type, (const_offset / 2) & 1));<br>
> break;<br>
> case 4:<br>
> bld.MOV(dst, dw);<br>
> break;<br>
> case 8:<br>
> shuffle_32bit_load_result_to_<wbr>64bit_data(bld, dst, dw, 1);<br>
> break;<br>
> default:<br>
> unreachable();<br>
> }<br>
<br>
</div></div>This implementation it is really more clear. Tested and works perfectly<br>
fine.<br>
<span class=""><br>
> <br>
><br>
> }<br>
><br>
> /**<br>
> diff --git a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> index a3861cd68e..00a4e29147 100644<br>
> --- a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> +++ b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> @@ -1381,12 +1381,18 @@<br>
> fs_generator::generate_<wbr>varying_pull_constant_load_<wbr>gen7(fs_inst *inst,<br>
> uint32_t simd_mode, rlen, mlen;<br>
> if (inst->exec_size == 16) {<br>
> mlen = 2;<br>
> - rlen = 8;<br>
> + if (type_sz(dst.type) == 2 && (devinfo->gen >= 9))<br>
> + rlen = 4;<br>
> + else<br>
> + rlen = 8;<br>
><br>
><br>
> I'm not sure what I think of this. We intentionally use a vec4 today<br>
> instead of a single float because it lets us potentially batch up a<br>
> bunch of loads in a single texture operation. Are we sure that we<br>
> never need more than 2 of those result registers?<br>
<br>
</span>I can drop this supposed "optimization", in this hunk and also the<br>
following lines. Maybe we could use the not read 3rd and 4th 32-bit<br>
components to read for example a consecutive pair of 16-bit vec4 in a<br>
matrix context.<br>
<br>
Removing this last hunks and with your previous code proposal, can I<br>
count with the R-b ? At the end the patch would be just reduced to your<br>
code ...<br></blockquote><div><br></div><div>Yup, fine with me. Or, if it just reduces to what I wrote above, you can re-author the patch and review it yourself. I don't care which.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chema<br>
<span class=""><br>
><br>
> --Jason<br>
><br>
> simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;<br>
> } else {<br>
> assert(inst->exec_size == 8);<br>
> mlen = 1;<br>
> - rlen = 4;<br>
> + if (type_sz(dst.type) == 2 && (devinfo->gen >= 9))<br>
> + rlen = 2;<br>
> + else<br>
> + rlen = 4;<br>
> simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;<br>
> }<br>
><br>
> --<br>
> 2.14.3<br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
</span>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.<wbr>freedesktop.org</a>><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> <<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.<wbr>org/mailman/listinfo/mesa-dev</a>><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">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/<wbr>mailman/listinfo/mesa-dev</a><br>
<br>
</div></div></blockquote></div><br></div></div>