panfrost/midgard: Support negative immediate offsets

It's not at all clear why this work for texelFetch but not texture.
Maybe the top bits are dual-purpose on other texturing ops...?

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-06-10 13:27:10 -07:00
parent 4d8157f12d
commit 6c18ae33bc
2 changed files with 20 additions and 16 deletions

View file

@ -1131,6 +1131,18 @@ print_texture_word(uint32_t *word, unsigned tabs)
printf(", ");
} else if (texture->offset_x || texture->offset_y || texture->offset_z) {
/* Only select ops allow negative immediate offsets, verify */
bool neg_x = texture->offset_x < 0;
bool neg_y = texture->offset_y < 0;
bool neg_z = texture->offset_z < 0;
bool any_neg = neg_x || neg_y || neg_z;
if (any_neg && texture->op != TEXTURE_OP_TEXEL_FETCH)
printf("/* invalid negative */ ");
/* Regardless, just print the immediate offset */
printf(" + <%d, %d, %d>, ",
texture->offset_x,
texture->offset_y,
@ -1171,22 +1183,14 @@ print_texture_word(uint32_t *word, unsigned tabs)
texture->unknown3 ||
texture->unknown4 ||
texture->unknownA ||
texture->unknownB ||
texture->unknown8) {
printf("// unknown2 = 0x%x\n", texture->unknown2);
printf("// unknown3 = 0x%x\n", texture->unknown3);
printf("// unknown4 = 0x%x\n", texture->unknown4);
printf("// unknownA = 0x%x\n", texture->unknownA);
printf("// unknownB = 0x%x\n", texture->unknownB);
printf("// unknown8 = 0x%x\n", texture->unknown8);
}
if (texture->offset_unknown4 ||
texture->offset_unknown8) {
printf("// offset_unknown4 = 0x%x\n", texture->offset_unknown4);
printf("// offset_unknown8 = 0x%x\n", texture->offset_unknown8);
}
/* Don't blow up */
if (texture->unknown7 != 0x1)
printf("// (!) unknown7 = %d\n", texture->unknown7);

View file

@ -561,15 +561,15 @@ __attribute__((__packed__))
/* Each offset field is either an immediate (range 0-7) or, in the case of X, a
* register full / select / upper triplet to select the offset vector
* register in register mode. In register mode, Y=2 and Z=1 for some
* reason. The range in register mode is [-8, 7] */
* reason. The range in register mode is [-8, 7].
*
* In immediate mode, for texel fethces the range is the full [-8, 7],
* but for normal texturing the top bit must be zero and a register
* used instead. It's not clear where this limitated is from. */
unsigned offset_x : 3;
unsigned offset_unknown4 : 1;
unsigned offset_y : 3;
unsigned offset_unknown8 : 1;
unsigned offset_z : 3;
unsigned unknownB : 1;
signed offset_x : 4;
signed offset_y : 4;
signed offset_z : 4;
/* Texture bias or LOD, depending on whether it is executed in a
* fragment/vertex shader respectively. Compute as int(2^8 * biasf).