<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 17, 2019 at 5:21 AM Boris Brezillon <<a href="mailto:boris.brezillon@collabora.com">boris.brezillon@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">get_texture_size() will create a txs instruction with ->sampler_dim set<br>
to the original tex->sampler_dim. The condition to call lower_rect()<br>
only checks the value of ->sampler_dim and whether lower_rect is<br>
requested or not. This leads to an infinite loop when calling<br>
nir_lower_tex() with the same options until it returns false.<br>
<br>
In order to avoid that, let's move the tex->sampler_dim patching before<br>
get_texture_size() is called. This way the txs instruction will have<br>
->sampler_dim set to GLSL_SAMPLER_DIM_2D and nir_lower_tex() won't try<br>
to lower it on the subsequent passes.<br>
<br>
Signed-off-by: Boris Brezillon <<a href="mailto:boris.brezillon@collabora.com" target="_blank">boris.brezillon@collabora.com</a>><br>
---<br>
Another option would be to not call lower_rect() when the instruction<br>
is a txs op.<br>
---<br>
 src/compiler/nir/nir_lower_tex.c | 4 ++--<br>
 1 file changed, 2 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c<br>
index 73b26dbdb238..1ee961dbb90c 100644<br>
--- a/src/compiler/nir/nir_lower_tex.c<br>
+++ b/src/compiler/nir/nir_lower_tex.c<br>
@@ -266,6 +266,8 @@ lower_offset(nir_builder *b, nir_tex_instr *tex)<br>
 static void<br>
 lower_rect(nir_builder *b, nir_tex_instr *tex)<br>
 {<br>
+   tex->sampler_dim = GLSL_SAMPLER_DIM_2D;<br></blockquote><div><br></div><div>Mind throwing in a short comment?</div><div><br></div><div>/* Set the sampler_dim to 2D here so that get_texture_size picks up the right dimensionality */</div><div><br></div><div>With that,</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
    nir_ssa_def *txs = get_texture_size(b, tex);<br>
    nir_ssa_def *scale = nir_frcp(b, txs);<br>
<br>
@@ -280,8 +282,6 @@ lower_rect(nir_builder *b, nir_tex_instr *tex)<br>
                             &tex->src[i].src,<br>
                             nir_src_for_ssa(nir_fmul(b, coords, scale)));<br>
    }<br>
-<br>
-   tex->sampler_dim = GLSL_SAMPLER_DIM_2D;<br>
 }<br>
<br>
 static void<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div></div>