From: Chad Versace Date: Mon, 17 Aug 2015 20:10:40 +0000 (-0700) Subject: vk: Add anv_format reference to anv_image X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ded736f16a9980eff3009b25b4b89763237c6cea;p=mesa.git vk: Add anv_format reference to anv_image Change type of anv_image::format from VkFormat to const struct anv_format*. This reduces the number of lookups in the VkFormat -> anv_format table. --- diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 2937c2e76e5..329955fff59 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -242,9 +242,6 @@ anv_image_create(VkDevice _device, return vk_error(VK_ERROR_INVALID_MEMORY_SIZE); } - const struct anv_format *format_info = - anv_format_for_vk_format(pCreateInfo->format); - image = anv_device_alloc(device, sizeof(*image), 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); if (!image) @@ -253,12 +250,12 @@ anv_image_create(VkDevice _device, memset(image, 0, sizeof(*image)); image->type = pCreateInfo->imageType; image->extent = pCreateInfo->extent; - image->format = pCreateInfo->format; + image->format = anv_format_for_vk_format(pCreateInfo->format); image->levels = pCreateInfo->mipLevels; image->array_size = pCreateInfo->arraySize; image->surf_type = surf_type; - if (likely(!format_info->has_stencil || format_info->depth_format)) { + if (likely(!image->format->has_stencil || image->format->depth_format)) { /* The image's primary surface is a color or depth surface. */ r = anv_image_make_surface(create_info, &image->size, &image->alignment, &image->primary_surface); @@ -266,7 +263,7 @@ anv_image_create(VkDevice _device, goto fail; } - if (format_info->has_stencil) { + if (image->format->has_stencil) { /* From the GPU's perspective, the depth buffer and stencil buffer are * separate buffers. From Vulkan's perspective, though, depth and * stencil reside in the same image. To satisfy Vulkan and the GPU, we @@ -465,7 +462,6 @@ anv_validate_CreateImageView(VkDevice _device, const VkImageSubresourceRange *subresource; const struct anv_image_view_info *view_info; const struct anv_format *view_format_info; - const struct anv_format *image_format_info; /* Validate structure type before dereferencing it. */ assert(pCreateInfo); @@ -480,7 +476,6 @@ anv_validate_CreateImageView(VkDevice _device, /* Validate format is in range before using it. */ assert(pCreateInfo->format >= VK_FORMAT_BEGIN_RANGE); assert(pCreateInfo->format <= VK_FORMAT_END_RANGE); - image_format_info = anv_format_for_vk_format(image->format); view_format_info = anv_format_for_vk_format(pCreateInfo->format); /* Validate channel swizzles. */ @@ -512,20 +507,20 @@ anv_validate_CreateImageView(VkDevice _device, /* Validate format. */ switch (subresource->aspect) { case VK_IMAGE_ASPECT_COLOR: - assert(!image_format_info->depth_format); - assert(!image_format_info->has_stencil); + assert(!image->format->depth_format); + assert(!image->format->has_stencil); assert(!view_format_info->depth_format); assert(!view_format_info->has_stencil); - assert(view_format_info->cpp == image_format_info->cpp); + assert(view_format_info->cpp == image->format->cpp); break; case VK_IMAGE_ASPECT_DEPTH: - assert(image_format_info->depth_format); + assert(image->format->depth_format); assert(view_format_info->depth_format); - assert(view_format_info->cpp == image_format_info->cpp); + assert(view_format_info->cpp == image->format->cpp); break; case VK_IMAGE_ASPECT_STENCIL: /* FINISHME: Is it legal to have an R8 view of S8? */ - assert(image_format_info->has_stencil); + assert(image->format->has_stencil); assert(view_format_info->has_stencil); break; default: @@ -672,8 +667,6 @@ anv_depth_stencil_view_init(struct anv_depth_stencil_view *view, ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); struct anv_surface *depth_surface = &image->primary_surface; struct anv_surface *stencil_surface = &image->stencil_surface; - const struct anv_format *format = - anv_format_for_vk_format(image->format); view->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL; @@ -686,7 +679,7 @@ anv_depth_stencil_view_init(struct anv_depth_stencil_view *view, view->depth_stride = depth_surface->stride; view->depth_offset = image->offset + depth_surface->offset; - view->depth_format = format->depth_format; + view->depth_format = image->format->depth_format; view->depth_qpitch = 0; /* FINISHME: QPitch */ view->stencil_stride = stencil_surface->stride; diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index 29995330b04..7fcabb29069 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -911,7 +911,7 @@ void anv_CmdCopyImage( .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, .viewType = VK_IMAGE_VIEW_TYPE_2D, - .format = src_image->format, + .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, @@ -933,7 +933,7 @@ void anv_CmdCopyImage( &(VkAttachmentViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, .image = destImage, - .format = src_image->format, + .format = src_image->format->vk_format, .mipLevel = pRegions[r].destSubresource.mipLevel, .baseArraySlice = pRegions[r].destSubresource.arraySlice, .arraySize = 1, @@ -980,7 +980,7 @@ void anv_CmdBlitImage( .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, .viewType = VK_IMAGE_VIEW_TYPE_2D, - .format = src_image->format, + .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, @@ -1002,7 +1002,7 @@ void anv_CmdBlitImage( &(VkAttachmentViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, .image = destImage, - .format = dest_image->format, + .format = dest_image->format->vk_format, .mipLevel = pRegions[r].destSubresource.mipLevel, .baseArraySlice = pRegions[r].destSubresource.arraySlice, .arraySize = 1, @@ -1048,7 +1048,7 @@ void anv_CmdCopyBufferToImage( &(VkImageCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, - .format = dest_image->format, + .format = dest_image->format->vk_format, .extent = { .width = pRegions[r].imageExtent.width, .height = pRegions[r].imageExtent.height, @@ -1076,7 +1076,7 @@ void anv_CmdCopyBufferToImage( .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = anv_image_to_handle(src_image), .viewType = VK_IMAGE_VIEW_TYPE_2D, - .format = dest_image->format, + .format = dest_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, @@ -1098,7 +1098,7 @@ void anv_CmdCopyBufferToImage( &(VkAttachmentViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, .image = anv_image_to_handle(dest_image), - .format = dest_image->format, + .format = dest_image->format->vk_format, .mipLevel = pRegions[r].imageSubresource.mipLevel, .baseArraySlice = pRegions[r].imageSubresource.arraySlice, .arraySize = 1, @@ -1147,7 +1147,7 @@ void anv_CmdCopyImageToBuffer( .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, .viewType = VK_IMAGE_VIEW_TYPE_2D, - .format = src_image->format, + .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, @@ -1169,7 +1169,7 @@ void anv_CmdCopyImageToBuffer( &(VkImageCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, - .format = src_image->format, + .format = src_image->format->vk_format, .extent = { .width = pRegions[r].imageExtent.width, .height = pRegions[r].imageExtent.height, @@ -1196,7 +1196,7 @@ void anv_CmdCopyImageToBuffer( &(VkAttachmentViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, .image = destImage, - .format = src_image->format, + .format = src_image->format->vk_format, .mipLevel = 0, .baseArraySlice = 0, .arraySize = 1, @@ -1259,7 +1259,7 @@ void anv_CmdClearColorImage( &(VkAttachmentViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, .image = _image, - .format = image->format, + .format = image->format->vk_format, .mipLevel = pRanges[r].baseMipLevel + l, .baseArraySlice = pRanges[r].baseArraySlice + s, .arraySize = 1, diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index dc14dd2818a..89e7a8d778c 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -912,8 +912,8 @@ struct anv_surface { struct anv_image { VkImageType type; + const struct anv_format *format; VkExtent3D extent; - VkFormat format; uint32_t levels; uint32_t array_size;