From: Boris Brezillon Date: Mon, 17 Jun 2019 09:31:51 +0000 (+0200) Subject: nir/lower_tex: Update ->sampler_dim value before calling get_texture_size() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e489fd36061352e79cb4fb90f71f1b901211452;p=mesa.git nir/lower_tex: Update ->sampler_dim value before calling get_texture_size() get_texture_size() will create a txs instruction with ->sampler_dim set to the original tex->sampler_dim. The condition to call lower_rect() only checks the value of ->sampler_dim and whether lower_rect is requested or not. This leads to an infinite loop when calling nir_lower_tex() with the same options until it returns false. In order to avoid that, let's move the tex->sampler_dim patching before get_texture_size() is called. This way the txs instruction will have ->sampler_dim set to GLSL_SAMPLER_DIM_2D and nir_lower_tex() won't try to lower it on the subsequent passes. Changes in v2: * Add Jason R-b * Add a comment explaining why we patch ->sampler_dim at the beginning of the lower_rect() func Signed-off-by: Boris Brezillon Reviewed-by: Jason Ekstrand Reviewed-by: Alyssa Rosenzweig --- diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index 04ca8f88c25..ace8600d4bb 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -266,6 +266,11 @@ lower_offset(nir_builder *b, nir_tex_instr *tex) static void lower_rect(nir_builder *b, nir_tex_instr *tex) { + /* Set the sampler_dim to 2D here so that get_texture_size picks up the + * right dimensionality. + */ + tex->sampler_dim = GLSL_SAMPLER_DIM_2D; + nir_ssa_def *txs = get_texture_size(b, tex); nir_ssa_def *scale = nir_frcp(b, txs); @@ -280,8 +285,6 @@ lower_rect(nir_builder *b, nir_tex_instr *tex) &tex->src[i].src, nir_src_for_ssa(nir_fmul(b, coords, scale))); } - - tex->sampler_dim = GLSL_SAMPLER_DIM_2D; } static void