1/* 2 * Copyright 2019 Google LLC 3 * SPDX-License-Identifier: MIT 4 * 5 * based in part on anv and radv which are: 6 * Copyright © 2015 Intel Corporation 7 * Copyright © 2016 Red Hat. 8 * Copyright © 2016 Bas Nieuwenhuizen 9 */ 10 11#ifndef VN_IMAGE_H 12#define VN_IMAGE_H 13 14#include "vn_common.h" 15 16/* changing this to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR disables ownership 17 * transfers and can be useful for debugging 18 */ 19#define VN_PRESENT_SRC_INTERNAL_LAYOUT VK_IMAGE_LAYOUT_GENERAL 20 21struct vn_image_create_deferred_info { 22 VkImageCreateInfo create; 23 VkImageFormatListCreateInfo list; 24 VkImageStencilUsageCreateInfo stencil; 25 26 /* track whether vn_image_init_deferred succeeds */ 27 bool initialized; 28}; 29 30struct vn_image { 31 struct vn_object_base base; 32 33 VkSharingMode sharing_mode; 34 35 VkMemoryRequirements2 memory_requirements[4]; 36 VkMemoryDedicatedRequirements dedicated_requirements[4]; 37 38 bool is_wsi; 39 bool is_prime_blit_src; 40 41 /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */ 42 VkDeviceMemory private_memory; 43 /* For VK_ANDROID_external_memory_android_hardware_buffer, real image 44 * creation is deferred until bind image memory. 45 */ 46 struct vn_image_create_deferred_info *deferred_info; 47}; 48VK_DEFINE_NONDISP_HANDLE_CASTS(vn_image, 49 base.base, 50 VkImage, 51 VK_OBJECT_TYPE_IMAGE) 52 53struct vn_image_view { 54 struct vn_object_base base; 55 56 const struct vn_image *image; 57}; 58VK_DEFINE_NONDISP_HANDLE_CASTS(vn_image_view, 59 base.base, 60 VkImageView, 61 VK_OBJECT_TYPE_IMAGE_VIEW) 62 63struct vn_sampler { 64 struct vn_object_base base; 65}; 66VK_DEFINE_NONDISP_HANDLE_CASTS(vn_sampler, 67 base.base, 68 VkSampler, 69 VK_OBJECT_TYPE_SAMPLER) 70 71struct vn_sampler_ycbcr_conversion { 72 struct vn_object_base base; 73}; 74VK_DEFINE_NONDISP_HANDLE_CASTS(vn_sampler_ycbcr_conversion, 75 base.base, 76 VkSamplerYcbcrConversion, 77 VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION) 78 79VkResult 80vn_image_create(struct vn_device *dev, 81 const VkImageCreateInfo *create_info, 82 const VkAllocationCallbacks *alloc, 83 struct vn_image **out_img); 84 85VkResult 86vn_image_init_deferred(struct vn_device *dev, 87 const VkImageCreateInfo *create_info, 88 struct vn_image *img); 89 90VkResult 91vn_image_create_deferred(struct vn_device *dev, 92 const VkImageCreateInfo *create_info, 93 const VkAllocationCallbacks *alloc, 94 struct vn_image **out_img); 95 96#endif /* VN_IMAGE_H */ 97