assert(mt->level[level].slice == NULL);
- mt->level[level].slice = malloc(d * sizeof(*mt->level[0].slice));
+ mt->level[level].slice = calloc(d, sizeof(*mt->level[0].slice));
mt->level[level].slice[0].x_offset = mt->level[level].level_x;
mt->level[level].slice[0].y_offset = mt->level[level].level_y;
}
void **out_ptr,
int *out_stride)
{
+ struct intel_miptree_map *map;
unsigned int bw, bh;
void *base;
unsigned int image_x, image_y;
+ map = calloc(1, sizeof(struct intel_miptree_map));
+ if (!map){
+ *out_ptr = NULL;
+ *out_stride = 0;
+ return;
+ }
+
+ assert(!mt->level[level].slice[slice].map);
+ mt->level[level].slice[slice].map = map;
+ map->mode = mode;
+ map->x = x;
+ map->y = y;
+ map->w = w;
+ map->h = h;
+
if (mt->stencil_mt) {
/* The miptree has depthstencil format, but uses separate stencil. The
* embedded stencil miptree contains the real stencil data, so gather
x += image_x;
y += image_y;
- *out_stride = mt->region->pitch * mt->cpp;
- *out_ptr = base + y * *out_stride + x * mt->cpp;
+ map->stride = mt->region->pitch * mt->cpp;
+ map->ptr = base + y * map->stride + x * mt->cpp;
+
+ *out_ptr = map->ptr;
+ *out_stride = map->stride;
DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
- x - image_x, y - image_y, w, h,
+ map->x, map->y, map->w, map->h,
mt, _mesa_get_format_name(mt->format),
- x, y, *out_ptr, *out_stride);
+ x, y, map->ptr, map->stride);
}
void
unsigned int level,
unsigned int slice)
{
+ struct intel_miptree_map *map = mt->level[level].slice[slice].map;
+
+ if (!map)
+ return;
+
DBG("%s: mt %p (%s) level %d slice %d\n", __FUNCTION__,
mt, _mesa_get_format_name(mt->format), level, slice);
*/
intel_miptree_s8z24_scatter(intel, mt, level, slice);
}
+
+ mt->level[level].slice[slice].map = NULL;
+ free(map);
}
struct intel_resolve_map;
struct intel_texture_image;
+struct intel_miptree_map {
+ /** Bitfield of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_BIT */
+ GLbitfield mode;
+ /** Region of interest for the map. */
+ int x, y, w, h;
+ /** Possibly malloced temporary buffer for the mapping. */
+ void *buffer;
+ /** Pointer to the start of (map_x, map_y) returned by the mapping. */
+ void *ptr;
+ /** Stride of the mapping. */
+ int stride;
+};
+
/**
* Describes the location of each texture image within a texture region.
*/
GLuint x_offset;
GLuint y_offset;
/** \} */
+
+ /**
+ * Pointer to mapping information, present across
+ * intel_tex_image_map()/unmap of the slice.
+ */
+ struct intel_miptree_map *map;
} *slice;
};