#include "disassemble.h"
#include "helpers.h"
#include "util/half_float.h"
+#include "util/u_math.h"
#define DEFINE_CASE(define, str) case define: { printf(str); break; }
printf(" + ");
print_texture_reg_triple(texture->offset_x);
- /* I've never seen them different than this */
- if (texture->offset_y != 2)
- printf(" /* y = %d */", texture->offset_y);
+ /* The less questions you ask, the better. */
- if (texture->offset_z != 1)
- printf(" /* z = %d */", texture->offset_z);
+ unsigned swizzle_lo, swizzle_hi;
+ unsigned orig_y = texture->offset_y;
+ unsigned orig_z = texture->offset_z;
+
+ memcpy(&swizzle_lo, &orig_y, sizeof(unsigned));
+ memcpy(&swizzle_hi, &orig_z, sizeof(unsigned));
+
+ /* Duplicate hi swizzle over */
+ assert(swizzle_hi < 4);
+ swizzle_hi = (swizzle_hi << 2) | swizzle_hi;
+
+ unsigned swiz = (swizzle_lo << 4) | swizzle_hi;
+ unsigned reversed = util_bitreverse(swiz) >> 24;
+ print_swizzle_vec4(reversed, false, false);
printf(", ");
} else if (texture->offset_x || texture->offset_y || texture->offset_z) {
unsigned unknownA : 4;
- /* 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].
+ /* In immediate mode, each offset field is an immediate range [0, 7].
*
- * In immediate mode, for texel fethces the range is the full [-8, 7],
+ * In register mode, offset_x becomes a register full / select / upper
+ * triplet and a vec3 swizzle is splattered across offset_y/offset_z in
+ * a genuinely bizarre way.
+ *
+ * For texel fetches in immediate mode, 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. */
+ * used instead. It's not clear where this limitation is from. */
signed offset_x : 4;
signed offset_y : 4;