From fdcd71f71d62a9d4bb08b54173121289b67b19ec Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Fri, 26 Jun 2015 20:06:08 -0700 Subject: [PATCH] vk/image: Embed VkImageCreateInfo* into anv_image_create_info All function signatures that matched this pattern, old: f(const VkImageCreateInfo *, const struct anv_image_create_info *) were rewritten as new: f(const struct anv_image_create_info *) --- src/vulkan/image.c | 20 +++++++++++--------- src/vulkan/private.h | 7 ++++--- src/vulkan/x11.c | 43 ++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/vulkan/image.c b/src/vulkan/image.c index b55fb9fde5c..dcea1dc8863 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -91,13 +91,12 @@ static const struct anv_tile_info { }; static uint32_t -anv_image_choose_tile_mode(const VkImageCreateInfo *vk_info, - const struct anv_image_create_info *anv_info) +anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) { - if (anv_info) + if (anv_info->force_tile_mode) return anv_info->tile_mode; - switch (vk_info->tiling) { + switch (anv_info->vk_info->tiling) { case VK_IMAGE_TILING_LINEAR: return LINEAR; case VK_IMAGE_TILING_OPTIMAL: @@ -110,11 +109,11 @@ anv_image_choose_tile_mode(const VkImageCreateInfo *vk_info, VkResult anv_image_create( VkDevice _device, - const VkImageCreateInfo* pCreateInfo, - const struct anv_image_create_info * extra, + const struct anv_image_create_info * create_info, VkImage* pImage) { struct anv_device *device = (struct anv_device *) _device; + const VkImageCreateInfo *pCreateInfo = create_info->vk_info; const VkExtent3D *restrict extent = &pCreateInfo->extent; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); @@ -128,8 +127,7 @@ VkResult anv_image_create( anv_assert(pCreateInfo->extent.height > 0); anv_assert(pCreateInfo->extent.depth == 1); - const uint32_t tile_mode = - anv_image_choose_tile_mode(pCreateInfo, extra); + const uint32_t tile_mode = anv_image_choose_tile_mode(create_info); /* TODO(chadv): How should we validate inputs? */ const uint8_t surf_type = @@ -228,7 +226,11 @@ VkResult anv_CreateImage( const VkImageCreateInfo* pCreateInfo, VkImage* pImage) { - return anv_image_create(device, pCreateInfo, NULL, pImage); + return anv_image_create(device, + &(struct anv_image_create_info) { + .vk_info = pCreateInfo, + }, + pImage); } VkResult anv_GetImageSubresourceInfo( diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 6e122899e2c..d55912d7543 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -833,12 +833,13 @@ struct anv_surface_view { }; struct anv_image_create_info { - uint32_t tile_mode; + const VkImageCreateInfo *vk_info; + bool force_tile_mode; + uint8_t tile_mode; }; VkResult anv_image_create(VkDevice _device, - const VkImageCreateInfo *pCreateInfo, - const struct anv_image_create_info *extra, + const struct anv_image_create_info *info, VkImage *pImage); void anv_image_view_init(struct anv_surface_view *view, diff --git a/src/vulkan/x11.c b/src/vulkan/x11.c index 898aba056c7..6aeb34b9b56 100644 --- a/src/vulkan/x11.c +++ b/src/vulkan/x11.c @@ -107,27 +107,28 @@ VkResult anv_CreateSwapChainWSI( struct anv_device_memory *memory; anv_image_create((VkDevice) device, - &(VkImageCreateInfo) { - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .imageType = VK_IMAGE_TYPE_2D, - .format = pCreateInfo->imageFormat, - .extent = { - .width = pCreateInfo->imageExtent.width, - .height = pCreateInfo->imageExtent.height, - .depth = 1 - }, - .mipLevels = 1, - .arraySize = 1, - .samples = 1, - /* FIXME: Need a way to use X tiling to allow scanout */ - .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, - .flags = 0, - }, - &(struct anv_image_create_info) { - .tile_mode = XMAJOR - }, - (VkImage *) &image); + &(struct anv_image_create_info) { + .force_tile_mode = true, + .tile_mode = XMAJOR, + .vk_info = + &(VkImageCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .imageType = VK_IMAGE_TYPE_2D, + .format = pCreateInfo->imageFormat, + .extent = { + .width = pCreateInfo->imageExtent.width, + .height = pCreateInfo->imageExtent.height, + .depth = 1 + }, + .mipLevels = 1, + .arraySize = 1, + .samples = 1, + /* FIXME: Need a way to use X tiling to allow scanout */ + .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + .flags = 0, + }}, + (VkImage *) &image); anv_AllocMemory((VkDevice) device, &(VkMemoryAllocInfo) { -- 2.30.2