vk/image: Embed VkImageCreateInfo* into anv_image_create_info
authorChad Versace <chad.versace@intel.com>
Sat, 27 Jun 2015 03:06:08 +0000 (20:06 -0700)
committerChad Versace <chad.versace@intel.com>
Sat, 27 Jun 2015 03:06:08 +0000 (20:06 -0700)
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
src/vulkan/private.h
src/vulkan/x11.c

index b55fb9fde5c4b3790caeca9bb7be0e04a04a7e0d..dcea1dc88636461fd7e556276275e060b1cfd838 100644 (file)
@@ -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(
index 6e122899e2cdd646ce534d56d52cc8b68a97da1c..d55912d7543df1085a244960f342f41d3d790cc2 100644 (file)
@@ -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,
index 898aba056c79fd2db92a81711bac65e4e000ff01..6aeb34b9b56dd7a253b40bdd5e5e6bca400b6235 100644 (file)
@@ -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) {