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;
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;
}