st/mesa: set pipe_image_view layers correctly for 3D textures
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 10 Feb 2016 16:19:55 +0000 (11:19 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 16 Feb 2016 03:22:33 +0000 (22:22 -0500)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/mesa/state_tracker/st_atom_image.c

index ff365377ac80c73017c800946df1e1f83f1ad5bc..4b48bc30b6962c05ef97cd8f30a8f9619265f633 100644 (file)
@@ -84,13 +84,23 @@ st_bind_images(struct st_context *st, struct gl_shader *shader,
          img->u.buf.last_element  = f + (n - 1);
       } else {
          img->u.tex.level = u->Level + stObj->base.MinLevel;
-         img->u.tex.first_layer = u->_Layer + stObj->base.MinLayer;
-         img->u.tex.last_layer = u->_Layer + stObj->base.MinLayer;
-         if (u->Layered && img->resource->array_size > 1) {
-            if (stObj->base.Immutable)
-               img->u.tex.last_layer += stObj->base.NumLayers - 1;
-            else
-               img->u.tex.last_layer += img->resource->array_size - 1;
+         if (stObj->pt->target == PIPE_TEXTURE_3D) {
+            if (u->Layered) {
+               img->u.tex.first_layer = 0;
+               img->u.tex.last_layer = u_minify(stObj->pt->depth0, img->u.tex.level) - 1;
+            } else {
+               img->u.tex.first_layer = u->_Layer;
+               img->u.tex.last_layer = u->_Layer;
+            }
+         } else {
+            img->u.tex.first_layer = u->_Layer + stObj->base.MinLayer;
+            img->u.tex.last_layer = u->_Layer + stObj->base.MinLayer;
+            if (u->Layered && img->resource->array_size > 1) {
+               if (stObj->base.Immutable)
+                  img->u.tex.last_layer += stObj->base.NumLayers - 1;
+               else
+                  img->u.tex.last_layer += img->resource->array_size - 1;
+            }
          }
       }
    }