vk/meta: Add an initial implementation of vkCmdBlitImage
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 May 2015 16:06:06 +0000 (09:06 -0700)
committerKristian Høgsberg <kristian.h.kristensen@intel.com>
Mon, 18 May 2015 17:27:08 +0000 (10:27 -0700)
Compile-tested only

src/vulkan/meta.c

index c734b157f21b5ddca54e23c8857c3bfc88721f40..c57b222fb71c38f20034fcf7d2f6f52f5ee8bb6c 100644 (file)
@@ -712,7 +712,61 @@ void anv_CmdBlitImage(
     uint32_t                                    regionCount,
     const VkImageBlit*                          pRegions)
 {
-   stub();
+   struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *)cmdBuffer;
+   VkDevice vk_device = (VkDevice) cmd_buffer->device;
+   struct anv_image *src_image = (struct anv_image *)srcImage;
+   struct anv_image *dest_image = (struct anv_image *)destImage;
+   struct anv_saved_state saved_state;
+
+   meta_prepare_blit(cmd_buffer, &saved_state);
+
+   for (unsigned r = 0; r < regionCount; r++) {
+      VkImageViewCreateInfo src_view_info = {
+         .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
+         .image = srcImage,
+         .viewType = VK_IMAGE_VIEW_TYPE_2D,
+         .format = src_image->format,
+         .channels = {
+            VK_CHANNEL_SWIZZLE_R,
+            VK_CHANNEL_SWIZZLE_G,
+            VK_CHANNEL_SWIZZLE_B,
+            VK_CHANNEL_SWIZZLE_A
+         },
+         .subresourceRange = {
+            .aspect = pRegions[r].srcSubresource.aspect,
+            .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
+            .mipLevels = 1,
+            .baseArraySlice = pRegions[r].srcSubresource.arraySlice,
+            .arraySize = 1
+         },
+         .minLod = 0
+      };
+
+      VkImageView src_view;
+      vkCreateImageView(vk_device, &src_view_info, &src_view);
+
+      VkColorAttachmentViewCreateInfo dest_view_info = {
+         .sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
+         .image = destImage,
+         .format = dest_image->format,
+         .mipLevel = pRegions[r].destSubresource.mipLevel,
+         .baseArraySlice = pRegions[r].destSubresource.arraySlice,
+         .arraySize = 1,
+      };
+
+      VkColorAttachmentView dest_view;
+      vkCreateColorAttachmentView(vk_device, &dest_view_info, &dest_view);
+
+      meta_emit_blit(cmd_buffer,
+                     (struct anv_surface_view *)src_view,
+                     pRegions[r].srcOffset,
+                     pRegions[r].srcExtent,
+                     (struct anv_surface_view *)dest_view,
+                     pRegions[r].destOffset,
+                     pRegions[r].destExtent);
+   }
+
+   meta_finish_blit(cmd_buffer, &saved_state);
 }
 
 void anv_CmdCopyBufferToImage(