[intel] use _mesa_copy_rect for upload compressed texture,
authorZou Nan hai <nanhai.zou@intel.com>
Fri, 1 Feb 2008 09:36:56 +0000 (17:36 +0800)
committerZou Nan hai <nanhai.zou@intel.com>
Fri, 1 Feb 2008 09:36:56 +0000 (17:36 +0800)
this fix bad texture issue in some games(UT and quake).

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 6e127dc31e72fbce2b49428bf04416f0bc45c6a5..fdd99edda7b4a4cddd87b45296d68051e81b8bfa 100644 (file)
@@ -130,7 +130,7 @@ intel_region_release(struct intel_region **region)
 /*
  * XXX Move this into core Mesa?
  */
-static void
+void
 _mesa_copy_rect(GLubyte * dst,
                 GLuint cpp,
                 GLuint dst_pitch,
index b6a3b5a7397f7c390954dec46699ef60f4fa656e..0d1dabe9ca789519951c61f8ec8261807c8bea17 100644 (file)
@@ -122,4 +122,14 @@ dri_bo *intel_region_buffer(struct intel_context *intel,
                            struct intel_region *region,
                            GLuint flag);
 
+void _mesa_copy_rect(GLubyte * dst,
+                GLuint cpp,
+                GLuint dst_pitch,
+                GLuint dst_x,
+                GLuint dst_y,
+                GLuint width,
+                GLuint height,
+                const GLubyte * src,
+                GLuint src_pitch, GLuint src_x, GLuint src_y);
+
 #endif
index 4f5f75d0492a280e1f865bc81ad17e6719de36b5..8f9f9897e870cb558c41f272fa959cc6b40ccf78 100644 (file)
@@ -493,7 +493,17 @@ intelTexImage(GLcontext * ctx,
     * conversion and copy:
     */
    if (compressed) {
-     memcpy(texImage->Data, pixels, imageSize);
+       if (intelImage->mt) {
+          struct intel_region *dst = intelImage->mt->region;
+          _mesa_copy_rect(texImage->Data, dst->cpp, dst->pitch,
+                  0, 0,
+                  intelImage->mt->level[intelImage->level].width,
+                  intelImage->mt->level[intelImage->level].height/4,
+                  pixels,
+                  intelImage->base.RowStride,
+                  0, 0);
+       } else
+           memcpy(texImage->Data, pixels, imageSize);
    } else if (!texImage->TexFormat->StoreImage(ctx, dims, 
                                               texImage->_BaseFormat, 
                                               texImage->TexFormat,