Hi,

This should fix the problem with depth-stencil textures mentioned in
the commit message for my GL_ARB_clear_texture patch here:

http://lists.freedesktop.org/archives/mesa-dev/2014-June/060739.html

- Neil

------- >8 --------------- (use git am --scissors to automatically chop here)

intel_miptree_unmap_depthstencil was not taking into account the offset of the
mapping when calculating the address to store the depth value. This was making
glTexSubImage2D update the wrong texels if it was used with a non-zero offset
on a depth-stencil texture. This patch makes the loop look more like the
equivalent one in intel_miptree_map_depthstencil so that it will use the right
location.
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index dd7e57a..2fee6e48 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -2136,13 +2136,14 @@ intel_miptree_unmap_depthstencil(struct brw_context 
*brw,
 
       for (uint32_t y = 0; y < map->h; 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->pitch,
-                                                x + s_image_x + map->x,
-                                                y + s_image_y + map->y,
+                                                map_x + s_image_x,
+                                                map_y + s_image_y,
                                                 brw->has_swizzling);
-           ptrdiff_t z_offset = ((y + z_image_y) *
+           ptrdiff_t z_offset = ((map_y + z_image_y) *
                                   (z_mt->pitch / 4) +
-                                 (x + z_image_x));
+                                 (map_x + z_image_x));
 
            if (map_z32f_x24s8) {
               z_map[z_offset] = packed_map[(y * map->w + x) * 2 + 0];
-- 
1.9.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to