- _mesa_get_format_block_size(tex_image->TexFormat, &bw, &bh);
- assert(y % bh == 0);
- y /= bh;
-
- if (likely(mt)) {
- void *base = intel_region_map(intel, mt->region);
- unsigned int image_x, image_y;
-
- intel_miptree_get_image_offset(mt, tex_image->Level, tex_image->Face,
- slice, &image_x, &image_y);
- x += image_x;
- y += image_y;
-
- *stride = mt->region->pitch * mt->cpp;
- *map = base + y * *stride + x * mt->cpp;
-
- DBG("%s: %d,%d %dx%d from mt %p %d,%d = %p/%d\n", __FUNCTION__,
- x - image_x, y - image_y, w, h,
- mt, x, y, *map, *stride);
- } else {
- /* texture data is in malloc'd memory */
- GLuint width = tex_image->Width;
- GLuint height = ALIGN(tex_image->Height, bh) / bh;
- GLuint texelSize = _mesa_get_format_bytes(tex_image->TexFormat);
-
- assert(map);
-
- *stride = _mesa_format_row_stride(tex_image->TexFormat, width);
- *map = tex_image->Data + (slice * height + y) * *stride + x * texelSize;