diff options
author | Chad Versace <[email protected]> | 2015-09-14 11:04:08 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2015-09-14 11:04:08 -0700 |
commit | eed74e3a02e21867f47501ca9ce0be21e76f7510 (patch) | |
tree | 8c3de2531401efd0a8d6be5d5b2af5db72f01a33 /src/vulkan/anv_image.c | |
parent | e01d5a0471bdf7e679eb576da2706e5436695fe9 (diff) |
vk: Teach vkCreateImage about layout of 3D surfaces
Calling vkCreateImage() with VK_IMAGE_TYPE_3D now succeeds and computes
the surface layout correctly. However, 3D images do not yet work for
many other Vulkan entrypoints.
Diffstat (limited to 'src/vulkan/anv_image.c')
-rw-r--r-- | src/vulkan/anv_image.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 0db87753e28..f0577a50a94 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -197,7 +197,21 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, break; } case VK_IMAGE_TYPE_3D: - anv_finishme("VK_IMAGE_TYPE_3D"); + /* The layout of 3D surfaces is described by the Broadwell PRM >> + * Volume 5: Memory Views >> Common Surface Formats >> Surface Layout >> + * 3D Surfaces. + */ + for (uint32_t l = 0; l < levels; ++l) { + const uint32_t w_l = align_u32(anv_minify(extent->width, l), i); + const uint32_t h_l = align_u32(anv_minify(extent->height, l), j); + const uint32_t d_l = anv_minify(extent->depth, l); + + const uint32_t max_layers_horiz = MIN(d_l, 1u << l); + const uint32_t max_layers_vert = align_u32(d_l, 1u << l) / (1u << l); + + mt_width = MAX(mt_width, w_l * max_layers_horiz); + mt_height += h_l * max_layers_vert; + } break; default: unreachable(!"bad VkImageType"); @@ -254,7 +268,8 @@ anv_image_create(VkDevice _device, assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); /* XXX: We don't handle any of these */ - anv_assert(pCreateInfo->imageType == VK_IMAGE_TYPE_2D); + anv_assert(pCreateInfo->imageType == VK_IMAGE_TYPE_2D || + pCreateInfo->imageType == VK_IMAGE_TYPE_3D); anv_assert(pCreateInfo->mipLevels > 0); anv_assert(pCreateInfo->arraySize > 0); anv_assert(pCreateInfo->samples == 1); |