1 // Copyright (C) 2018 The Android Open Source Project
2 // Copyright (C) 2018 Google Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 #pragma once
16 
17 #include <vulkan/vulkan.h>
18 
19 #define GOLDFISH_VK_LIST_DISPATCHABLE_HANDLE_TYPES(f) \
20     f(VkInstance)                                     \
21     f(VkPhysicalDevice)                               \
22     f(VkDevice)                                       \
23     f(VkQueue)                                        \
24     f(VkCommandBuffer)
25 
26 // Unboxing can be overridden for some handles, this would mean the actual
27 // unboxed handle to be used for the GPU can be different than the 'unboxed'
28 // handle used for tracking its properties (e.g. via mQueueInfo).
29 // Queues can be virtualized by using made up 'unboxed' handles for tracking,
30 // whichwill then needs translation when used for the driver operations.
31 #define GOLDFISH_VK_LIST_DISPATCHABLE_REGULAR_UNBOX_HANDLE_TYPES(f) \
32     f(VkInstance)                                                   \
33     f(VkPhysicalDevice)                                             \
34     f(VkDevice)                                                     \
35     f(VkCommandBuffer)
36 
37 // VkQueues can be virtualized to provide multiple queues when only a single
38 // queue is supported. Custom unbox will ensure that the unboxed handle can
39 // be used by the GPU correctly.
40 #define GOLDFISH_VK_LIST_DISPATCHABLE_CUSTOM_UNBOX_HANDLE_TYPES(f) f(VkQueue)
41 
42 #define GOLDFISH_VK_LIST_TRIVIAL_NON_DISPATCHABLE_HANDLE_TYPES(f) \
43     f(VkBuffer)                                                   \
44     f(VkBufferView)                                               \
45     f(VkImage)                                                    \
46     f(VkImageView)                                                \
47     f(VkShaderModule)                                             \
48     f(VkDescriptorPool)                                           \
49     f(VkDescriptorSetLayout)                                      \
50     f(VkDescriptorSet)                                            \
51     f(VkSampler)                                                  \
52     f(VkPipeline)                                                 \
53     f(VkPipelineCache)                                            \
54     f(VkPipelineLayout)                                           \
55     f(VkRenderPass)                                               \
56     f(VkFramebuffer)                                              \
57     f(VkCommandPool)                                              \
58     f(VkFence)                                                    \
59     f(VkSemaphore)                                                \
60     f(VkEvent)                                                    \
61     f(VkQueryPool)                                                \
62     f(VkSamplerYcbcrConversion)                                   \
63     f(VkDescriptorUpdateTemplate)                                 \
64     f(VkSurfaceKHR)                                               \
65     f(VkSwapchainKHR)                                             \
66     f(VkDisplayKHR)                                               \
67     f(VkDisplayModeKHR)                                           \
68     f(VkValidationCacheEXT)                                       \
69     f(VkDebugReportCallbackEXT)                                   \
70     f(VkDebugUtilsMessengerEXT)                                   \
71     f(VkAccelerationStructureNV)                                  \
72     f(VkIndirectCommandsLayoutNV)                                 \
73     f(VkAccelerationStructureKHR)                                 \
74     f(VkCuModuleNVX)                                              \
75     f(VkCuFunctionNVX)                                            \
76     f(VkPrivateDataSlot)                                          \
77     f(VkMicromapEXT)
78 
79 #define GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES(f) \
80     f(VkDeviceMemory)                                     \
81     GOLDFISH_VK_LIST_TRIVIAL_NON_DISPATCHABLE_HANDLE_TYPES(f)
82 
83 #define GOLDFISH_VK_LIST_HANDLE_TYPES(f)          \
84     GOLDFISH_VK_LIST_DISPATCHABLE_HANDLE_TYPES(f) \
85     GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES(f)
86 
87 // Need to sort by snapshot load dependency order
88 #define GOLDFISH_VK_LIST_HANDLE_TYPES_BY_STAGE(f) \
89     f(VkInstance)                                 \
90     f(VkPhysicalDevice)                           \
91     f(VkDevice)                                   \
92     f(VkQueue)                                    \
93     f(VkDeviceMemory)                             \
94     f(VkBuffer)                                   \
95     f(VkImage)                                    \
96     f(VkBufferView)                               \
97     f(VkImageView)                                \
98     f(VkShaderModule)                             \
99     f(VkDescriptorSetLayout)                      \
100     f(VkDescriptorPool)                           \
101     f(VkDescriptorSet)                            \
102     f(VkSampler)                                  \
103     f(VkSamplerYcbcrConversion)                   \
104     f(VkDescriptorUpdateTemplate)                 \
105     f(VkRenderPass)                               \
106     f(VkFramebuffer)                              \
107     f(VkPipelineLayout)                           \
108     f(VkPipelineCache)                            \
109     f(VkPipeline)                                 \
110     f(VkFence)                                    \
111     f(VkSemaphore)                                \
112     f(VkEvent)                                    \
113     f(VkQueryPool)                                \
114     f(VkSurfaceKHR)                               \
115     f(VkSwapchainKHR)                             \
116     f(VkDisplayKHR)                               \
117     f(VkDisplayModeKHR)                           \
118     f(VkValidationCacheEXT)                       \
119     f(VkDebugReportCallbackEXT)                   \
120     f(VkDebugUtilsMessengerEXT)                   \
121     f(VkCommandPool)                              \
122     f(VkCommandBuffer)                            \
123     f(VkAccelerationStructureNV)                  \
124     f(VkIndirectCommandsLayoutNV)                 \
125     f(VkAccelerationStructureKHR)                 \
126     f(VkCuModuleNVX)                              \
127     f(VkCuFunctionNVX)                            \
128     f(VkPrivateDataSlot)                          \
129     f(VkMicromapEXT)
130