anv/image: Add a vk_format field
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 Dec 2015 20:39:34 +0000 (12:39 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 5 Jan 2016 00:08:05 +0000 (16:08 -0800)
We've been trying to move away from anv_format for a while and this should
help with the transition.  There are cases (mostly in meta) where we need
the original format for the image and not the isl_format.  These will be
moved over to the new vk_format and everythign else will use the isl_format
from the particular anv_surface.

src/vulkan/anv_image.c
src/vulkan/anv_meta.c
src/vulkan/anv_meta_clear.c
src/vulkan/anv_private.h

index 159af6d19b0458e794e3b37f7918cc9783bcd77c..1cb860f75f5df8013d4528d6e5690291094ebb4d 100644 (file)
@@ -205,6 +205,7 @@ anv_image_create(VkDevice _device,
    memset(image, 0, sizeof(*image));
    image->type = pCreateInfo->imageType;
    image->extent = pCreateInfo->extent;
+   image->vk_format = pCreateInfo->format;
    image->format = anv_format_for_vk_format(pCreateInfo->format);
    image->levels = pCreateInfo->mipLevels;
    image->array_size = pCreateInfo->arrayLayers;
index b72ec48afe23528afa163a2dd34dc3c90d30b2be..d9a5783e3493f6cc7cfbc5c1bc408bd332239e6d 100644 (file)
@@ -858,7 +858,7 @@ void anv_CmdCopyImage(
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
             .viewType = anv_meta_get_view_type(src_image),
-            .format = src_image->format->vk_format,
+            .format = src_image->vk_format,
             .subresourceRange = {
                .aspectMask = pRegions[r].srcSubresource.aspectMask,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
@@ -902,7 +902,7 @@ void anv_CmdCopyImage(
                .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
                .image = destImage,
                .viewType = anv_meta_get_view_type(dest_image),
-               .format = dest_image->format->vk_format,
+               .format = dest_image->vk_format,
                .subresourceRange = {
                   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                   .baseMipLevel = pRegions[r].dstSubresource.mipLevel,
@@ -955,7 +955,7 @@ void anv_CmdBlitImage(
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
             .viewType = anv_meta_get_view_type(src_image),
-            .format = src_image->format->vk_format,
+            .format = src_image->vk_format,
             .subresourceRange = {
                .aspectMask = pRegions[r].srcSubresource.aspectMask,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
@@ -989,7 +989,7 @@ void anv_CmdBlitImage(
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = destImage,
             .viewType = anv_meta_get_view_type(dest_image),
-            .format = dest_image->format->vk_format,
+            .format = dest_image->vk_format,
             .subresourceRange = {
                .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                .baseMipLevel = pRegions[r].dstSubresource.mipLevel,
@@ -1067,7 +1067,7 @@ void anv_CmdCopyBufferToImage(
    ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
    ANV_FROM_HANDLE(anv_image, dest_image, destImage);
    VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
-   const VkFormat orig_format = dest_image->format->vk_format;
+   const VkFormat orig_format = dest_image->vk_format;
    struct anv_meta_saved_state saved_state;
 
    meta_prepare_blit(cmd_buffer, &saved_state);
@@ -1194,7 +1194,7 @@ void anv_CmdCopyImageToBuffer(
             .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .image = srcImage,
             .viewType = anv_meta_get_view_type(src_image),
-            .format = src_image->format->vk_format,
+            .format = src_image->vk_format,
             .subresourceRange = {
                .aspectMask = pRegions[r].imageSubresource.aspectMask,
                .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
@@ -1205,7 +1205,7 @@ void anv_CmdCopyImageToBuffer(
          },
          cmd_buffer);
 
-      VkFormat dest_format = src_image->format->vk_format;
+      VkFormat dest_format = src_image->vk_format;
       if (dest_format == VK_FORMAT_S8_UINT) {
          dest_format = VK_FORMAT_R8_UINT;
       }
index 6a0517a2228da82145343aa6a3d05373fc791f14..17a40cd6be601b6ddc3b6d0554fad32e57c7b7e7 100644 (file)
@@ -729,7 +729,7 @@ void anv_CmdClearColorImage(
                   .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
                   .image = _image,
                   .viewType = anv_meta_get_view_type(image),
-                  .format = image->format->vk_format,
+                  .format = image->vk_format,
                   .subresourceRange = {
                      .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
                      .baseMipLevel = pRanges[r].baseMipLevel + l,
index 626d7bbedfe06634545a0c45169119c60e2fabf5..187a6e822b2e2e55c491866ae217c7f52e3df1e4 100644 (file)
@@ -1443,6 +1443,10 @@ struct anv_surface {
 
 struct anv_image {
    VkImageType type;
+   /* The original VkFormat provided by the client.  This may not match any
+    * of the actual surface formats.
+    */
+   VkFormat vk_format;
    const struct anv_format *format;
    VkExtent3D extent;
    uint32_t levels;