<div dir="ltr"><div>Sagar reminded me via his MSR that this patch series never landed. Everything got reviewed by Ian except this patch which he only acked. Would someone mind doing a more proper review? This seemed like the wrong patch to push with just an ack.</div><div><br></div><div>--Jason<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 11, 2018 at 4:33 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We have to lower some shadow instructions because they don't exist in<br>
hardware and we have to lower txb+offset+clamp because the message gets<br>
too big and we run into the sampler message length limit of 11 regs.<br>
---<br>
src/intel/compiler/brw_eu_defines.h | 2 ++<br>
src/intel/compiler/brw_fs.cpp | 22 +++++++++++++++++++++-<br>
src/intel/compiler/brw_fs_nir.cpp | 6 +++++-<br>
src/intel/compiler/brw_nir.c | 3 +++<br>
4 files changed, 31 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_eu_defines.h b/src/intel/compiler/brw_eu_defines.h<br>
index 52957882b10..affe977835b 100644<br>
--- a/src/intel/compiler/brw_eu_defines.h<br>
+++ b/src/intel/compiler/brw_eu_defines.h<br>
@@ -811,6 +811,8 @@ enum tex_logical_srcs {<br>
TEX_LOGICAL_SRC_LOD,<br>
/** dPdy if the operation takes explicit derivatives */<br>
TEX_LOGICAL_SRC_LOD2,<br>
+ /** Min LOD */<br>
+ TEX_LOGICAL_SRC_MIN_LOD,<br>
/** Sample index */<br>
TEX_LOGICAL_SRC_SAMPLE_INDEX,<br>
/** MCS data */<br>
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp<br>
index 23a25fedca5..a09451249d8 100644<br>
--- a/src/intel/compiler/brw_fs.cpp<br>
+++ b/src/intel/compiler/brw_fs.cpp<br>
@@ -4472,6 +4472,7 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
const fs_reg &coordinate,<br>
const fs_reg &shadow_c,<br>
fs_reg lod, const fs_reg &lod2,<br>
+ const fs_reg &min_lod,<br>
const fs_reg &sample_index,<br>
const fs_reg &mcs,<br>
const fs_reg &surface,<br>
@@ -4682,6 +4683,15 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
bld.MOV(sources[length++], offset(coordinate, bld, i));<br>
}<br>
<br>
+ if (min_lod.file != BAD_FILE) {<br>
+ /* Account for all of the missing coordinate sources */<br>
+ length += 4 - coord_components;<br>
+ if (op == SHADER_OPCODE_TXD)<br>
+ length += (3 - grad_components) * 2;<br>
+<br>
+ bld.MOV(sources[length++], min_lod);<br>
+ }<br>
+<br>
int mlen;<br>
if (reg_width == 2)<br>
mlen = length * reg_width - header_size;<br>
@@ -4713,6 +4723,7 @@ lower_sampler_logical_send(const fs_builder &bld, fs_inst *inst, opcode op)<br>
const fs_reg &shadow_c = inst->src[TEX_LOGICAL_SRC_SHADOW_C];<br>
const fs_reg &lod = inst->src[TEX_LOGICAL_SRC_LOD];<br>
const fs_reg &lod2 = inst->src[TEX_LOGICAL_SRC_LOD2];<br>
+ const fs_reg &min_lod = inst->src[TEX_LOGICAL_SRC_MIN_LOD];<br>
const fs_reg &sample_index = inst->src[TEX_LOGICAL_SRC_SAMPLE_INDEX];<br>
const fs_reg &mcs = inst->src[TEX_LOGICAL_SRC_MCS];<br>
const fs_reg &surface = inst->src[TEX_LOGICAL_SRC_SURFACE];<br>
@@ -4725,7 +4736,8 @@ lower_sampler_logical_send(const fs_builder &bld, fs_inst *inst, opcode op)<br>
<br>
if (devinfo->gen >= 7) {<br>
lower_sampler_logical_send_gen7(bld, inst, op, coordinate,<br>
- shadow_c, lod, lod2, sample_index,<br>
+ shadow_c, lod, lod2, min_lod,<br>
+ sample_index,<br>
mcs, surface, sampler, tg4_offset,<br>
coord_components, grad_components);<br>
} else if (devinfo->gen >= 5) {<br>
@@ -5262,6 +5274,14 @@ static unsigned<br>
get_sampler_lowered_simd_width(const struct gen_device_info *devinfo,<br>
const fs_inst *inst)<br>
{<br>
+ /* If we have a min_lod parameter on anything other than a simple sample<br>
+ * message, it will push it over 5 arguments and we have to fall back to<br>
+ * SIMD8.<br>
+ */<br>
+ if (inst->opcode != SHADER_OPCODE_TEX &&<br>
+ inst->components_read(TEX_LOGICAL_SRC_MIN_LOD))<br>
+ return 8;<br>
+<br>
/* Calculate the number of coordinate components that have to be present<br>
* assuming that additional arguments follow the texel coordinates in the<br>
* message payload. On IVB+ there is no need for padding, on ILK-SNB we<br>
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp<br>
index 7930205d659..6862abf80bb 100644<br>
--- a/src/intel/compiler/brw_fs_nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_nir.cpp<br>
@@ -3079,7 +3079,7 @@ fs_visitor::emit_non_coherent_fb_read(const fs_builder &bld, const fs_reg &dst,<br>
<br>
/* Emit the instruction. */<br>
const fs_reg srcs[] = { coords, fs_reg(), brw_imm_ud(0), fs_reg(),<br>
- sample, mcs,<br>
+ fs_reg(), sample, mcs,<br>
brw_imm_ud(surface), brw_imm_ud(0),<br>
fs_reg(), brw_imm_ud(3), brw_imm_ud(0) };<br>
STATIC_ASSERT(ARRAY_SIZE(srcs) == TEX_LOGICAL_NUM_SRCS);<br>
@@ -5072,6 +5072,10 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)<br>
break;<br>
}<br>
break;<br>
+ case nir_tex_src_min_lod:<br>
+ srcs[TEX_LOGICAL_SRC_MIN_LOD] =<br>
+ retype(get_nir_src_imm(instr->src[i].src), BRW_REGISTER_TYPE_F);<br>
+ break;<br>
case nir_tex_src_ms_index:<br>
srcs[TEX_LOGICAL_SRC_SAMPLE_INDEX] = retype(src, BRW_REGISTER_TYPE_UD);<br>
break;<br>
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c<br>
index f61baee230a..576140e060a 100644<br>
--- a/src/intel/compiler/brw_nir.c<br>
+++ b/src/intel/compiler/brw_nir.c<br>
@@ -655,6 +655,9 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)<br>
.lower_txf_offset = true,<br>
.lower_rect_offset = true,<br>
.lower_txd_cube_map = true,<br>
+ .lower_txb_shadow_clamp = true,<br>
+ .lower_txd_shadow_clamp = true,<br>
+ .lower_txd_offset_clamp = true,<br>
};<br>
<br>
OPT(nir_lower_tex, &tex_options);<br>
-- <br>
2.19.1<br>
<br>
</blockquote></div>