- R300_TX_HEIGHT((pt->height[0] - 1) & 0x7ff) |
- R300_TX_DEPTH(util_logbase2(pt->depth[0]) & 0xf) |
- R300_TX_NUM_LEVELS(pt->last_level & 0xf);/* |
- R300_TX_PITCH_EN;*/
- /* XXX TX_PITCH_EN breaks rendering mipmap levels > 0, weard */
+ R300_TX_HEIGHT((pt->height[0] - 1) & 0x7ff);
+
+ if (!util_is_power_of_two(pt->width[0]) ||
+ !util_is_power_of_two(pt->height[0])) {
+
+ /* rectangles love this */
+ state->format0 |= R300_TX_PITCH_EN;
+
+ stride = r300_texture_get_stride(tex, 0) / pt->block.size;
+ state->format2 = (stride - 1) & 0x1fff;
+ }
+ else {
+ /* power of two textures (3D, mipmaps, and no pitch) */
+ state->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth[0]) & 0xf) |
+ R300_TX_NUM_LEVELS(pt->last_level & 0xf);
+ }