aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2017-11-19 12:27:12 -0500
committerIlia Mirkin <[email protected]>2017-11-25 16:56:30 -0500
commitab336e8b46b6d7016519681c59b9aedf3fea04ad (patch)
tree57b6011a3af1f50045f42c6af6c4d232ad85da24 /src
parentc690a7a8cdfb6425547bbb782020098405851194 (diff)
nir: allow texture offsets with cube maps
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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f46f6147110..cf200fdc665 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) {
+ if (instr->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
+ return 2;
+ else if (instr->is_array)
+ return instr->coord_components - 1;
+ else
+ return instr->coord_components;
+ }
+
return 1;
}