nir_ssa_def *height = nir_iadd_imm(b, height_m1, 1);
nir_ssa_def *depth = nir_iadd_imm(b, depth_m1, 1);
+ /* 1D Arrays have their second component as the layer count */
+ if (tex->sampler_dim == GLSL_SAMPLER_DIM_1D && tex->is_array)
+ height = depth;
+
/* How we finish depends on the size of the result */
unsigned nr_comps = nir_dest_num_components(tex->dest);
assert(nr_comps <= 3);
nir_ssa_def *coord = steal_tex_src(tex, nir_tex_src_coord);
nir_ssa_def *ms_idx = steal_tex_src(tex, nir_tex_src_ms_index);
+ /* It's unclear if mipmapped 1D textures work in the hardware. For now, we
+ * always lower to 2D.
+ */
+ if (tex->sampler_dim == GLSL_SAMPLER_DIM_1D) {
+ /* Add a zero Y component to the coordinate */
+ if (tex->is_array) {
+ assert(coord->num_components == 2);
+ coord = nir_vec3(b, nir_channel(b, coord, 0),
+ nir_imm_intN_t(b, 0, coord->bit_size),
+ nir_channel(b, coord, 1));
+ } else {
+ assert(coord->num_components == 1);
+ coord = nir_vec2(b, coord, nir_imm_intN_t(b, 0, coord->bit_size));
+ }
+
+ /* Add a zero Y component to other sources */
+ nir_tex_src_type other_srcs[] = {
+ nir_tex_src_ddx,
+ nir_tex_src_ddy,
+ nir_tex_src_offset,
+ };
+
+ for (unsigned i = 0; i < ARRAY_SIZE(other_srcs); ++i) {
+ nir_ssa_def *src = steal_tex_src(tex, other_srcs[i]);
+
+ if (!src)
+ continue;
+
+ assert(src->num_components == 1);
+ src = nir_vec2(b, src, nir_imm_intN_t(b, 0, src->bit_size));
+ nir_tex_instr_add_src(tex, other_srcs[i], nir_src_for_ssa(src));
+ }
+
+ tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
+ tex->coord_components++;
+ }
+
/* The layer is always the last component of the NIR coordinate, split it off
* because we'll need to swizzle.
*/
/* 1D is always linear */
case PIPE_BUFFER:
case PIPE_TEXTURE_1D:
+ case PIPE_TEXTURE_1D_ARRAY:
/* Linear textures require specifying their strides explicitly, which only
* works for 2D textures. Rectangle textures are a special case of 2D.
(PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_LINEAR))
return false;
- /* Buffers must be linear, and it does not make sense to twiddle 1D */
- if (pres->base.target == PIPE_BUFFER || pres->base.target == PIPE_TEXTURE_1D)
+ /* Buffers must be linear */
+ if (pres->base.target == PIPE_BUFFER)
return false;
/* Anything else may be twiddled */
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
+#include "util/compiler.h"
#include "util/format_srgb.h"
#include "util/half_float.h"
#include "util/u_inlines.h"
switch (dim) {
case PIPE_BUFFER:
+ case PIPE_TEXTURE_1D:
/* Lowered to 2D */
assert(samples == 1);
return AGX_TEXTURE_DIMENSION_2D;
- case PIPE_TEXTURE_1D:
- assert(samples == 1);
- return AGX_TEXTURE_DIMENSION_1D;
-
- case PIPE_TEXTURE_1D_ARRAY:
- assert(samples == 1);
- return AGX_TEXTURE_DIMENSION_1D_ARRAY;
-
case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_2D:
return samples > 1 ? AGX_TEXTURE_DIMENSION_2D_MULTISAMPLED
: AGX_TEXTURE_DIMENSION_2D;
+ case PIPE_TEXTURE_1D_ARRAY:
+ assert(samples == 1);
+ /* Lowered to 2D */
+ FALLTHROUGH;
case PIPE_TEXTURE_2D_ARRAY:
return samples > 1 ? AGX_TEXTURE_DIMENSION_2D_ARRAY_MULTISAMPLED
: AGX_TEXTURE_DIMENSION_2D_ARRAY;