intel: Add a width field to regions, and use it for making miptrees in TFP.
authorEric Anholt <eric@anholt.net>
Fri, 12 Sep 2008 22:48:13 +0000 (15:48 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 12 Sep 2008 22:48:13 +0000 (15:48 -0700)
Otherwise, we would use the pitch as width of the texture, and compiz would
render the pitch padding on the right hand side.

src/mesa/drivers/dri/intel/intel_context.c
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
src/mesa/drivers/dri/intel/intel_tex_image.c

index 007dee449ca95ec82c3d343a433d9b111ef7bbde..23e0f6331ac2b9c3f33cdd2e0057e5cf8b78f48d 100644 (file)
@@ -301,8 +301,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        }
        else
           region = intel_region_alloc_for_handle(intel, buffers[i].cpp,
-                                                buffers[i].pitch / buffers[i].cpp,
+                                                drawable->w,
                                                 drawable->h,
+                                                buffers[i].pitch / buffers[i].cpp,
                                                 buffers[i].name,
                                                 region_name);
 
index 5bd2ebfdcf6012fe0f20a6d50150de89de3e326e..6570f6e69b7a4dd6488ebde2361793e0524c60ed 100644 (file)
@@ -296,7 +296,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
          height, pitch);
 
-      irb->region = intel_region_alloc(intel, cpp, pitch, height);
+      irb->region = intel_region_alloc(intel, cpp, width, height, pitch);
       if (!irb->region)
          return GL_FALSE;       /* out of memory? */
 
index 9be7e02eff13433e1b21f20d4b4cda1d68eb4a71..f28fac8394b48c848e8cda5ef5deb14fe1348f3e 100644 (file)
@@ -117,7 +117,10 @@ intel_miptree_create(struct intel_context *intel,
       return NULL;
 
    mt->region = intel_region_alloc(intel,
-                                  mt->cpp, mt->pitch, mt->total_height);
+                                  mt->cpp,
+                                  mt->pitch,
+                                  mt->total_height,
+                                  mt->pitch);
 
    if (!mt->region) {
        free(mt);
@@ -141,7 +144,7 @@ intel_miptree_create_for_region(struct intel_context *intel,
 
    mt = intel_miptree_create_internal(intel, target, internal_format,
                                      first_level, last_level,
-                                     region->pitch, region->height, depth0,
+                                     region->width, region->height, 1,
                                      region->cpp, compress_byte);
    if (!mt)
       return mt;
index 1cfc8ddd64c3f77ae57d21224a74a1866838426d..cb0f4ba083b0c1ad0ee20a642d861b0724d69e5e 100644 (file)
@@ -105,7 +105,8 @@ intel_set_region_tiling_gem(struct intel_context *intel,
 
 static struct intel_region *
 intel_region_alloc_internal(struct intel_context *intel,
-                           GLuint cpp, GLuint pitch, GLuint height,
+                           GLuint cpp,
+                           GLuint width, GLuint height, GLuint pitch,
                            dri_bo *buffer)
 {
    struct intel_region *region;
@@ -117,8 +118,9 @@ intel_region_alloc_internal(struct intel_context *intel,
 
    region = calloc(sizeof(*region), 1);
    region->cpp = cpp;
+   region->width = width;
+   region->height = height;
    region->pitch = pitch;
-   region->height = height;     /* needed? */
    region->refcount = 1;
    region->buffer = buffer;
 
@@ -131,19 +133,20 @@ intel_region_alloc_internal(struct intel_context *intel,
 
 struct intel_region *
 intel_region_alloc(struct intel_context *intel,
-                   GLuint cpp, GLuint pitch, GLuint height)
+                   GLuint cpp, GLuint width, GLuint height, GLuint pitch)
 {
    dri_bo *buffer;
 
    buffer = dri_bo_alloc(intel->bufmgr, "region",
                         pitch * cpp * height, 64);
 
-   return intel_region_alloc_internal(intel, cpp, pitch, height, buffer);
+   return intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer);
 }
 
 struct intel_region *
 intel_region_alloc_for_handle(struct intel_context *intel,
-                             GLuint cpp, GLuint pitch, GLuint height,
+                             GLuint cpp,
+                             GLuint width, GLuint height, GLuint pitch,
                              GLuint handle, const char *name)
 {
    struct intel_region *region;
@@ -151,7 +154,8 @@ intel_region_alloc_for_handle(struct intel_context *intel,
 
    buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle);
 
-   region = intel_region_alloc_internal(intel, cpp, pitch, height, buffer);
+   region = intel_region_alloc_internal(intel, cpp,
+                                       width, height, pitch, buffer);
    if (region == NULL)
       return region;
 
index a561de485e24286b89d6f2d61c7fba5666eca829..62eb049fbafca21d8f3a00e9a4ffa55df900d6a3 100644 (file)
@@ -55,8 +55,9 @@ struct intel_region
    dri_bo *buffer;  /**< buffer manager's buffer */
    GLuint refcount; /**< Reference count for region */
    GLuint cpp;      /**< bytes per pixel */
-   GLuint pitch;    /**< in pixels */
+   GLuint width;    /**< in pixels */
    GLuint height;   /**< in pixels */
+   GLuint pitch;    /**< in pixels */
    GLubyte *map;    /**< only non-NULL when region is actually mapped */
    GLuint map_refcount;  /**< Reference count for mapping */
 
@@ -72,12 +73,13 @@ struct intel_region
  * copied by calling intel_reference_region().
  */
 struct intel_region *intel_region_alloc(struct intel_context *intel,
-                                        GLuint cpp,
-                                        GLuint pitch, GLuint height);
+                                        GLuint cpp, GLuint width,
+                                        GLuint height, GLuint pitch);
 
 struct intel_region *
 intel_region_alloc_for_handle(struct intel_context *intel,
-                             GLuint cpp, GLuint pitch, GLuint height,
+                             GLuint cpp,
+                             GLuint width, GLuint height, GLuint pitch,
                              unsigned int handle, const char *name);
 
 void intel_region_reference(struct intel_region **dst,
index 70b0b3e245688f26f0183dc5d3147bf2ecf49457..1820d3dc05881fc9f820ce4b1eb44862f84fdb89 100644 (file)
@@ -757,7 +757,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
    intelObj->mt = mt;
    texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
    _mesa_init_teximage_fields(&intel->ctx, target, texImage,
-                             rb->region->pitch, rb->region->height, 1,
+                             rb->region->width, rb->region->height, 1,
                              0, internalFormat);
 
    intelImage = intel_texture_image(texImage);