anv/image: Refactor anv_image_make_surface()
[mesa.git] / src / vulkan / anv_dump.c
index 3634ae687321575b59df51e4c2ad1f41643959fc..3a1430d49a0653d4333d28e6a00e75e76f6ced9e 100644 (file)
@@ -49,52 +49,52 @@ anv_dump_image_to_ppm(struct anv_device *device,
          .format = VK_FORMAT_R8G8B8A8_UNORM,
          .extent = (VkExtent3D) { extent.width, extent.height, 1 },
          .mipLevels = 1,
-         .arraySize = 1,
+         .arrayLayers = 1,
          .samples = 1,
          .tiling = VK_IMAGE_TILING_LINEAR,
          .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT,
          .flags = 0,
-      }, &copy_image);
+      }, NULL, &copy_image);
    assert(result == VK_SUCCESS);
 
    VkMemoryRequirements reqs;
-   result = anv_GetImageMemoryRequirements(vk_device, copy_image, &reqs);
+   anv_GetImageMemoryRequirements(vk_device, copy_image, &reqs);
 
    VkDeviceMemory memory;
-   result = anv_AllocMemory(vk_device,
-      &(VkMemoryAllocInfo) {
-         .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO,
+   result = anv_AllocateMemory(vk_device,
+      &(VkMemoryAllocateInfo) {
+         .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
          .allocationSize = reqs.size,
          .memoryTypeIndex = 0,
-      }, &memory);
+      }, NULL, &memory);
    assert(result == VK_SUCCESS);
 
    result = anv_BindImageMemory(vk_device, copy_image, memory, 0);
    assert(result == VK_SUCCESS);
 
-   VkCmdPool cmdPool;
+   VkCommandPool commandPool;
    result = anv_CreateCommandPool(vk_device,
-      &(VkCmdPoolCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO,
+      &(VkCommandPoolCreateInfo) {
+         .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
          .queueFamilyIndex = 0,
          .flags = 0,
-      }, &cmdPool);
+      }, NULL, &commandPool);
    assert(result == VK_SUCCESS);
 
-   VkCmdBuffer cmd;
-   result = anv_CreateCommandBuffer(vk_device,
-      &(VkCmdBufferCreateInfo) {
-         .sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO,
-         .cmdPool = cmdPool,
-         .level = VK_CMD_BUFFER_LEVEL_PRIMARY,
-         .flags = 0,
+   VkCommandBuffer cmd;
+   result = anv_AllocateCommandBuffers(vk_device,
+      &(VkCommandBufferAllocateInfo) {
+         .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
+         .commandPool = commandPool,
+         .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
+         .bufferCount = 1,
       }, &cmd);
    assert(result == VK_SUCCESS);
 
    result = anv_BeginCommandBuffer(cmd,
-      &(VkCmdBufferBeginInfo) {
-         .sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO,
-         .flags = VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT,
+      &(VkCommandBufferBeginInfo) {
+         .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+         .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
       });
    assert(result == VK_SUCCESS);
 
@@ -103,10 +103,10 @@ anv_dump_image_to_ppm(struct anv_device *device,
       copy_image, VK_IMAGE_LAYOUT_GENERAL, 1,
       &(VkImageBlit) {
          .srcSubresource = {
-            .aspect = VK_IMAGE_ASPECT_COLOR,
+            .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .mipLevel = miplevel,
-            .arrayLayer = array_layer,
-            .arraySize = 1,
+            .baseArrayLayer = array_layer,
+            .layerCount = 1,
          },
          .srcOffset = (VkOffset3D) { 0, 0, 0 },
          .srcExtent = (VkExtent3D) {
@@ -114,19 +114,19 @@ anv_dump_image_to_ppm(struct anv_device *device,
             extent.height,
             1
          },
-         .destSubresource = {
-            .aspect = VK_IMAGE_ASPECT_COLOR,
+         .dstSubresource = {
+            .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .mipLevel = 0,
-            .arrayLayer = 0,
-            .arraySize = 1,
+            .baseArrayLayer = 0,
+            .layerCount = 1,
          },
-         .destOffset = (VkOffset3D) { 0, 0, 0 },
-         .destExtent = (VkExtent3D) {
+         .dstOffset = (VkOffset3D) { 0, 0, 0 },
+         .dstExtent = (VkExtent3D) {
             extent.width,
             extent.height,
             1
          },
-      }, VK_TEX_FILTER_NEAREST);
+      }, VK_FILTER_NEAREST);
 
    ANV_CALL(CmdPipelineBarrier)(cmd,
       VK_PIPELINE_STAGE_TRANSFER_BIT,
@@ -134,19 +134,19 @@ anv_dump_image_to_ppm(struct anv_device *device,
       true, 1,
       (const void * []) { &(VkImageMemoryBarrier) {
          .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
-         .outputMask = VK_MEMORY_OUTPUT_TRANSFER_BIT,
-         .inputMask = VK_MEMORY_INPUT_HOST_READ_BIT,
+         .srcAccessMask = VK_ACCESS_HOST_READ_BIT,
+         .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
          .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
          .newLayout = VK_IMAGE_LAYOUT_GENERAL,
          .srcQueueFamilyIndex = 0,
-         .destQueueFamilyIndex = 0,
+         .dstQueueFamilyIndex = 0,
          .image = copy_image,
          .subresourceRange = (VkImageSubresourceRange) {
             .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .baseMipLevel = 0,
-            .mipLevels = 1,
+            .levelCount = 1,
             .baseArrayLayer = 0,
-            .arraySize = 1,
+            .layerCount = 1,
          },
       }});
 
@@ -158,31 +158,34 @@ anv_dump_image_to_ppm(struct anv_device *device,
       &(VkFenceCreateInfo) {
          .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
          .flags = 0,
-      }, &fence);
+      }, NULL, &fence);
    assert(result == VK_SUCCESS);
 
-   result = anv_QueueSubmit(anv_queue_to_handle(&device->queue),
-                            1, &cmd, fence);
+   result = anv_QueueSubmit(anv_queue_to_handle(&device->queue), 1,
+      &(VkSubmitInfo) {
+         .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
+         .commandBufferCount = 1,
+         .pCommandBuffers = &cmd,
+      }, fence);
    assert(result == VK_SUCCESS);
 
    result = anv_WaitForFences(vk_device, 1, &fence, true, UINT64_MAX);
    assert(result == VK_SUCCESS);
 
-   anv_DestroyFence(vk_device, fence);
-   anv_DestroyCommandPool(vk_device, cmdPool);
+   anv_DestroyFence(vk_device, fence, NULL);
+   anv_DestroyCommandPool(vk_device, commandPool, NULL);
 
    uint8_t *map;
    result = anv_MapMemory(vk_device, memory, 0, reqs.size, 0, (void **)&map);
    assert(result == VK_SUCCESS);
 
    VkSubresourceLayout layout;
-   result = anv_GetImageSubresourceLayout(vk_device, copy_image,
+   anv_GetImageSubresourceLayout(vk_device, copy_image,
       &(VkImageSubresource) {
-         .aspect = VK_IMAGE_ASPECT_COLOR,
+         .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
          .mipLevel = 0,
          .arrayLayer = 0,
       }, &layout);
-   assert(result == VK_SUCCESS);
 
    map += layout.offset;
 
@@ -205,6 +208,6 @@ anv_dump_image_to_ppm(struct anv_device *device,
    fclose(file);
 
    anv_UnmapMemory(vk_device, memory);
-   anv_DestroyImage(vk_device, copy_image);
-   anv_FreeMemory(vk_device, memory);
+   anv_DestroyImage(vk_device, copy_image, NULL);
+   anv_FreeMemory(vk_device, memory, NULL);
 }