intel: Make mapping of texture slices track the region of interest.

This will be used for things like packed depth/stencil temporaries and
making LLC-cached temporary mappings using blits.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
This commit is contained in:
Eric Anholt 2011-11-28 11:02:59 -08:00
parent b75291c61c
commit 221a36514b
2 changed files with 51 additions and 5 deletions

View File

@ -346,7 +346,7 @@ intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
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;
}
@ -746,10 +746,26 @@ intel_miptree_map(struct intel_context *intel,
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
@ -781,13 +797,16 @@ intel_miptree_map(struct intel_context *intel,
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
@ -796,6 +815,11 @@ intel_miptree_unmap(struct intel_context *intel,
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);
@ -811,4 +835,7 @@ intel_miptree_unmap(struct intel_context *intel,
*/
intel_miptree_s8z24_scatter(intel, mt, level, slice);
}
mt->level[level].slice[slice].map = NULL;
free(map);
}

View File

@ -62,6 +62,19 @@
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.
*/
@ -110,6 +123,12 @@ struct intel_mipmap_level
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;
};