<p dir="ltr"><br>
On Nov 25, 2015 4:18 PM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> On Tuesday, November 03, 2015 01:26:04 PM Jason Ekstrand wrote:<br>
> > ---<br>
> > src/mesa/drivers/dri/i965/brw_vec4.h | 4 +++-<br>
> > src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 27 ++++++++++++++++++--------<br>
> > src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 12 ++++++++----<br>
> > 3 files changed, 30 insertions(+), 13 deletions(-)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
> > index ec8abf4..52d68c5 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_vec4.h<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
> > @@ -273,9 +273,11 @@ public:<br>
> > src_reg offset_value,<br>
> > src_reg mcs,<br>
> > bool is_cube_array,<br>
> > + uint32_t surface, src_reg surface_reg,<br>
> > uint32_t sampler, src_reg sampler_reg);<br>
> ><br>
> > - uint32_t gather_channel(unsigned gather_component, uint32_t sampler);<br>
> > + uint32_t gather_channel(unsigned gather_component,<br>
> > + uint32_t surface, uint32_t sampler);<br>
> > src_reg emit_mcs_fetch(const glsl_type *coordinate_type, src_reg coordinate,<br>
> > src_reg sampler);<br>
> > void emit_gen6_gather_wa(uint8_t wa, dst_reg dst);<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > index 7a6372b..86e3dec 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > @@ -1585,7 +1585,9 @@ glsl_type_for_nir_alu_type(nir_alu_type alu_type,<br>
> > void<br>
> > vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> > {<br>
> > + unsigned texture = instr->texture_index;<br>
><br>
> Here you call it texture, later in gather_channel() you call it surface.<br>
><br>
> I kind of prefer surface, though I suppose it's not the actual binding<br>
> table index, but rather a texture unit number. *shrug* We should<br>
> probably be consistent though? (I don't feel too strongly though.)</p>
<p dir="ltr">Yeah. Texture seemed better from a GL point of view but surface seemed better in the back end. I can rename it all texture if you'd like.</p>
<p dir="ltr">> > unsigned sampler = instr->sampler_index;<br>
> > + src_reg texture_reg = src_reg(texture);<br>
> > src_reg sampler_reg = src_reg(sampler);<br>
> > src_reg coordinate;<br>
> > const glsl_type *coord_type = NULL;<br>
> > @@ -1666,8 +1668,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> > sample_index = get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 1);<br>
> > assert(coord_type != NULL);<br>
> > if (devinfo->gen >= 7 &&<br>
> > - key_tex->compressed_multisample_layout_mask & (1 << sampler)) {<br>
> > - mcs = emit_mcs_fetch(coord_type, coordinate, sampler_reg);<br>
> > + key_tex->compressed_multisample_layout_mask & (1 << texture)) {<br>
> > + mcs = emit_mcs_fetch(coord_type, coordinate, texture_reg);<br>
> > } else {<br>
> > mcs = src_reg(0u);<br>
> > }<br>
> > @@ -1679,13 +1681,12 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> > offset_value = get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 2);<br>
> > break;<br>
> ><br>
> > - case nir_tex_src_sampler_offset: {<br>
> > - /* The highest sampler which may be used by this operation is<br>
> > + case nir_tex_src_texture_offset: {<br>
> > + /* The highest texture which may be used by this operation is<br>
> > * the last element of the array. Mark it here, because the generator<br>
> > * doesn't have enough information to determine the bound.<br>
> > */<br>
> > - uint32_t array_size = instr->texture_array_size;<br>
> > - uint32_t max_used = sampler + array_size - 1;<br>
> > + uint32_t max_used = texture + instr->texture_array_size - 1;<br>
> > if (instr->op == nir_texop_tg4) {<br>
> > max_used += prog_data->base.binding_table.gather_texture_start;<br>
> > } else {<br>
> > @@ -1697,6 +1698,15 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> > /* Emit code to evaluate the actual indexing expression */<br>
> > src_reg src = get_nir_src(instr->src[i].src, 1);<br>
> > src_reg temp(this, glsl_type::uint_type);<br>
> > + emit(ADD(dst_reg(temp), src, src_reg(texture)));<br>
> > + texture_reg = emit_uniformize(temp);<br>
> > + break;<br>
> > + }<br>
> > +<br>
> > + case nir_tex_src_sampler_offset: {<br>
> > + /* Emit code to evaluate the actual indexing expression */<br>
> > + src_reg src = get_nir_src(instr->src[i].src, 1);<br>
> > + src_reg temp(this, glsl_type::uint_type);<br>
> > emit(ADD(dst_reg(temp), src, src_reg(sampler)));<br>
> > sampler_reg = emit_uniformize(temp);<br>
> > break;<br>
> > @@ -1723,7 +1733,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> ><br>
> > /* Stuff the channel select bits in the top of the texture offset */<br>
> > if (instr->op == nir_texop_tg4)<br>
> > - constant_offset |= gather_channel(instr->component, sampler) << 16;<br>
> > + constant_offset |= gather_channel(instr->component, texture, sampler) << 16;<br>
> ><br>
> > ir_texture_opcode op = ir_texture_opcode_for_nir_texop(instr->op);<br>
> ><br>
> > @@ -1736,7 +1746,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> > shadow_comparitor,<br>
> > lod, lod2, sample_index,<br>
> > constant_offset, offset_value,<br>
> > - mcs, is_cube_array, sampler, sampler_reg);<br>
> > + mcs, is_cube_array,<br>
> > + texture, texture_reg, sampler, sampler_reg);<br>
> > }<br>
> ><br>
> > void<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
> > index b8f90f2..5eb2f7b 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
> > @@ -879,6 +879,8 @@ vec4_visitor::emit_texture(ir_texture_opcode op,<br>
> > src_reg offset_value,<br>
> > src_reg mcs,<br>
> > bool is_cube_array,<br>
> > + uint32_t surface,<br>
> > + src_reg surface_reg,<br>
> > uint32_t sampler,<br>
> > src_reg sampler_reg)<br>
> > {<br>
> > @@ -937,7 +939,8 @@ vec4_visitor::emit_texture(ir_texture_opcode op,<br>
> > inst->dst.writemask = WRITEMASK_XYZW;<br>
> > inst->shadow_compare = shadow_comparitor.file != BAD_FILE;<br>
> ><br>
> > - inst->src[1] = sampler_reg;<br>
> > + inst->src[1] = surface_reg;<br>
> > + inst->src[2] = sampler_reg;<br>
> ><br>
> > /* MRF for the first parameter */<br>
> > int param_base = inst->base_mrf + inst->header_size;<br>
> > @@ -1054,7 +1057,7 @@ vec4_visitor::emit_texture(ir_texture_opcode op,<br>
> > }<br>
> ><br>
> > if (devinfo->gen == 6 && op == ir_tg4) {<br>
> > - emit_gen6_gather_wa(key_tex->gen6_gather_wa[sampler], inst->dst);<br>
> > + emit_gen6_gather_wa(key_tex->gen6_gather_wa[surface], inst->dst);<br>
> > }<br>
> ><br>
> > swizzle_result(op, dest,<br>
> > @@ -1092,7 +1095,8 @@ vec4_visitor::emit_gen6_gather_wa(uint8_t wa, dst_reg dst)<br>
> > * Set up the gather channel based on the swizzle, for gather4.<br>
> > */<br>
> > uint32_t<br>
> > -vec4_visitor::gather_channel(unsigned gather_component, uint32_t sampler)<br>
> > +vec4_visitor::gather_channel(unsigned gather_component,<br>
> > + uint32_t surface, uint32_t sampler)<br>
> > {<br>
> > int swiz = GET_SWZ(key_tex->swizzles[sampler], gather_component);<br>
> > switch (swiz) {<br>
> > @@ -1101,7 +1105,7 @@ vec4_visitor::gather_channel(unsigned gather_component, uint32_t sampler)<br>
> > /* gather4 sampler is broken for green channel on RG32F --<br>
> > * we must ask for blue instead.<br>
> > */<br>
> > - if (key_tex->gather_channel_quirk_mask & (1 << sampler))<br>
> > + if (key_tex->gather_channel_quirk_mask & (1 << surface))<br>
> > return 2;<br>
> > return 1;<br>
> > case SWIZZLE_Z: return 2;<br>
> ><br>
><br>
> It doesn't look like gather_channel actually needs both parameters,<br>
> so maybe only pass in the surface/texture?</p>
<p dir="ltr">Well, gather_channel is gone now, so that's not as big a deal.</p>