intel: Rely on allocated region pitch for the miptree pitch.
authorEric Anholt <eric@anholt.net>
Tue, 16 Mar 2010 23:20:03 +0000 (16:20 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 17 Mar 2010 18:23:43 +0000 (11:23 -0700)
Bug #26966: 945 miptree pitch disagreement with libdrm.

src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_regions.c
src/mesa/drivers/dri/intel/intel_regions.h

index a429f8d003dfa94c0adc3679b95da9b646efc0d7..ba3bb8fdba4819aad0758395413f64fe437931be 100644 (file)
@@ -104,7 +104,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    struct intel_context *intel = intel_context(ctx);
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
    int cpp;
-   GLuint pitch;
 
    ASSERT(rb->Name != 0);
 
@@ -176,15 +175,11 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
    /* allocate new memory region/renderbuffer */
 
-   /* Choose a pitch to match hardware requirements:
-    */
-   pitch = ((cpp * width + 63) & ~63) / cpp;
-
    /* alloc hardware renderbuffer */
-   DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch);
+   DBG("Allocating %d x %d Intel RBO\n", width, height);
 
    irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp,
-                                   width, height, pitch, GL_TRUE);
+                                   width, height, GL_TRUE);
    if (!irb->region)
       return GL_FALSE;       /* out of memory? */
 
index ac9e135a01ac7d9dff54c491eb776e0821260997..e02b188e3540f3bb7816a5262e842e49bbf6cf70 100644 (file)
@@ -146,8 +146,8 @@ intel_miptree_create(struct intel_context *intel,
                                   mt->cpp,
                                   mt->pitch,
                                   mt->total_height,
-                                  mt->pitch,
                                   expect_accelerated_upload);
+   mt->pitch = mt->region->pitch;
 
    if (!mt->region) {
        free(mt);
@@ -177,20 +177,11 @@ intel_miptree_create_for_region(struct intel_context *intel,
                                      I915_TILING_NONE);
    if (!mt)
       return mt;
-#if 0
-   if (mt->pitch != region->pitch) {
-      fprintf(stderr,
-             "region pitch (%d) doesn't match mipmap tree pitch (%d)\n",
-             region->pitch, mt->pitch);
-      free(mt);
-      return NULL;
-   }
-#else
+
    /* The mipmap tree pitch is aligned to 64 bytes to make sure render
     * to texture works, but we don't need that for texturing from a
     * pixmap.  Just override it here. */
    mt->pitch = region->pitch;
-#endif
 
    intel_region_reference(&mt->region, region);
 
index 581e5ec6b38a2d8a743b06bd72f41111990055f1..27e454d2942beaa686ab03cc088d4dcbe0643e2a 100644 (file)
@@ -172,7 +172,7 @@ intel_region_alloc_internal(struct intel_context *intel,
 struct intel_region *
 intel_region_alloc(struct intel_context *intel,
                   uint32_t tiling,
-                   GLuint cpp, GLuint width, GLuint height, GLuint pitch,
+                   GLuint cpp, GLuint width, GLuint height,
                   GLboolean expect_accelerated_upload)
 {
    dri_bo *buffer;
@@ -186,13 +186,9 @@ intel_region_alloc(struct intel_context *intel,
    buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region",
                                     width, height, cpp,
                                     &tiling, &aligned_pitch, flags);
-   /* We've already chosen a pitch as part of miptree layout.  It had
-    * better be the same.
-    */
-   assert(aligned_pitch == pitch * cpp);
 
    region = intel_region_alloc_internal(intel, cpp, width, height,
-                                       pitch, buffer);
+                                       aligned_pitch / cpp, buffer);
    region->tiling = tiling;
 
    return region;
index c81ccde4dad66d2dec52f5788f86785d05026318..2459c9a924d255935cd1b4a1964a17473f8b0361 100644 (file)
@@ -78,7 +78,7 @@ struct intel_region
 struct intel_region *intel_region_alloc(struct intel_context *intel,
                                         uint32_t tiling,
                                        GLuint cpp, GLuint width,
-                                        GLuint height, GLuint pitch,
+                                        GLuint height,
                                        GLboolean expect_accelerated_upload);
 
 struct intel_region *