aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/tu_image.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-10 11:58:07 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commit1085df8176cbc18c5ad59bed3906e27c26ab1766 (patch)
tree39eb0621d6ce36c4d3df0939aef22a2056c786d9 /src/freedreno/vulkan/tu_image.c
parent992ecdd40ebc2e027b39f98a92bdab953eedd5d5 (diff)
turnip: preliminary support for tu_image_view_init
Diffstat (limited to 'src/freedreno/vulkan/tu_image.c')
-rw-r--r--src/freedreno/vulkan/tu_image.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c
index 9a6930b0a9a..af90b1ff310 100644
--- a/src/freedreno/vulkan/tu_image.c
+++ b/src/freedreno/vulkan/tu_image.c
@@ -154,6 +154,8 @@ tu_image_create(VkDevice _device,
image->usage = pCreateInfo->usage;
image->flags = pCreateInfo->flags;
image->extent = pCreateInfo->extent;
+ image->level_count = pCreateInfo->mipLevels;
+ image->layer_count = pCreateInfo->arrayLayers;
image->exclusive = pCreateInfo->sharingMode == VK_SHARING_MODE_EXCLUSIVE;
if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
@@ -184,6 +186,41 @@ tu_image_view_init(struct tu_image_view *iview,
struct tu_device *device,
const VkImageViewCreateInfo *pCreateInfo)
{
+ TU_FROM_HANDLE(tu_image, image, pCreateInfo->image);
+ const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
+
+ switch (image->type) {
+ case VK_IMAGE_TYPE_1D:
+ case VK_IMAGE_TYPE_2D:
+ assert(range->baseArrayLayer + tu_get_layerCount(image, range) <=
+ image->layer_count);
+ break;
+ case VK_IMAGE_TYPE_3D:
+ assert(range->baseArrayLayer + tu_get_layerCount(image, range) <=
+ tu_minify(image->extent.depth, range->baseMipLevel));
+ break;
+ default:
+ unreachable("bad VkImageType");
+ }
+
+ iview->image = image;
+ iview->type = pCreateInfo->viewType;
+ iview->vk_format = pCreateInfo->format;
+ iview->aspect_mask = pCreateInfo->subresourceRange.aspectMask;
+
+ if (iview->aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT) {
+ iview->vk_format = vk_format_stencil_only(iview->vk_format);
+ } else if (iview->aspect_mask == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ iview->vk_format = vk_format_depth_only(iview->vk_format);
+ }
+
+ // should we minify?
+ iview->extent = image->extent;
+
+ iview->base_layer = range->baseArrayLayer;
+ iview->layer_count = tu_get_layerCount(image, range);
+ iview->base_mip = range->baseMipLevel;
+ iview->level_count = tu_get_levelCount(image, range);
}
unsigned