[Freedreno] [PATCH 1/2] nir: allow texture offsets with cube maps
Ilia Mirkin
imirkin at alum.mit.edu
Sun Nov 19 19:54:15 UTC 2017
GL doesn't have this, but some hardware supports it. This is convenient
for lowering tg4 to plain texture calls, which is necessary on Adreno
A4xx hardware.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/compiler/nir/nir.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f46f6147110..64965ae16d6 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1364,8 +1364,7 @@ nir_tex_instr_src_size(const nir_tex_instr *instr, unsigned src)
if (instr->src[src].src_type == nir_tex_src_ms_mcs)
return 4;
- if (instr->src[src].src_type == nir_tex_src_offset ||
- instr->src[src].src_type == nir_tex_src_ddx ||
+ if (instr->src[src].src_type == nir_tex_src_ddx ||
instr->src[src].src_type == nir_tex_src_ddy) {
if (instr->is_array)
return instr->coord_components - 1;
@@ -1373,6 +1372,18 @@ nir_tex_instr_src_size(const nir_tex_instr *instr, unsigned src)
return instr->coord_components;
}
+ /* Usual APIs don't allow cube + offset, but we allow it, with 2 coords for
+ * the offset, since a cube maps to a single face.
+ */
+ if (instr->src[src].src_type == nir_tex_src_offset) {
+ unsigned ret = instr->coord_components;
+ if (instr->is_array)
+ ret--;
+ if (instr->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
+ ret--;
+ return ret;
+ }
+
return 1;
}
--
2.13.6
More information about the Freedreno
mailing list