[i915] Bug #13634: Fix bugs in 945 cube mipmap layout.
authorEric Anholt <eric@anholt.net>
Wed, 19 Mar 2008 02:45:30 +0000 (19:45 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 19 Mar 2008 03:17:56 +0000 (20:17 -0700)
The most egregious, and the one the bug report and failure in the cubemap
demo were about was introduced with intel_mipmap_pitch_align(), where a
"* 2" for the pitch calculation was lost.  The base size < 32 case also
failed to align, which may have caused problems with render to texture.
Another bug would have broken 2x2/1x1 base mipmap levels by placing the
data where the hardware wouldn't look for it.

Other bugs remain with the layout of the small mipmap faces (hardware looks
for them in X,Y,Z,-X,-Y,-Z order along the bottom row, but we lay them out
X,-X,Y,-Y,Z,-Z).

src/mesa/drivers/dri/i915/i915_tex_layout.c

index 87daec67105e96f39d6c3eccdefbef59ee0713e6..b5085f49d417419541964d909ce6e0b8de86abfa 100644 (file)
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
 static GLint initial_offsets[6][2] = {
-   {0, 0},
-   {0, 2},
-   {1, 0},
-   {1, 2},
-   {1, 1},
-   {1, 3}
+   [FACE_POS_X] = {0, 0},
+   [FACE_POS_Y] = {1, 0},
+   [FACE_POS_Z] = {1, 1},
+   [FACE_NEG_X] = {0, 2},
+   [FACE_NEG_Y] = {1, 2},
+   [FACE_NEG_Z] = {1, 3},
 };
 
 
 static GLint step_offsets[6][2] = {
-   {0, 2},
-   {0, 2},
-   {-1, 2},
-   {-1, 2},
-   {-1, 1},
-   {-1, 1}
+   [FACE_POS_X] = {0, 2},
+   [FACE_POS_Y] = {-1, 2},
+   [FACE_POS_Z] = {-1, 1},
+   [FACE_NEG_X] = {0, 2},
+   [FACE_NEG_Y] = {-1, 2},
+   [FACE_NEG_Z] = {-1, 1},
 };
 
 /**
@@ -320,11 +320,14 @@ i945_miptree_layout_cube(struct intel_context *intel,
     * or the final row of 4x4, 2x2 and 1x1 faces below this.
     */
    if (dim > 32)
-      mt->pitch = intel_miptree_pitch_align (intel, mt, dim);
+      mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
    else
-      mt->pitch = 14 * 8;
+      mt->pitch = intel_miptree_pitch_align (intel, mt, 14 * 8);
 
-   mt->total_height = dim * 4 + 4;
+   if (dim >= 4)
+      mt->total_height = dim * 4 + 4;
+   else
+      mt->total_height = 4;
 
    /* Set all the levels to effectively occupy the whole rectangular region. */
    for (level = mt->first_level; level <= mt->last_level; level++) {