<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 1, 2018 at 12:38 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> writes:<br>
<br>
> This gives the scheduler visibility into the headers which should<br>
> improve scheduling. More importantly, however, it lets the scheduler<br>
> know that the header gets written. As-is, the scheduler thinks that a<br>
> texture instruction only reads it's payload and is unaware that it may<br>
> write to the first register so it may reorder it with respect to a read<br>
> from that register. This is causing issues in a couple of Dota 2 vertex<br>
> shaders.<br>
><br>
<br>
</span>Yikes... Corrupting your GRF since 2012... Render target writes<br>
probably need a similar treatment.<span class=""><br></span></blockquote><div><br></div><div>Yeah... It all needs a similar treatment. :-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=104923" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104923</a><br>
> Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
<br>
</span>Reviewed-by: Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>><br><div><div class="h5"></div></div></blockquote><div><br></div><div>Thanks!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> ---<br>
> src/intel/compiler/brw_fs.cpp | 40 +++++++++++++++++++++++++++++-<wbr>---<br>
> src/intel/compiler/brw_fs_<wbr>generator.cpp | 21 +++--------------<br>
> 2 files changed, 39 insertions(+), 22 deletions(-)<br>
><br>
> diff --git a/src/intel/compiler/brw_fs.<wbr>cpp b/src/intel/compiler/brw_fs.<wbr>cpp<br>
> index 113f62c..ab8cc89 100644<br>
> --- a/src/intel/compiler/brw_fs.<wbr>cpp<br>
> +++ b/src/intel/compiler/brw_fs.<wbr>cpp<br>
> @@ -4192,17 +4192,15 @@ lower_sampler_logical_send_<wbr>gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
> op == SHADER_OPCODE_SAMPLEINFO ||<br>
> is_high_sampler(devinfo, sampler)) {<br>
> /* For general texture offsets (no txf workaround), we need a header to<br>
> - * put them in. Note that we're only reserving space for it in the<br>
> - * message payload as it will be initialized implicitly by the<br>
> - * generator.<br>
> + * put them in.<br>
> *<br>
> * TG4 needs to place its channel select in the header, for interaction<br>
> * with ARB_texture_swizzle. The sampler index is only 4-bits, so for<br>
> * larger sampler numbers we need to offset the Sampler State Pointer in<br>
> * the header.<br>
> */<br>
> + fs_reg header = retype(sources[0], BRW_REGISTER_TYPE_UD);<br>
> header_size = 1;<br>
> - sources[0] = fs_reg();<br>
> length++;<br>
><br>
> /* If we're requesting fewer than four channels worth of response,<br>
> @@ -4214,6 +4212,40 @@ lower_sampler_logical_send_<wbr>gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
> unsigned mask = ~((1 << (regs_written(inst) / reg_width)) - 1) & 0xf;<br>
> inst->offset |= mask << 12;<br>
> }<br>
> +<br>
> + /* Build the actual header */<br>
> + const fs_builder ubld = bld.exec_all().group(8, 0);<br>
> + const fs_builder ubld1 = ubld.group(1, 0);<br>
> + ubld.MOV(header, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));<br>
> + if (inst->offset) {<br>
> + ubld1.MOV(component(header, 2), brw_imm_ud(inst->offset));<br>
> + } else if (bld.shader->stage != MESA_SHADER_VERTEX &&<br>
> + bld.shader->stage != MESA_SHADER_FRAGMENT) {<br>
> + /* The vertex and fragment stages have g0.2 set to 0, so<br>
> + * header0.2 is 0 when g0 is copied. Other stages may not, so we<br>
> + * must set it to 0 to avoid setting undesirable bits in the<br>
> + * message.<br>
> + */<br>
> + ubld1.MOV(component(header, 2), brw_imm_ud(0));<br>
> + }<br>
> +<br>
> + if (is_high_sampler(devinfo, sampler)) {<br>
> + if (sampler.file == BRW_IMMEDIATE_VALUE) {<br>
> + assert(sampler.ud >= 16);<br>
> + const int sampler_state_size = 16; /* 16 bytes */<br>
> +<br>
> + ubld1.ADD(component(header, 3),<br>
> + retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD),<br>
> + brw_imm_ud(16 * (sampler.ud / 16) * sampler_state_size));<br>
> + } else {<br>
> + fs_reg tmp = ubld1.vgrf(BRW_REGISTER_TYPE_<wbr>UD);<br>
> + ubld1.AND(tmp, sampler, brw_imm_ud(0x0f0));<br>
> + ubld1.SHL(tmp, tmp, brw_imm_ud(4));<br>
> + ubld1.ADD(component(header, 3),<br>
> + retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD),<br>
> + tmp);<br>
> + }<br>
> + }<br>
> }<br>
><br>
> if (shadow_c.file != BAD_FILE) {<br>
> diff --git a/src/intel/compiler/brw_fs_<wbr>generator.cpp b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> index b59c09f..a5a821a 100644<br>
> --- a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> +++ b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
> @@ -1001,19 +1001,13 @@ fs_generator::generate_tex(fs_<wbr>inst *inst, struct brw_reg dst, struct brw_reg src<br>
> * we need to set it up explicitly and load the offset bitfield.<br>
> * Otherwise, we can use an implied move from g0 to the first message reg.<br>
> */<br>
> - if (inst->header_size != 0) {<br>
> + if (inst->header_size != 0 && devinfo->gen < 7) {<br>
> if (devinfo->gen < 6 && !inst->offset) {<br>
> /* Set up an implied move from g0 to the MRF. */<br>
> src = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);<br>
> } else {<br>
> - struct brw_reg header_reg;<br>
> -<br>
> - if (devinfo->gen >= 7) {<br>
> - header_reg = src;<br>
> - } else {<br>
> - assert(inst->base_mrf != -1);<br>
> - header_reg = brw_message_reg(inst->base_<wbr>mrf);<br>
> - }<br>
> + assert(inst->base_mrf != -1);<br>
> + struct brw_reg header_reg = brw_message_reg(inst->base_<wbr>mrf);<br>
><br>
> brw_push_insn_state(p);<br>
> brw_set_default_exec_size(p, BRW_EXECUTE_8);<br>
> @@ -1027,17 +1021,8 @@ fs_generator::generate_tex(fs_<wbr>inst *inst, struct brw_reg dst, struct brw_reg src<br>
> /* Set the offset bits in DWord 2. */<br>
> brw_MOV(p, get_element_ud(header_reg, 2),<br>
> brw_imm_ud(inst->offset));<br>
> - } else if (stage != MESA_SHADER_VERTEX &&<br>
> - stage != MESA_SHADER_FRAGMENT) {<br>
> - /* The vertex and fragment stages have g0.2 set to 0, so<br>
> - * header0.2 is 0 when g0 is copied. Other stages may not, so we<br>
> - * must set it to 0 to avoid setting undesirable bits in the<br>
> - * message.<br>
> - */<br>
> - brw_MOV(p, get_element_ud(header_reg, 2), brw_imm_ud(0));<br>
> }<br>
><br>
> - brw_adjust_sampler_state_<wbr>pointer(p, header_reg, sampler_index);<br>
> brw_pop_insn_state(p);<br>
> }<br>
> }<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> mesa-stable mailing list<br>
> <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-stable" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-stable</a><br>
</blockquote></div><br></div></div>