summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-11-28 11:02:59 -0800
committerEric Anholt <[email protected]>2011-12-07 13:36:57 -0800
commit221a36514b4ecffdaa3be5c43e67c75cc8c30ab8 (patch)
tree651723b3c5f380016c0c58dabbf112e41f009afa
parentb75291c61c40a3a690b08f8aa013ad2d3d2deda8 (diff)
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 <[email protected]>
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c37
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.h19
2 files changed, 51 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 78d572f2385..f7228d8cfd0 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -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);
}
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 56541d5b60c..50f8b820228 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -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;
};