i965/gen5+: Fix incorrect miptree layout for non-power-of-two cubemaps.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_tex_layout.c
index 768ccfd79c432d2bd49875fd01db1a7c3b13f99c..46a417a08edafd27eb216e13ecc23b6fc986bfc1 100644 (file)
@@ -48,7 +48,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
 
    switch (mt->target) {
    case GL_TEXTURE_CUBE_MAP:
-      if (intel->gen == 5) {
+      if (intel->gen >= 5) {
           GLuint align_h = 2;
           GLuint level;
           GLuint qpitch = 0;
@@ -60,8 +60,8 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
           * given in Volume 1 of the BSpec.
           */
          h0 = ALIGN(mt->height0, align_h);
-         h1 = ALIGN(minify(h0), align_h);
-         qpitch = (h0 + h1 + 11 * align_h);
+         h1 = ALIGN(minify(mt->height0), align_h);
+         qpitch = (h0 + h1 + (intel->gen >= 7 ? 12 : 11) * align_h);
           if (mt->compressed)
             qpitch /= 4;
 
@@ -88,7 +88,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
       GLuint align_w = 4;
 
       mt->total_height = 0;
-      intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h);
+      intel_get_texture_alignment_unit(mt->format, &align_w, &align_h);
 
       if (mt->compressed) {
           mt->total_width = ALIGN(width, align_w);
@@ -152,9 +152,6 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
        * in the texture surfaces run, so they may be "vertical" through
        * memory.  As a result, the docs say in Surface Padding Requirements:
        * Sampling Engine Surfaces that two extra rows of padding are required.
-       * We don't know of similar requirements for pre-965, but given that
-       * those docs are silent on padding requirements in general, let's play
-       * it safe.
        */
       if (mt->target == GL_TEXTURE_CUBE_MAP)
         mt->total_height += 2;