anv/meta: Disambiguate slice variable value
authorNanley Chery <nanley.g.chery@intel.com>
Wed, 27 Jan 2016 02:00:14 +0000 (18:00 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 27 Jan 2016 23:12:42 +0000 (15:12 -0800)
This will simplify the usage of
isl_surf_get_image_intratile_offset_el().

src/vulkan/anv_meta.c

index cbdb2fa188908b15c8e69975fc14c23cca116ca2..65f07eb4bce542f3a531a361f7084a0d2db9f400 100644 (file)
@@ -1306,16 +1306,11 @@ void anv_CmdCopyBufferToImage(
                                                   &pRegions[r].imageSubresource,
                                                   &pRegions[r].imageOffset);
 
-      unsigned num_slices;
-      if (dest_image->type == VK_IMAGE_TYPE_3D) {
-         assert(pRegions[r].imageSubresource.layerCount == 1);
-         num_slices = pRegions[r].imageExtent.depth;
-      } else {
-         assert(pRegions[r].imageExtent.depth == 1);
-         num_slices = pRegions[r].imageSubresource.layerCount;
-      }
-
-      for (unsigned slice = 0; slice < num_slices; slice++) {
+      unsigned num_slices_3d = pRegions[r].imageExtent.depth;
+      unsigned num_slices_array = pRegions[r].imageSubresource.layerCount;
+      unsigned slice_3d = 0;
+      unsigned slice_array = 0;
+      while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
          struct anv_image_view src_iview;
          anv_image_view_init(&src_iview, cmd_buffer->device,
             &(VkImageViewCreateInfo) {
@@ -1344,7 +1339,8 @@ void anv_CmdCopyBufferToImage(
                   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                   .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
                   .levelCount = 1,
-                  .baseArrayLayer = dest_base_array_slice + slice,
+                  .baseArrayLayer = dest_base_array_slice +
+                                    slice_array + slice_3d,
                   .layerCount = 1
                },
             },
@@ -1375,6 +1371,11 @@ void anv_CmdCopyBufferToImage(
          src_image->offset += src_image->extent.width *
                               src_image->extent.height *
                               src_image->format->isl_layout->bs;
+
+         if (dest_image->type == VK_IMAGE_TYPE_3D)
+            slice_3d++;
+         else
+            slice_array++;
       }
 
       anv_DestroyImage(vk_device, anv_image_to_handle(src_image),