d3d1x: fix translation of subresource to layer
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 20 Oct 2011 18:12:51 +0000 (20:12 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 21 Oct 2011 21:00:37 +0000 (23:00 +0200)
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h

index bbeeb8c3c954a6e83786900eef3876dd6ac0bbf8..f3db3843bef8f34aa41ea199cacd22bd4da97d6c 100644 (file)
@@ -1428,7 +1428,7 @@ changed:
                }
        }
 
-       static unsigned d3d11_subresource_to_face(struct pipe_resource* resource, unsigned subresource)
+       static unsigned d3d11_subresource_to_layer(struct pipe_resource* resource, unsigned subresource)
        {
                if(subresource <= resource->last_level)
                {
@@ -1458,9 +1458,9 @@ changed:
                if(resource->transfers.count(subresource))
                        return E_FAIL;
                unsigned level = d3d11_subresource_to_level(resource->resource, subresource);
-               unsigned face = d3d11_subresource_to_face(resource->resource, subresource);
+               unsigned layer = d3d11_subresource_to_layer(resource->resource, subresource);
                pipe_box box = d3d11_to_pipe_box(resource->resource, level, 0);
-               /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */
+               box.z += layer;
                unsigned usage = 0;
                if(map_type == D3D11_MAP_READ)
                        usage = PIPE_TRANSFER_READ;
@@ -1519,11 +1519,12 @@ changed:
                GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource;
                GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource;
                unsigned dst_level = d3d11_subresource_to_level(dst->resource, dst_subresource);
-               unsigned dst_face = d3d11_subresource_to_face(dst->resource, dst_subresource);
+               unsigned dst_layer = d3d11_subresource_to_layer(dst->resource, dst_subresource);
                unsigned src_level = d3d11_subresource_to_level(src->resource, src_subresource);
-               unsigned src_face = d3d11_subresource_to_face(src->resource, src_subresource);
-               /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */
+               unsigned src_layer = d3d11_subresource_to_layer(src->resource, src_subresource);
                pipe_box box = d3d11_to_pipe_box(src->resource, src_level, src_box);
+               dst_z += dst_layer;
+               box.z += src_layer;
                {
                        pipe->resource_copy_region(pipe,
                                dst->resource, dst_level, dst_x, dst_y, dst_z,
@@ -1541,17 +1542,14 @@ changed:
                unsigned level;
                for(level = 0; level <= dst->resource->last_level; ++level)
                {
-                       unsigned layers = 1;
                        pipe_box box;
-                       if (dst->resource->target == PIPE_TEXTURE_CUBE)
-                               layers = 6;
-                       else if (dst->resource->target == PIPE_TEXTURE_3D)
-                               layers = u_minify(dst->resource->depth0, level);
-                       /* else layers = dst->resource->array_size; */
                        box.x = box.y = box.z = 0;
                        box.width = u_minify(dst->resource->width0, level);
                        box.height = u_minify(dst->resource->height0, level);
-                       box.depth = layers;
+                       if(dst->resource->target == PIPE_TEXTURE_3D)
+                               box.depth = u_minify(dst->resource->depth0, level);
+                       else
+                               box.depth = dst->resource->array_size;
                        pipe->resource_copy_region(pipe,
                                                   dst->resource, level, 0, 0, 0,
                                                   src->resource, level, &box);
@@ -1569,8 +1567,9 @@ changed:
                SYNCHRONIZED;
                GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource;
                unsigned dst_level = d3d11_subresource_to_level(dst->resource, dst_subresource);
-               /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */
+               unsigned dst_layer = d3d11_subresource_to_layer(dst->resource, dst_subresource);
                pipe_box box = d3d11_to_pipe_box(dst->resource, dst_level, pDstBox);
+               box.z += dst_layer;
                pipe->transfer_inline_write(pipe, dst->resource, dst_level, PIPE_TRANSFER_WRITE, &box, pSrcData, src_row_pitch, src_depth_pitch);
        }
 
@@ -1737,8 +1736,8 @@ changed:
                info.dst.res = dst->resource;
                info.src.res = src->resource;
                info.dst.level = 0;
-               info.dst.layer = d3d11_subresource_to_face(dst->resource, dst_subresource);
-               info.src.layer = d3d11_subresource_to_face(src->resource, src_subresource);
+               info.dst.layer = d3d11_subresource_to_layer(dst->resource, dst_subresource);
+               info.src.layer = d3d11_subresource_to_layer(src->resource, src_subresource);
 
                info.src.x0 = 0;
                info.src.x1 = info.src.res->width0;