From 3200a81a553b9cf5e3d0853307d8f75eadff8f97 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 31 Dec 2015 12:39:34 -0800 Subject: [PATCH] anv/image: Add a vk_format field 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 | 1 + src/vulkan/anv_meta.c | 14 +++++++------- src/vulkan/anv_meta_clear.c | 2 +- src/vulkan/anv_private.h | 4 ++++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 159af6d19b0..1cb860f75f5 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -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; diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index b72ec48afe2..d9a5783e349 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -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; } diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c index 6a0517a2228..17a40cd6be6 100644 --- a/src/vulkan/anv_meta_clear.c +++ b/src/vulkan/anv_meta_clear.c @@ -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, diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 626d7bbedfe..187a6e822b2 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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; -- 2.30.2