anv: Add initial support for cube maps
[mesa.git] / src / vulkan / anv_meta.c
index eabe207389e8ed436995a64ecb878a9a354538e2..63976cdfe4238aa4b535f9294db19c96636e0e8c 100644 (file)
@@ -145,31 +145,27 @@ anv_meta_restore(const struct anv_meta_saved_state *state,
    cmd_buffer->state.dirty |= state->dynamic_mask;
 }
 
-static VkImageViewType
-meta_blit_get_src_image_view_type(const struct anv_image *src_image)
+VkImageViewType
+anv_meta_get_view_type(const struct anv_image *image)
 {
-   switch (src_image->type) {
-   case VK_IMAGE_TYPE_1D:
-      return VK_IMAGE_VIEW_TYPE_1D;
-   case VK_IMAGE_TYPE_2D:
-      return VK_IMAGE_VIEW_TYPE_2D;
-   case VK_IMAGE_TYPE_3D:
-      return VK_IMAGE_VIEW_TYPE_3D;
+   switch (image->type) {
+   case VK_IMAGE_TYPE_1D: return VK_IMAGE_VIEW_TYPE_1D;
+   case VK_IMAGE_TYPE_2D: return VK_IMAGE_VIEW_TYPE_2D;
+   case VK_IMAGE_TYPE_3D: return VK_IMAGE_VIEW_TYPE_3D;
    default:
-      assert(!"bad VkImageType");
-      return 0;
+      unreachable("bad VkImageViewType");
    }
 }
 
 static uint32_t
 meta_blit_get_dest_view_base_array_slice(const struct anv_image *dest_image,
-                                         const VkImageSubresourceCopy *dest_subresource,
+                                         const VkImageSubresourceLayers *dest_subresource,
                                          const VkOffset3D *dest_offset)
 {
    switch (dest_image->type) {
    case VK_IMAGE_TYPE_1D:
    case VK_IMAGE_TYPE_2D:
-      return dest_subresource->arrayLayer;
+      return dest_subresource->baseArrayLayer;
    case VK_IMAGE_TYPE_3D:
       /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer,
        * but meta does it anyway. When doing so, we translate the
@@ -190,7 +186,6 @@ anv_device_init_meta_blit_state(struct anv_device *device)
          .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
          .attachmentCount = 1,
          .pAttachments = &(VkAttachmentDescription) {
-            .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
             .format = VK_FORMAT_UNDEFINED, /* Our shaders don't care */
             .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
             .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
@@ -199,143 +194,121 @@ anv_device_init_meta_blit_state(struct anv_device *device)
          },
          .subpassCount = 1,
          .pSubpasses = &(VkSubpassDescription) {
-            .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION,
             .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
-            .inputCount = 0,
-            .colorCount = 1,
+            .inputAttachmentCount = 0,
+            .colorAttachmentCount = 1,
             .pColorAttachments = &(VkAttachmentReference) {
                .attachment = 0,
                .layout = VK_IMAGE_LAYOUT_GENERAL,
             },
             .pResolveAttachments = NULL,
-            .depthStencilAttachment = (VkAttachmentReference) {
+            .pDepthStencilAttachment = &(VkAttachmentReference) {
                .attachment = VK_ATTACHMENT_UNUSED,
                .layout = VK_IMAGE_LAYOUT_GENERAL,
             },
-            .preserveCount = 1,
+            .preserveAttachmentCount = 1,
             .pPreserveAttachments = &(VkAttachmentReference) {
                .attachment = 0,
                .layout = VK_IMAGE_LAYOUT_GENERAL,
             },
          },
          .dependencyCount = 0,
-      }, &device->meta_state.blit.render_pass);
+      }, NULL, &device->meta_state.blit.render_pass);
 
    /* We don't use a vertex shader for clearing, but instead build and pass
     * the VUEs directly to the rasterization backend.  However, we do need
     * to provide GLSL source for the vertex shader so that the compiler
     * does not dead-code our inputs.
     */
-   struct anv_shader_module vsm = {
+   struct anv_shader_module vs = {
       .nir = build_nir_vertex_shader(false),
    };
 
-   struct anv_shader_module fsm_2d = {
+   struct anv_shader_module fs_2d = {
       .nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D),
    };
 
-   struct anv_shader_module fsm_3d = {
+   struct anv_shader_module fs_3d = {
       .nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D),
    };
 
-   VkShader vs;
-   anv_CreateShader(anv_device_to_handle(device),
-      &(VkShaderCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
-         .module = anv_shader_module_to_handle(&vsm),
-         .pName = "main",
-      }, &vs);
-
-   VkShader fs_2d;
-   anv_CreateShader(anv_device_to_handle(device),
-      &(VkShaderCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
-         .module = anv_shader_module_to_handle(&fsm_2d),
-         .pName = "main",
-      }, &fs_2d);
-
-   VkShader fs_3d;
-   anv_CreateShader(anv_device_to_handle(device),
-      &(VkShaderCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
-         .module = anv_shader_module_to_handle(&fsm_3d),
-         .pName = "main",
-      }, &fs_3d);
-
    VkPipelineVertexInputStateCreateInfo vi_create_info = {
       .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
-      .bindingCount = 2,
+      .vertexBindingDescriptionCount = 2,
       .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) {
          {
             .binding = 0,
-            .strideInBytes = 0,
+            .stride = 0,
             .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
          },
          {
             .binding = 1,
-            .strideInBytes = 5 * sizeof(float),
+            .stride = 5 * sizeof(float),
             .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
          },
       },
-      .attributeCount = 3,
+      .vertexAttributeDescriptionCount = 3,
       .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) {
          {
             /* VUE Header */
             .location = 0,
             .binding = 0,
             .format = VK_FORMAT_R32G32B32A32_UINT,
-            .offsetInBytes = 0
+            .offset = 0
          },
          {
             /* Position */
             .location = 1,
             .binding = 1,
             .format = VK_FORMAT_R32G32_SFLOAT,
-            .offsetInBytes = 0
+            .offset = 0
          },
          {
             /* Texture Coordinate */
             .location = 2,
             .binding = 1,
             .format = VK_FORMAT_R32G32B32_SFLOAT,
-            .offsetInBytes = 8
+            .offset = 8
          }
       }
    };
 
    VkDescriptorSetLayoutCreateInfo ds_layout_info = {
       .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
-      .count = 1,
+      .bindingCount = 1,
       .pBinding = (VkDescriptorSetLayoutBinding[]) {
          {
+            .binding = 0,
             .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
-            .arraySize = 1,
+            .descriptorCount = 1,
             .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
             .pImmutableSamplers = NULL
          },
       }
    };
    anv_CreateDescriptorSetLayout(anv_device_to_handle(device), &ds_layout_info,
-                                 &device->meta_state.blit.ds_layout);
+                                 NULL, &device->meta_state.blit.ds_layout);
 
    anv_CreatePipelineLayout(anv_device_to_handle(device),
       &(VkPipelineLayoutCreateInfo) {
          .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
-         .descriptorSetCount = 1,
+         .setLayoutCount = 1,
          .pSetLayouts = &device->meta_state.blit.ds_layout,
       },
-      &device->meta_state.blit.pipeline_layout);
+      NULL, &device->meta_state.blit.pipeline_layout);
 
    VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
       {
          .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
-         .stage = VK_SHADER_STAGE_VERTEX,
-         .shader = vs,
+         .stage = VK_SHADER_STAGE_VERTEX_BIT,
+         .module = anv_shader_module_to_handle(&vs),
+         .pName = "main",
          .pSpecializationInfo = NULL
       }, {
          .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
-         .stage = VK_SHADER_STAGE_FRAGMENT,
-         .shader = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
+         .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
+         .module = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
+         .pName = "main",
          .pSpecializationInfo = NULL
       },
    };
@@ -355,9 +328,8 @@ anv_device_init_meta_blit_state(struct anv_device *device)
          .viewportCount = 1,
          .scissorCount = 1,
       },
-      .pRasterState = &(VkPipelineRasterStateCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO,
-         .depthClipEnable = true,
+      .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
+         .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
          .rasterizerDiscardEnable = false,
          .polygonMode = VK_POLYGON_MODE_FILL,
          .cullMode = VK_CULL_MODE_NONE,
@@ -365,7 +337,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       },
       .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
          .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
-         .rasterSamples = 1,
+         .rasterizationSamples = 1,
          .sampleShadingEnable = false,
          .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
       },
@@ -373,8 +345,11 @@ anv_device_init_meta_blit_state(struct anv_device *device)
          .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
          .attachmentCount = 1,
          .pAttachments = (VkPipelineColorBlendAttachmentState []) {
-            { .channelWriteMask = VK_CHANNEL_A_BIT |
-                 VK_CHANNEL_R_BIT | VK_CHANNEL_G_BIT | VK_CHANNEL_B_BIT },
+            { .colorWriteMask =
+                 VK_COLOR_COMPONENT_A_BIT |
+                 VK_COLOR_COMPONENT_R_BIT |
+                 VK_COLOR_COMPONENT_G_BIT |
+                 VK_COLOR_COMPONENT_B_BIT },
          }
       },
       .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
@@ -406,22 +381,19 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       .use_rectlist = true
    };
 
-   pipeline_shader_stages[1].shader = fs_2d;
+   pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_2d);
    anv_graphics_pipeline_create(anv_device_to_handle(device),
       &vk_pipeline_info, &anv_pipeline_info,
-      &device->meta_state.blit.pipeline_2d_src);
+      NULL, &device->meta_state.blit.pipeline_2d_src);
 
-   pipeline_shader_stages[1].shader = fs_3d;
+   pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_3d);
    anv_graphics_pipeline_create(anv_device_to_handle(device),
       &vk_pipeline_info, &anv_pipeline_info,
-      &device->meta_state.blit.pipeline_3d_src);
-
-   anv_DestroyShader(anv_device_to_handle(device), vs);
-   anv_DestroyShader(anv_device_to_handle(device), fs_2d);
-   anv_DestroyShader(anv_device_to_handle(device), fs_3d);
-   ralloc_free(vsm.nir);
-   ralloc_free(fsm_2d.nir);
-   ralloc_free(fsm_3d.nir);
+      NULL, &device->meta_state.blit.pipeline_3d_src);
+
+   ralloc_free(vs.nir);
+   ralloc_free(fs_2d.nir);
+   ralloc_free(fs_3d.nir);
 }
 
 static void
@@ -449,7 +421,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
                struct anv_image_view *dest_iview,
                VkOffset3D dest_offset,
                VkExtent3D dest_extent,
-               VkTexFilter blit_filter)
+               VkFilter blit_filter)
 {
    struct anv_device *device = cmd_buffer->device;
    VkDescriptorPool dummy_desc_pool = (VkDescriptorPool)1;
@@ -502,6 +474,8 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
       },
    };
 
+   anv_state_clflush(vb_state);
+
    struct anv_buffer vertex_buffer = {
       .device = device,
       .size = vb_size,
@@ -525,27 +499,31 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
          .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
          .magFilter = blit_filter,
          .minFilter = blit_filter,
-      }, &sampler);
+      }, &cmd_buffer->pool->alloc, &sampler);
 
    VkDescriptorSet set;
-   anv_AllocDescriptorSets(anv_device_to_handle(device), dummy_desc_pool,
-                           VK_DESCRIPTOR_SET_USAGE_ONE_SHOT,
-                           1, &device->meta_state.blit.ds_layout, &set);
+   anv_AllocateDescriptorSets(anv_device_to_handle(device),
+      &(VkDescriptorSetAllocateInfo) {
+         .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
+         .descriptorPool = dummy_desc_pool,
+         .setLayoutCount = 1,
+         .pSetLayouts = &device->meta_state.blit.ds_layout
+      }, &set);
    anv_UpdateDescriptorSets(anv_device_to_handle(device),
       1, /* writeCount */
       (VkWriteDescriptorSet[]) {
          {
             .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
-            .destSet = set,
-            .destBinding = 0,
-            .destArrayElement = 0,
-            .count = 1,
+            .dstSet = set,
+            .dstBinding = 0,
+            .dstArrayElement = 0,
+            .descriptorCount = 1,
             .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
-            .pDescriptors = (VkDescriptorInfo[]) {
+            .pImageInfo = (VkDescriptorImageInfo[]) {
                {
+                  .sampler = sampler,
                   .imageView = anv_image_view_to_handle(src_iview),
                   .imageLayout = VK_IMAGE_LAYOUT_GENERAL,
-                  .sampler = sampler,
                },
             }
          }
@@ -562,7 +540,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
          .width = dest_iview->extent.width,
          .height = dest_iview->extent.height,
          .layers = 1
-      }, &fb);
+      }, &cmd_buffer->pool->alloc, &fb);
 
    ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer),
       &(VkRenderPassBeginInfo) {
@@ -601,8 +579,8 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
 
    anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer), 1,
                       &(VkViewport) {
-                        .originX = 0.0f,
-                        .originY = 0.0f,
+                        .x = 0.0f,
+                        .y = 0.0f,
                         .width = dest_iview->extent.width,
                         .height = dest_iview->extent.height,
                         .minDepth = 0.0f,
@@ -622,8 +600,10 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
     * descriptor sets, etc. has been used.  We are free to delete it.
     */
    anv_descriptor_set_destroy(device, anv_descriptor_set_from_handle(set));
-   anv_DestroySampler(anv_device_to_handle(device), sampler);
-   anv_DestroyFramebuffer(anv_device_to_handle(device), fb);
+   anv_DestroySampler(anv_device_to_handle(device), sampler,
+                      &cmd_buffer->pool->alloc);
+   anv_DestroyFramebuffer(anv_device_to_handle(device), fb,
+                          &cmd_buffer->pool->alloc);
 }
 
 static void
@@ -668,7 +648,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
          .depth = 1,
       },
       .mipLevels = 1,
-      .arraySize = 1,
+      .arrayLayers = 1,
       .samples = 1,
       .tiling = VK_IMAGE_TILING_LINEAR,
       .usage = 0,
@@ -677,11 +657,13 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
 
    VkImage src_image;
    image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
-   anv_CreateImage(vk_device, &image_info, &src_image);
+   anv_CreateImage(vk_device, &image_info,
+                   &cmd_buffer->pool->alloc, &src_image);
 
    VkImage dest_image;
    image_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
-   anv_CreateImage(vk_device, &image_info, &dest_image);
+   anv_CreateImage(vk_device, &image_info,
+                   &cmd_buffer->pool->alloc, &dest_image);
 
    /* We could use a vk call to bind memory, but that would require
     * creating a dummy memory object etc. so there's really no point.
@@ -701,9 +683,9 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
          .subresourceRange = {
             .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .baseMipLevel = 0,
-            .mipLevels = 1,
+            .levelCount = 1,
             .baseArrayLayer = 0,
-            .arraySize = 1
+            .layerCount = 1
          },
       },
       cmd_buffer);
@@ -718,9 +700,9 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
          .subresourceRange = {
             .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .baseMipLevel = 0,
-            .mipLevels = 1,
+            .levelCount = 1,
             .baseArrayLayer = 0,
-            .arraySize = 1,
+            .layerCount = 1,
          },
       },
       cmd_buffer);
@@ -734,10 +716,10 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
                   &dest_iview,
                   (VkOffset3D) { 0, 0, 0 },
                   (VkExtent3D) { width, height, 1 },
-                  VK_TEX_FILTER_NEAREST);
+                  VK_FILTER_NEAREST);
 
-   anv_DestroyImage(vk_device, src_image);
-   anv_DestroyImage(vk_device, dest_image);
+   anv_DestroyImage(vk_device, src_image, &cmd_buffer->pool->alloc);
+   anv_DestroyImage(vk_device, dest_image, &cmd_buffer->pool->alloc);
 }
 
 void anv_CmdCopyBuffer(
@@ -757,8 +739,8 @@ void anv_CmdCopyBuffer(
 
    for (unsigned r = 0; r < regionCount; r++) {
       uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset;
-      uint64_t dest_offset = dest_buffer->offset + pRegions[r].destOffset;
-      uint64_t copy_size = pRegions[r].copySize;
+      uint64_t dest_offset = dest_buffer->offset + pRegions[r].dstOffset;
+      uint64_t copy_size = pRegions[r].size;
 
       /* First, we compute the biggest format that can be used with the
        * given offsets and size.
@@ -775,10 +757,10 @@ void anv_CmdCopyBuffer(
          bs = MIN2(bs, 1 << fs);
       assert(dest_offset % bs == 0);
 
-      fs = ffs(pRegions[r].copySize) - 1;
+      fs = ffs(pRegions[r].size) - 1;
       if (fs != -1)
          bs = MIN2(bs, 1 << fs);
-      assert(pRegions[r].copySize % bs == 0);
+      assert(pRegions[r].size % bs == 0);
 
       VkFormat copy_format = vk_format_for_size(bs);
 
@@ -831,9 +813,6 @@ void anv_CmdCopyImage(
    ANV_FROM_HANDLE(anv_image, src_image, srcImage);
    ANV_FROM_HANDLE(anv_image, dest_image, destImage);
 
-   const VkImageViewType src_iview_type =
-      meta_blit_get_src_image_view_type(src_image);
-
    struct anv_meta_saved_state saved_state;
 
    meta_prepare_blit(cmd_buffer, &saved_state);
@@ -844,40 +823,40 @@ void anv_CmdCopyImage(
          &(VkImageViewCreateInfo) {
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
-            .viewType = src_iview_type,
+            .viewType = anv_meta_get_view_type(src_image),
             .format = src_image->format->vk_format,
             .subresourceRange = {
-               .aspectMask = 1 << pRegions[r].srcSubresource.aspect,
+               .aspectMask = pRegions[r].srcSubresource.aspectMask,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
-               .mipLevels = 1,
-               .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer,
-               .arraySize = pRegions[r].destSubresource.arraySize,
+               .levelCount = 1,
+               .baseArrayLayer = pRegions[r].srcSubresource.baseArrayLayer,
+               .layerCount = pRegions[r].dstSubresource.layerCount,
             },
          },
          cmd_buffer);
 
       const VkOffset3D dest_offset = {
-         .x = pRegions[r].destOffset.x,
-         .y = pRegions[r].destOffset.y,
+         .x = pRegions[r].dstOffset.x,
+         .y = pRegions[r].dstOffset.y,
          .z = 0,
       };
 
       unsigned num_slices;
       if (src_image->type == VK_IMAGE_TYPE_3D) {
-         assert(pRegions[r].srcSubresource.arraySize == 1 &&
-                pRegions[r].destSubresource.arraySize == 1);
+         assert(pRegions[r].srcSubresource.layerCount == 1 &&
+                pRegions[r].dstSubresource.layerCount == 1);
          num_slices = pRegions[r].extent.depth;
       } else {
-         assert(pRegions[r].srcSubresource.arraySize ==
-                pRegions[r].destSubresource.arraySize);
+         assert(pRegions[r].srcSubresource.layerCount ==
+                pRegions[r].dstSubresource.layerCount);
          assert(pRegions[r].extent.depth == 1);
-         num_slices = pRegions[r].destSubresource.arraySize;
+         num_slices = pRegions[r].dstSubresource.layerCount;
       }
 
       const uint32_t dest_base_array_slice =
          meta_blit_get_dest_view_base_array_slice(dest_image,
-                                                  &pRegions[r].destSubresource,
-                                                  &pRegions[r].destOffset);
+                                                  &pRegions[r].dstSubresource,
+                                                  &pRegions[r].dstOffset);
 
       for (unsigned slice = 0; slice < num_slices; slice++) {
          VkOffset3D src_offset = pRegions[r].srcOffset;
@@ -888,14 +867,14 @@ void anv_CmdCopyImage(
             &(VkImageViewCreateInfo) {
                .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
                .image = destImage,
-               .viewType = VK_IMAGE_VIEW_TYPE_2D,
+               .viewType = anv_meta_get_view_type(dest_image),
                .format = dest_image->format->vk_format,
                .subresourceRange = {
                   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-                  .baseMipLevel = pRegions[r].destSubresource.mipLevel,
-                  .mipLevels = 1,
+                  .baseMipLevel = pRegions[r].dstSubresource.mipLevel,
+                  .levelCount = 1,
                   .baseArrayLayer = dest_base_array_slice + slice,
-                  .arraySize = 1
+                  .layerCount = 1
                },
             },
             cmd_buffer);
@@ -907,7 +886,7 @@ void anv_CmdCopyImage(
                         dest_image, &dest_iview,
                         dest_offset,
                         pRegions[r].extent,
-                        VK_TEX_FILTER_NEAREST);
+                        VK_FILTER_NEAREST);
       }
    }
 
@@ -922,19 +901,16 @@ void anv_CmdBlitImage(
     VkImageLayout                               destImageLayout,
     uint32_t                                    regionCount,
     const VkImageBlit*                          pRegions,
-    VkTexFilter                                 filter)
+    VkFilter                                    filter)
 
 {
    ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
    ANV_FROM_HANDLE(anv_image, src_image, srcImage);
    ANV_FROM_HANDLE(anv_image, dest_image, destImage);
 
-   const VkImageViewType src_iview_type =
-      meta_blit_get_src_image_view_type(src_image);
-
    struct anv_meta_saved_state saved_state;
 
-   anv_finishme("respect VkTexFilter");
+   anv_finishme("respect VkFilter");
 
    meta_prepare_blit(cmd_buffer, &saved_state);
 
@@ -944,33 +920,33 @@ void anv_CmdBlitImage(
          &(VkImageViewCreateInfo) {
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
-            .viewType = src_iview_type,
+            .viewType = anv_meta_get_view_type(src_image),
             .format = src_image->format->vk_format,
             .subresourceRange = {
-               .aspectMask = 1 << pRegions[r].srcSubresource.aspect,
+               .aspectMask = pRegions[r].srcSubresource.aspectMask,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
-               .mipLevels = 1,
-               .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer,
-               .arraySize = 1
+               .levelCount = 1,
+               .baseArrayLayer = pRegions[r].srcSubresource.baseArrayLayer,
+               .layerCount = 1
             },
          },
          cmd_buffer);
 
       const VkOffset3D dest_offset = {
-         .x = pRegions[r].destOffset.x,
-         .y = pRegions[r].destOffset.y,
+         .x = pRegions[r].dstOffset.x,
+         .y = pRegions[r].dstOffset.y,
          .z = 0,
       };
 
       const uint32_t dest_array_slice =
          meta_blit_get_dest_view_base_array_slice(dest_image,
-                                                  &pRegions[r].destSubresource,
-                                                  &pRegions[r].destOffset);
+                                                  &pRegions[r].dstSubresource,
+                                                  &pRegions[r].dstOffset);
 
-      if (pRegions[r].srcSubresource.arraySize > 1)
+      if (pRegions[r].srcSubresource.layerCount > 1)
          anv_finishme("FINISHME: copy multiple array layers");
 
-      if (pRegions[r].destExtent.depth > 1)
+      if (pRegions[r].dstExtent.depth > 1)
          anv_finishme("FINISHME: copy multiple depth layers");
 
       struct anv_image_view dest_iview;
@@ -978,14 +954,14 @@ void anv_CmdBlitImage(
          &(VkImageViewCreateInfo) {
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = destImage,
-            .viewType = VK_IMAGE_VIEW_TYPE_2D,
+            .viewType = anv_meta_get_view_type(dest_image),
             .format = dest_image->format->vk_format,
             .subresourceRange = {
                .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-               .baseMipLevel = pRegions[r].destSubresource.mipLevel,
-               .mipLevels = 1,
+               .baseMipLevel = pRegions[r].dstSubresource.mipLevel,
+               .levelCount = 1,
                .baseArrayLayer = dest_array_slice,
-               .arraySize = 1
+               .layerCount = 1
             },
          },
          cmd_buffer);
@@ -996,7 +972,7 @@ void anv_CmdBlitImage(
                      pRegions[r].srcExtent,
                      dest_image, &dest_iview,
                      dest_offset,
-                     pRegions[r].destExtent,
+                     pRegions[r].dstExtent,
                      filter);
    }
 
@@ -1007,6 +983,7 @@ static struct anv_image *
 make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format,
                       VkImageUsageFlags usage,
                       VkImageType image_type,
+                      const VkAllocationCallbacks *alloc,
                       const VkBufferImageCopy *copy)
 {
    ANV_FROM_HANDLE(anv_buffer, buffer, vk_buffer);
@@ -1026,12 +1003,12 @@ make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format,
          .format = format,
          .extent = extent,
          .mipLevels = 1,
-         .arraySize = 1,
+         .arrayLayers = 1,
          .samples = 1,
          .tiling = VK_IMAGE_TILING_LINEAR,
          .usage = usage,
          .flags = 0,
-      }, &vk_image);
+      }, alloc, &vk_image);
    assert(result == VK_SUCCESS);
 
    ANV_FROM_HANDLE(anv_image, image, vk_image);
@@ -1063,17 +1040,18 @@ void anv_CmdCopyBufferToImage(
 
    for (unsigned r = 0; r < regionCount; r++) {
       VkFormat proxy_format = orig_format;
-      VkImageAspect proxy_aspect = pRegions[r].imageSubresource.aspect;
+      VkImageAspectFlags proxy_aspect = pRegions[r].imageSubresource.aspectMask;
 
       if (orig_format == VK_FORMAT_S8_UINT) {
          proxy_format = VK_FORMAT_R8_UINT;
-         proxy_aspect = VK_IMAGE_ASPECT_COLOR;
+         proxy_aspect = VK_IMAGE_ASPECT_COLOR_BIT;
       }
 
       struct anv_image *src_image =
          make_image_for_buffer(vk_device, srcBuffer, proxy_format,
                                VK_IMAGE_USAGE_SAMPLED_BIT,
-                               dest_image->type, &pRegions[r]);
+                               dest_image->type, &cmd_buffer->pool->alloc,
+                               &pRegions[r]);
 
       const uint32_t dest_base_array_slice =
          meta_blit_get_dest_view_base_array_slice(dest_image,
@@ -1082,11 +1060,11 @@ void anv_CmdCopyBufferToImage(
 
       unsigned num_slices;
       if (dest_image->type == VK_IMAGE_TYPE_3D) {
-         assert(pRegions[r].imageSubresource.arraySize == 1);
+         assert(pRegions[r].imageSubresource.layerCount == 1);
          num_slices = pRegions[r].imageExtent.depth;
       } else {
          assert(pRegions[r].imageExtent.depth == 1);
-         num_slices = pRegions[r].imageSubresource.arraySize;
+         num_slices = pRegions[r].imageSubresource.layerCount;
       }
 
       for (unsigned slice = 0; slice < num_slices; slice++) {
@@ -1098,11 +1076,11 @@ void anv_CmdCopyBufferToImage(
                .viewType = VK_IMAGE_VIEW_TYPE_2D,
                .format = proxy_format,
                .subresourceRange = {
-                  .aspectMask = 1 << proxy_aspect,
+                  .aspectMask = proxy_aspect,
                   .baseMipLevel = 0,
-                  .mipLevels = 1,
+                  .levelCount = 1,
                   .baseArrayLayer = 0,
-                  .arraySize = 1,
+                  .layerCount = 1,
                },
             },
             cmd_buffer);
@@ -1112,14 +1090,14 @@ void anv_CmdCopyBufferToImage(
             &(VkImageViewCreateInfo) {
                .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
                .image = anv_image_to_handle(dest_image),
-               .viewType = VK_IMAGE_VIEW_TYPE_2D,
+               .viewType = anv_meta_get_view_type(dest_image),
                .format = proxy_format,
                .subresourceRange = {
                   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                   .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
-                  .mipLevels = 1,
+                  .levelCount = 1,
                   .baseArrayLayer = dest_base_array_slice + slice,
-                  .arraySize = 1
+                  .layerCount = 1
                },
             },
             cmd_buffer);
@@ -1141,7 +1119,7 @@ void anv_CmdCopyBufferToImage(
                         &dest_iview,
                         dest_offset,
                         pRegions[r].imageExtent,
-                        VK_TEX_FILTER_NEAREST);
+                        VK_FILTER_NEAREST);
 
          /* Once we've done the blit, all of the actual information about
           * the image is embedded in the command buffer so we can just
@@ -1153,7 +1131,8 @@ void anv_CmdCopyBufferToImage(
                               src_image->extent.height * 4;
       }
 
-      anv_DestroyImage(vk_device, anv_image_to_handle(src_image));
+      anv_DestroyImage(vk_device, anv_image_to_handle(src_image),
+                       &cmd_buffer->pool->alloc);
    }
 
    meta_finish_blit(cmd_buffer, &saved_state);
@@ -1172,9 +1151,6 @@ void anv_CmdCopyImageToBuffer(
    VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
    struct anv_meta_saved_state saved_state;
 
-   const VkImageViewType src_iview_type =
-      meta_blit_get_src_image_view_type(src_image);
-
    meta_prepare_blit(cmd_buffer, &saved_state);
 
    for (unsigned r = 0; r < regionCount; r++) {
@@ -1183,14 +1159,14 @@ void anv_CmdCopyImageToBuffer(
          &(VkImageViewCreateInfo) {
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
-            .viewType = src_iview_type,
+            .viewType = anv_meta_get_view_type(src_image),
             .format = src_image->format->vk_format,
             .subresourceRange = {
-               .aspectMask = 1 << pRegions[r].imageSubresource.aspect,
+               .aspectMask = pRegions[r].imageSubresource.aspectMask,
                .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
-               .mipLevels = 1,
-               .baseArrayLayer = pRegions[r].imageSubresource.arrayLayer,
-               .arraySize = pRegions[r].imageSubresource.arraySize,
+               .levelCount = 1,
+               .baseArrayLayer = pRegions[r].imageSubresource.baseArrayLayer,
+               .layerCount = pRegions[r].imageSubresource.layerCount,
             },
          },
          cmd_buffer);
@@ -1203,15 +1179,16 @@ void anv_CmdCopyImageToBuffer(
       struct anv_image *dest_image =
          make_image_for_buffer(vk_device, destBuffer, dest_format,
                                VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
-                               src_image->type, &pRegions[r]);
+                               src_image->type, &cmd_buffer->pool->alloc,
+                               &pRegions[r]);
 
       unsigned num_slices;
       if (src_image->type == VK_IMAGE_TYPE_3D) {
-         assert(pRegions[r].imageSubresource.arraySize == 1);
+         assert(pRegions[r].imageSubresource.layerCount == 1);
          num_slices = pRegions[r].imageExtent.depth;
       } else {
          assert(pRegions[r].imageExtent.depth == 1);
-         num_slices = pRegions[r].imageSubresource.arraySize;
+         num_slices = pRegions[r].imageSubresource.layerCount;
       }
 
       for (unsigned slice = 0; slice < num_slices; slice++) {
@@ -1228,9 +1205,9 @@ void anv_CmdCopyImageToBuffer(
                .subresourceRange = {
                   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                   .baseMipLevel = 0,
-                  .mipLevels = 1,
+                  .levelCount = 1,
                   .baseArrayLayer = 0,
-                  .arraySize = 1
+                  .layerCount = 1
                },
             },
             cmd_buffer);
@@ -1244,7 +1221,7 @@ void anv_CmdCopyImageToBuffer(
                         &dest_iview,
                         (VkOffset3D) { 0, 0, 0 },
                         pRegions[r].imageExtent,
-                        VK_TEX_FILTER_NEAREST);
+                        VK_FILTER_NEAREST);
 
          /* Once we've done the blit, all of the actual information about
           * the image is embedded in the command buffer so we can just
@@ -1256,7 +1233,8 @@ void anv_CmdCopyImageToBuffer(
                                dest_image->extent.height * 4;
       }
 
-      anv_DestroyImage(vk_device, anv_image_to_handle(dest_image));
+      anv_DestroyImage(vk_device, anv_image_to_handle(dest_image),
+                       &cmd_buffer->pool->alloc);
    }
 
    meta_finish_blit(cmd_buffer, &saved_state);
@@ -1308,13 +1286,13 @@ anv_device_finish_meta(struct anv_device *device)
 
    /* Blit */
    anv_DestroyRenderPass(anv_device_to_handle(device),
-                         device->meta_state.blit.render_pass);
+                         device->meta_state.blit.render_pass, NULL);
    anv_DestroyPipeline(anv_device_to_handle(device),
-                       device->meta_state.blit.pipeline_2d_src);
+                       device->meta_state.blit.pipeline_2d_src, NULL);
    anv_DestroyPipeline(anv_device_to_handle(device),
-                       device->meta_state.blit.pipeline_3d_src);
+                       device->meta_state.blit.pipeline_3d_src, NULL);
    anv_DestroyPipelineLayout(anv_device_to_handle(device),
-                             device->meta_state.blit.pipeline_layout);
+                             device->meta_state.blit.pipeline_layout, NULL);
    anv_DestroyDescriptorSetLayout(anv_device_to_handle(device),
-                                  device->meta_state.blit.ds_layout);
+                                  device->meta_state.blit.ds_layout, NULL);
 }