[Mesa-dev] [PATCH 13/13] i965/miptree: recurse to miptree_map for depth in map_depthstencil
Scott D Phillips
scott.d.phillips at intel.com
Mon Apr 30 17:25:52 UTC 2018
Call back to intel_miptree_map when mapping the separate depth
miptree in map_depthstencil. This brings us back to the mapping
method decision tree in miptree_map where we will then find the
best mapping method for depth.
---
src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 58 ++++++++++++++++-----------
1 file changed, 35 insertions(+), 23 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 948ddc4969e..d7908aeb906 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -3525,44 +3525,50 @@ intel_miptree_unmap_depthstencil(struct brw_context *brw,
if (map->mode & GL_MAP_WRITE_BIT) {
uint32_t *packed_map = map->ptr;
uint8_t *s_map = intel_miptree_map_raw(brw, s_mt, GL_MAP_WRITE_BIT);
- uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_WRITE_BIT);
unsigned int s_image_x, s_image_y;
- unsigned int z_image_x, z_image_y;
intel_miptree_get_image_offset(s_mt, level, slice,
&s_image_x, &s_image_y);
- intel_miptree_get_image_offset(z_mt, level, slice,
- &z_image_x, &z_image_y);
+
+ struct intel_miptree_map z_map = {
+ .mode = GL_MAP_WRITE_BIT | BRW_MAP_DIRECT_BIT | GL_MAP_INVALIDATE_RANGE_BIT,
+ .x = map->x,
+ .y = map->y,
+ .w = map->w,
+ .h = map->h,
+ };
+ __intel_miptree_map(brw, z_mt, level, slice, &z_map);
+ assert(z_map.ptr);
for (uint32_t y = 0; y < map->h; y++) {
+ uint32_t *z_line =
+ (uint32_t *)((uint8_t *)z_map.ptr + z_map.stride * y);
for (uint32_t x = 0; x < map->w; x++) {
ptrdiff_t s_offset = intel_offset_S8(s_mt->surf.row_pitch,
x + s_image_x + map->x,
y + s_image_y + map->y,
brw->has_swizzling);
- ptrdiff_t z_offset = ((y + z_image_y + map->y) *
- (z_mt->surf.row_pitch / 4) +
- (x + z_image_x + map->x));
if (map_z32f_x24s8) {
- z_map[z_offset] = packed_map[(y * map->w + x) * 2 + 0];
+ z_line[x] = packed_map[(y * map->w + x) * 2 + 0];
s_map[s_offset] = packed_map[(y * map->w + x) * 2 + 1];
} else {
uint32_t packed = packed_map[y * map->w + x];
s_map[s_offset] = packed >> 24;
- z_map[z_offset] = packed;
+ z_line[x] = packed;
}
}
}
+ __intel_miptree_unmap(brw, z_mt, level, slice, &z_map);
intel_miptree_unmap_raw(s_mt);
- intel_miptree_unmap_raw(z_mt);
- DBG("%s: %d,%d %dx%d from z mt %p (%s) %d,%d, s mt %p %d,%d = %p/%d\n",
+ DBG("%s: %d,%d %dx%d from z mt %p (%s) %d,%d @ (level: %d, slice: %d),"
+ " s mt %p %d,%d = %p/%d\n",
__func__,
map->x, map->y, map->w, map->h,
z_mt, _mesa_get_format_name(z_mt->format),
- map->x + z_image_x, map->y + z_image_y,
+ map->x, map->y, level, slice,
s_mt, map->x + s_image_x, map->y + s_image_y,
map->ptr, map->stride);
}
@@ -3594,27 +3600,32 @@ intel_miptree_map_depthstencil(struct brw_context *brw,
if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
uint32_t *packed_map = map->ptr;
uint8_t *s_map = intel_miptree_map_raw(brw, s_mt, GL_MAP_READ_BIT);
- uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_READ_BIT);
unsigned int s_image_x, s_image_y;
- unsigned int z_image_x, z_image_y;
intel_miptree_get_image_offset(s_mt, level, slice,
&s_image_x, &s_image_y);
- intel_miptree_get_image_offset(z_mt, level, slice,
- &z_image_x, &z_image_y);
+
+ struct intel_miptree_map z_map = {
+ .mode = GL_MAP_READ_BIT | BRW_MAP_DIRECT_BIT,
+ .x = map->x,
+ .y = map->y,
+ .w = map->w,
+ .h = map->h,
+ };
+ __intel_miptree_map(brw, z_mt, level, slice, &z_map);
+ assert(z_map.ptr);
for (uint32_t y = 0; y < map->h; y++) {
+ uint32_t *z_line =
+ (uint32_t *)((uint8_t *)z_map.ptr + z_map.stride * y);
for (uint32_t x = 0; x < map->w; x++) {
int map_x = map->x + x, map_y = map->y + y;
ptrdiff_t s_offset = intel_offset_S8(s_mt->surf.row_pitch,
map_x + s_image_x,
map_y + s_image_y,
brw->has_swizzling);
- ptrdiff_t z_offset = ((map_y + z_image_y) *
- (z_mt->surf.row_pitch / 4) +
- (map_x + z_image_x));
uint8_t s = s_map[s_offset];
- uint32_t z = z_map[z_offset];
+ uint32_t z = z_line[x];
if (map_z32f_x24s8) {
packed_map[(y * map->w + x) * 2 + 0] = z;
@@ -3625,13 +3636,14 @@ intel_miptree_map_depthstencil(struct brw_context *brw,
}
}
+ __intel_miptree_unmap(brw, z_mt, level, slice, &z_map);
intel_miptree_unmap_raw(s_mt);
- intel_miptree_unmap_raw(z_mt);
- DBG("%s: %d,%d %dx%d from z mt %p %d,%d, s mt %p %d,%d = %p/%d\n",
+ DBG("%s: %d,%d %dx%d from z mt %p %d,%d @ (level: %d, slice: %d),"
+ " s mt %p %d,%d = %p/%d\n",
__func__,
map->x, map->y, map->w, map->h,
- z_mt, map->x + z_image_x, map->y + z_image_y,
+ z_mt, map->x, map->y, level, slice,
s_mt, map->x + s_image_x, map->y + s_image_y,
map->ptr, map->stride);
} else {
--
2.14.3
More information about the mesa-dev
mailing list