• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 struct vn_image_create_deferred_info {
22    VkImageCreateInfo create;
23    VkImageFormatListCreateInfo list;
24    VkImageStencilUsageCreateInfo stencil;
25 };
26 
27 struct vn_image {
28    struct vn_object_base base;
29 
30    VkSharingMode sharing_mode;
31 
32    VkMemoryRequirements2 memory_requirements[4];
33    VkMemoryDedicatedRequirements dedicated_requirements[4];
34 
35    bool is_wsi;
36    bool is_prime_blit_src;
37 
38    /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */
39    VkDeviceMemory private_memory;
40    /* For VK_ANDROID_external_memory_android_hardware_buffer, real image
41     * creation is deferred until bind image memory.
42     */
43    struct vn_image_create_deferred_info *deferred_info;
44 };
45 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_image,
46                                base.base,
47                                VkImage,
48                                VK_OBJECT_TYPE_IMAGE)
49 
50 struct vn_image_view {
51    struct vn_object_base base;
52 
53    const struct vn_image *image;
54 };
55 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_image_view,
56                                base.base,
57                                VkImageView,
58                                VK_OBJECT_TYPE_IMAGE_VIEW)
59 
60 struct vn_sampler {
61    struct vn_object_base base;
62 };
63 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_sampler,
64                                base.base,
65                                VkSampler,
66                                VK_OBJECT_TYPE_SAMPLER)
67 
68 struct vn_sampler_ycbcr_conversion {
69    struct vn_object_base base;
70 };
71 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_sampler_ycbcr_conversion,
72                                base.base,
73                                VkSamplerYcbcrConversion,
74                                VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION)
75 
76 VkResult
77 vn_image_create(struct vn_device *dev,
78                 const VkImageCreateInfo *create_info,
79                 const VkAllocationCallbacks *alloc,
80                 struct vn_image **out_img);
81 
82 VkResult
83 vn_image_init_deferred(struct vn_device *dev,
84                        const VkImageCreateInfo *create_info,
85                        struct vn_image *img);
86 
87 VkResult
88 vn_image_create_deferred(struct vn_device *dev,
89                          const VkImageCreateInfo *create_info,
90                          const VkAllocationCallbacks *alloc,
91                          struct vn_image **out_img);
92 
93 #endif /* VN_IMAGE_H */
94