agx: handle 16-bit coordinates

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36399>
This commit is contained in:
Alyssa Rosenzweig 2025-07-31 19:48:45 -04:00
parent 0319bd0a84
commit 8a8fe2ffc1
2 changed files with 9 additions and 10 deletions

View file

@ -58,11 +58,10 @@ static unsigned
agx_pack_sample_coords(const agx_instr *I, agx_index index, bool *flag,
bool *is_16)
{
/* TODO: Do we have a use case for 16-bit coords? */
pack_assert_msg(I, index.size == AGX_SIZE_32, "32-bit coordinates");
pack_assert_msg(I, index.size <= AGX_SIZE_32, "32-bit coordinates");
pack_assert_msg(I, index.value < 0x100, "coordinate register bound");
*is_16 = false;
*is_16 = index.size == AGX_SIZE_16;
*flag = index.discard;
return index.value;
}
@ -913,8 +912,8 @@ agx_pack_instr(struct util_dynarray *emission, struct util_dynarray *fixups,
(q2 << 30) | (((uint64_t)(T & BITFIELD_MASK(6))) << 32) |
(((uint64_t)Tt) << 38) |
(((uint64_t)(I->dim & BITFIELD_MASK(3))) << 40) |
(((uint64_t)q3) << 43) | (((uint64_t)I->mask) << 48) |
(((uint64_t)lod_mode) << 52) |
(((uint64_t)q3) << 43) | (Cs ? BITFIELD64_BIT(47) : 0) |
(((uint64_t)I->mask) << 48) | (((uint64_t)lod_mode) << 52) |
(((uint64_t)(S & BITFIELD_MASK(6))) << 56) | (((uint64_t)St) << 62) |
(((uint64_t)I->scoreboard) << 63);

View file

@ -228,12 +228,12 @@ agx_dim_info(enum agx_dim dim)
* lower 16-bits are present. LOD queries do not take a layer.
*/
static unsigned
agx_coordinate_registers(const agx_instr *I)
agx_coordinate_registers(const agx_instr *I, enum agx_size size)
{
struct dim_info dim = agx_dim_info(I->dim);
bool has_array = !I->query_lod;
return 2 * (dim.comps + (has_array && dim.array));
return agx_size_align_16(size) * (dim.comps + (has_array && dim.array));
}
static unsigned
@ -292,7 +292,7 @@ agx_read_registers(const agx_instr *I, unsigned s)
if (s == 0)
return 4 * size /* data */;
else if (s == 1)
return agx_coordinate_registers(I);
return agx_coordinate_registers(I, I->src[1].size);
else
return size;
@ -300,7 +300,7 @@ agx_read_registers(const agx_instr *I, unsigned s)
case AGX_OPCODE_TEXTURE_LOAD:
case AGX_OPCODE_TEXTURE_SAMPLE:
if (s == 0) {
return agx_coordinate_registers(I);
return agx_coordinate_registers(I, I->src[0].size);
} else if (s == 1) {
/* LOD */
if (I->lod_mode == AGX_LOD_MODE_LOD_GRAD ||
@ -341,7 +341,7 @@ agx_read_registers(const agx_instr *I, unsigned s)
case AGX_OPCODE_BLOCK_IMAGE_STORE:
if (s == 3 && I->explicit_coords)
return agx_coordinate_registers(I);
return agx_coordinate_registers(I, I->src[3].size);
else
return size;