summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2015-06-09 14:33:05 -0700
committerChad Versace <[email protected]>2015-06-09 16:38:42 -0700
commitf1db3b386990513041fd8ca89950d8aa3f9a0133 (patch)
treee518d040c36c49b54173f6a184161102a61c0aa8
parent11e941900ad222bebc0142f58f78c70fe335caa9 (diff)
vk/image: Factor tile mode selection into separate function
Because it will eventually need to get smarter.
-rw-r--r--src/vulkan/image.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/vulkan/image.c b/src/vulkan/image.c
index 6e123e38530..2de5be93e1b 100644
--- a/src/vulkan/image.c
+++ b/src/vulkan/image.c
@@ -64,6 +64,24 @@ static const struct anv_tile_info {
[WMAJOR] = { 128, 32, 4096 },
};
+static uint32_t
+anv_image_choose_tile_mode(const VkImageCreateInfo *vk_info,
+ const struct anv_image_create_info *anv_info)
+{
+ if (anv_info)
+ return anv_info->tile_mode;
+
+ switch (vk_info->tiling) {
+ case VK_IMAGE_TILING_LINEAR:
+ return LINEAR;
+ case VK_IMAGE_TILING_OPTIMAL:
+ return YMAJOR;
+ default:
+ assert(!"bad VKImageTiling");
+ return LINEAR;
+ }
+}
+
VkResult anv_image_create(
VkDevice _device,
const VkImageCreateInfo* pCreateInfo,
@@ -89,26 +107,12 @@ VkResult anv_image_create(
image->format = pCreateInfo->format;
image->extent = pCreateInfo->extent;
image->swap_chain = NULL;
+ image->tile_mode = anv_image_choose_tile_mode(pCreateInfo, extra);
assert(image->extent.width > 0);
assert(image->extent.height > 0);
assert(image->extent.depth > 0);
- switch (pCreateInfo->tiling) {
- case VK_IMAGE_TILING_LINEAR:
- image->tile_mode = LINEAR;
- break;
- case VK_IMAGE_TILING_OPTIMAL:
- image->tile_mode = YMAJOR;
- break;
- default:
- assert(!"bad VKImageTiling");
- break;
- }
-
- if (extra)
- image->tile_mode = extra->tile_mode;
-
const struct anv_tile_info *tile_info =
&anv_tile_info_table[image->tile_mode];