<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Dec 2, 2017 at 11:09 PM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.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 2017-12-01 17:20:04, Jason Ekstrand wrote:<br>
> We want to call brw_nir_analyze_ubo_ranges immedately after<br>
> anv_nir_apply_pipeline_layout and it badly wants constants.  We could<br>
> run an optimization step and let constant folding do it but that's way<br>
> more expensive than needed.  It's really easy to just handle constants<br>
> in apply_pipeline_layout.<br>
> ---<br>
>  src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c | 15 +++++++++++----<br>
>  1 file changed, 11 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
> index f8d8164..4f7680b 100644<br>
> --- a/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
> +++ b/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
> @@ -116,12 +116,19 @@ lower_res_index_intrinsic(nir_<wbr>intrinsic_instr *intrin,<br>
>     uint32_t array_size =<br>
>        state->layout->set[set].<wbr>layout->binding[binding].<wbr>array_size;<br>
><br>
> -   nir_ssa_def *block_index = nir_ssa_for_src(b, intrin->src[0], 1);<br>
> +   nir_const_value *const_block_index = nir_src_as_const_value(intrin-<wbr>>src[0]);<br>
><br>
> -   if (state->add_bounds_checks)<br>
> -      block_index = nir_umin(b, block_index, nir_imm_int(b, array_size - 1));<br>
> +   nir_ssa_def *block_index;<br>
> +   if (const_block_index) {<br>
> +      block_index = nir_imm_int(b, surface_index + const_block_index->u32[0]);<br>
<br>
</span>I'm guessing that if this is constant, then it'll have been bounds<br>
checked elsewhere? If not, I guess you could do something easy here<br>
with array_size.<br></blockquote><div><br></div><div>Thanks!  I meant to but forgot.  Fixed locally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Reviewed-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
<span class=""><br>
> +   } else {<br>
> +      block_index = nir_ssa_for_src(b, intrin->src[0], 1);<br>
><br>
> -   block_index = nir_iadd(b, nir_imm_int(b, surface_index), block_index);<br>
> +      if (state->add_bounds_checks)<br>
> +         block_index = nir_umin(b, block_index, nir_imm_int(b, array_size - 1));<br>
> +<br>
> +      block_index = nir_iadd(b, nir_imm_int(b, surface_index), block_index);<br>
> +   }<br>
><br>
>     assert(intrin->dest.is_ssa);<br>
>     nir_ssa_def_rewrite_uses(&<wbr>intrin->dest.ssa, nir_src_for_ssa(block_index));<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</span>> ______________________________<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>
</blockquote></div><br></div></div>