agx: fix query LOD of array

need to ignore the layer

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig
2024-04-08 14:35:39 -04:00
committed by Marge Bot
parent 8df39ac49b
commit ec47f325f8
2 changed files with 39 additions and 25 deletions
+38 -24
View File
@@ -187,36 +187,50 @@ agx_write_registers(const agx_instr *I, unsigned d)
}
}
struct dim_info {
unsigned comps;
bool array;
};
static struct dim_info
agx_dim_info(enum agx_dim dim)
{
switch (dim) {
case AGX_DIM_1D:
return (struct dim_info){1, false};
case AGX_DIM_1D_ARRAY:
return (struct dim_info){1, true};
case AGX_DIM_2D:
return (struct dim_info){2, false};
case AGX_DIM_2D_ARRAY:
return (struct dim_info){2, true};
case AGX_DIM_2D_MS:
return (struct dim_info){3, false};
case AGX_DIM_3D:
return (struct dim_info){3, false};
case AGX_DIM_CUBE:
return (struct dim_info){3, false};
case AGX_DIM_CUBE_ARRAY:
return (struct dim_info){3, true};
case AGX_DIM_2D_MS_ARRAY:
return (struct dim_info){2, true};
default:
unreachable("invalid dim");
}
}
/*
* Return number of registers required for coordinates for a
* texture/image instruction. We handle layer + sample index as 32-bit even when
* only the lower 16-bits are present.
* Return number of registers required for coordinates for a texture/image
* instruction. We handle layer + sample index as 32-bit even when only the
* lower 16-bits are present. LOD queries do not take a layer.
*/
static unsigned
agx_coordinate_registers(const agx_instr *I)
{
switch (I->dim) {
case AGX_DIM_1D:
return 2 * 1;
case AGX_DIM_1D_ARRAY:
return 2 * 2;
case AGX_DIM_2D:
return 2 * 2;
case AGX_DIM_2D_ARRAY:
return 2 * 3;
case AGX_DIM_2D_MS:
return 2 * 3;
case AGX_DIM_3D:
return 2 * 3;
case AGX_DIM_CUBE:
return 2 * 3;
case AGX_DIM_CUBE_ARRAY:
return 2 * 4;
case AGX_DIM_2D_MS_ARRAY:
return 2 * 3;
}
struct dim_info dim = agx_dim_info(I->dim);
bool has_array = !I->query_lod;
unreachable("Invalid texture dimension");
return 2 * (dim.comps + (has_array && dim.array));
}
static unsigned
+1 -1
View File
@@ -224,7 +224,7 @@ lower_regular_texture(nir_builder *b, nir_instr *instr, UNUSED void *data)
*/
nir_def *layer = NULL;
if (tex->is_array) {
if (tex->is_array && tex->op != nir_texop_lod) {
unsigned lidx = coord->num_components - 1;
nir_def *unclamped_layer = nir_channel(b, coord, lidx);
coord = nir_trim_vector(b, coord, lidx);