Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1 | {{define "Copyright"}} |
| 2 | /* |
| 3 | •* Copyright 2016 The Android Open Source Project |
| 4 | •* |
| 5 | •* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | •* you may not use this file except in compliance with the License. |
| 7 | •* You may obtain a copy of the License at |
| 8 | •* |
| 9 | •* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | •* |
| 11 | •* Unless required by applicable law or agreed to in writing, software |
| 12 | •* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | •* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | •* See the License for the specific language governing permissions and |
| 15 | •* limitations under the License. |
| 16 | •*/ |
| 17 | ¶{{end}} |
| 18 | |
| 19 | {{Include "../api/templates/vulkan_common.tmpl"}} |
| 20 | {{Global "clang-format" (Strings "clang-format" "-style=file")}} |
| 21 | {{Macro "DefineGlobals" $}} |
| 22 | {{$ | Macro "api_gen.h" | Format (Global "clang-format") | Write "api_gen.h" }} |
| 23 | {{$ | Macro "api_gen.cpp" | Format (Global "clang-format") | Write "api_gen.cpp"}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 24 | {{$ | Macro "driver_gen.h" | Format (Global "clang-format") | Write "driver_gen.h"}} |
| 25 | {{$ | Macro "driver_gen.cpp" | Format (Global "clang-format") | Write "driver_gen.cpp"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 26 | |
| 27 | {{/* |
| 28 | ------------------------------------------------------------------------------- |
| 29 | api_gen.h |
| 30 | ------------------------------------------------------------------------------- |
| 31 | */}} |
| 32 | {{define "api_gen.h"}} |
| 33 | {{Macro "Copyright"}} |
| 34 | ¶ |
| 35 | // WARNING: This file is generated. See ../README.md for instructions. |
| 36 | ¶ |
| 37 | #ifndef LIBVULKAN_API_GEN_H |
| 38 | #define LIBVULKAN_API_GEN_H |
| 39 | ¶ |
| 40 | #include <vulkan/vulkan.h> |
Yiwei Zhang | 6d78a57 | 2019-04-10 15:35:38 -0700 | [diff] [blame] | 41 | ¶ |
| 42 | #include <bitset> |
| 43 | ¶ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 44 | #include "driver_gen.h" |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 45 | ¶ |
| 46 | namespace vulkan {« |
| 47 | namespace api {« |
| 48 | ¶ |
| 49 | struct InstanceDispatchTable { |
| 50 | // clang-format off |
| 51 | {{range $f := AllCommands $}} |
| 52 | {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}} |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 53 | {{Macro "C++.DeclareTableEntry" $f}}; |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 54 | {{end}} |
| 55 | {{end}} |
| 56 | // clang-format on |
| 57 | }; |
| 58 | ¶ |
| 59 | struct DeviceDispatchTable { |
| 60 | // clang-format off |
| 61 | {{range $f := AllCommands $}} |
| 62 | {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}} |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 63 | {{Macro "C++.DeclareTableEntry" $f}}; |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 64 | {{end}} |
| 65 | {{end}} |
| 66 | // clang-format on |
| 67 | }; |
| 68 | ¶ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 69 | bool InitDispatchTable( |
| 70 | VkInstance instance, |
| 71 | PFN_vkGetInstanceProcAddr get_proc, |
| 72 | const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions); |
| 73 | bool InitDispatchTable( |
| 74 | VkDevice dev, |
| 75 | PFN_vkGetDeviceProcAddr get_proc, |
| 76 | const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 77 | ¶ |
| 78 | »} // namespace api |
| 79 | »} // namespace vulkan |
| 80 | ¶ |
| 81 | #endif // LIBVULKAN_API_GEN_H |
| 82 | ¶{{end}} |
| 83 | |
| 84 | |
| 85 | {{/* |
| 86 | ------------------------------------------------------------------------------- |
| 87 | api_gen.cpp |
| 88 | ------------------------------------------------------------------------------- |
| 89 | */}} |
| 90 | {{define "api_gen.cpp"}} |
| 91 | {{Macro "Copyright"}} |
| 92 | ¶ |
| 93 | // WARNING: This file is generated. See ../README.md for instructions. |
| 94 | ¶ |
Yiwei Zhang | 6d78a57 | 2019-04-10 15:35:38 -0700 | [diff] [blame] | 95 | #include <log/log.h> |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 96 | #include <string.h> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 97 | ¶ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 98 | #include <algorithm> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 99 | ¶ |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 100 | // to catch mismatches between vulkan.h and this file |
| 101 | #undef VK_NO_PROTOTYPES |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 102 | #include "api.h" |
| 103 | ¶ |
| 104 | namespace vulkan {« |
| 105 | namespace api {« |
| 106 | ¶ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 107 | {{Macro "C++.DefineInitProcMacro" "dispatch"}} |
| 108 | ¶ |
| 109 | {{Macro "api.C++.DefineInitProcExtMacro"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 110 | ¶ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 111 | namespace {« |
| 112 | ¶ |
| 113 | // clang-format off |
| 114 | ¶ |
| 115 | {{range $f := AllCommands $}} |
| 116 | {{Macro "api.C++.DefineExtensionStub" $f}} |
| 117 | {{end}} |
| 118 | // clang-format on |
| 119 | ¶ |
| 120 | »} // anonymous |
| 121 | ¶ |
| 122 | bool InitDispatchTable( |
| 123 | VkInstance instance, |
| 124 | PFN_vkGetInstanceProcAddr get_proc, |
| 125 | const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) { |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 126 | auto& data = GetData(instance); |
| 127 | bool success = true; |
| 128 | ¶ |
| 129 | // clang-format off |
| 130 | {{range $f := AllCommands $}} |
| 131 | {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}} |
| 132 | {{Macro "C++.InitProc" $f}} |
| 133 | {{end}} |
| 134 | {{end}} |
| 135 | // clang-format on |
| 136 | ¶ |
| 137 | return success; |
| 138 | } |
| 139 | ¶ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 140 | bool InitDispatchTable( |
| 141 | VkDevice dev, |
| 142 | PFN_vkGetDeviceProcAddr get_proc, |
| 143 | const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) { |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 144 | auto& data = GetData(dev); |
| 145 | bool success = true; |
| 146 | ¶ |
| 147 | // clang-format off |
| 148 | {{range $f := AllCommands $}} |
| 149 | {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}} |
| 150 | {{Macro "C++.InitProc" $f}} |
| 151 | {{end}} |
| 152 | {{end}} |
| 153 | // clang-format on |
| 154 | ¶ |
| 155 | return success; |
| 156 | } |
| 157 | ¶ |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 158 | // clang-format off |
| 159 | ¶ |
| 160 | namespace {« |
| 161 | ¶ |
| 162 | // forward declarations needed by GetInstanceProcAddr and GetDeviceProcAddr |
| 163 | {{range $f := AllCommands $}} |
| 164 | {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}} |
| 165 | VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}}); |
| 166 | {{end}} |
| 167 | {{end}} |
| 168 | ¶ |
| 169 | {{range $f := AllCommands $}} |
| 170 | {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}} |
| 171 | VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}}) { |
| 172 | {{ if eq $f.Name "vkGetInstanceProcAddr"}} |
| 173 | {{Macro "api.C++.InterceptInstanceProcAddr" $}} |
| 174 | {{else if eq $f.Name "vkGetDeviceProcAddr"}} |
| 175 | {{Macro "api.C++.InterceptDeviceProcAddr" $}} |
| 176 | {{end}} |
| 177 | |
| 178 | {{Macro "api.C++.Dispatch" $f}} |
| 179 | } |
| 180 | ¶ |
| 181 | {{end}} |
| 182 | {{end}} |
| 183 | ¶ |
| 184 | »} // anonymous namespace |
| 185 | ¶ |
| 186 | // clang-format on |
| 187 | ¶ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 188 | »} // namespace api |
| 189 | »} // namespace vulkan |
| 190 | ¶ |
| 191 | // clang-format off |
| 192 | ¶ |
| 193 | {{range $f := AllCommands $}} |
| 194 | {{if (Macro "IsFunctionExported" $f)}} |
| 195 | __attribute__((visibility("default"))) |
| 196 | VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) { |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 197 | {{if not (IsVoid $f.Return.Type)}}return §{{end}} |
| 198 | vulkan::api::{{Macro "BaseName" $f}}({{Macro "Arguments" $f}}); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 199 | } |
| 200 | ¶ |
| 201 | {{end}} |
| 202 | {{end}} |
| 203 | ¶ |
| 204 | // clang-format on |
| 205 | ¶{{end}} |
| 206 | |
| 207 | |
| 208 | {{/* |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 209 | ------------------------------------------------------------------------------- |
| 210 | driver_gen.h |
| 211 | ------------------------------------------------------------------------------- |
| 212 | */}} |
| 213 | {{define "driver_gen.h"}} |
| 214 | {{Macro "Copyright"}} |
| 215 | ¶ |
| 216 | // WARNING: This file is generated. See ../README.md for instructions. |
| 217 | ¶ |
| 218 | #ifndef LIBVULKAN_DRIVER_GEN_H |
| 219 | #define LIBVULKAN_DRIVER_GEN_H |
| 220 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 221 | #include <vulkan/vk_android_native_buffer.h> |
Yiwei Zhang | 6d78a57 | 2019-04-10 15:35:38 -0700 | [diff] [blame] | 222 | #include <vulkan/vulkan.h> |
| 223 | ¶ |
| 224 | #include <bitset> |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 225 | ¶ |
| 226 | namespace vulkan {« |
| 227 | namespace driver {« |
| 228 | ¶ |
| 229 | {{Macro "driver.C++.DefineProcHookType"}} |
| 230 | ¶ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 231 | struct InstanceDriverTable { |
| 232 | // clang-format off |
| 233 | {{range $f := AllCommands $}} |
| 234 | {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}} |
| 235 | {{Macro "C++.DeclareTableEntry" $f}}; |
| 236 | {{end}} |
| 237 | {{end}} |
| 238 | // clang-format on |
| 239 | }; |
| 240 | ¶ |
| 241 | struct DeviceDriverTable { |
| 242 | // clang-format off |
| 243 | {{range $f := AllCommands $}} |
| 244 | {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}} |
| 245 | {{Macro "C++.DeclareTableEntry" $f}}; |
| 246 | {{end}} |
| 247 | {{end}} |
| 248 | // clang-format on |
| 249 | }; |
| 250 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 251 | const ProcHook* GetProcHook(const char* name); |
| 252 | ProcHook::Extension GetProcHookExtension(const char* name); |
| 253 | ¶ |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 254 | bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc, |
| 255 | const std::bitset<ProcHook::EXTENSION_COUNT> &extensions); |
| 256 | bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc, |
| 257 | const std::bitset<ProcHook::EXTENSION_COUNT> &extensions); |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 258 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 259 | »} // namespace driver |
| 260 | »} // namespace vulkan |
| 261 | ¶ |
| 262 | #endif // LIBVULKAN_DRIVER_TABLE_H |
| 263 | ¶{{end}} |
| 264 | |
| 265 | |
| 266 | {{/* |
| 267 | ------------------------------------------------------------------------------- |
| 268 | driver_gen.cpp |
| 269 | ------------------------------------------------------------------------------- |
| 270 | */}} |
| 271 | {{define "driver_gen.cpp"}} |
| 272 | {{Macro "Copyright"}} |
| 273 | ¶ |
| 274 | // WARNING: This file is generated. See ../README.md for instructions. |
| 275 | ¶ |
Yiwei Zhang | 6d78a57 | 2019-04-10 15:35:38 -0700 | [diff] [blame] | 276 | #include <log/log.h> |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 277 | #include <string.h> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 278 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 279 | #include <algorithm> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 280 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 281 | #include "driver.h" |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 282 | ¶ |
| 283 | namespace vulkan {« |
| 284 | namespace driver {« |
| 285 | ¶ |
| 286 | namespace {« |
| 287 | ¶ |
| 288 | // clang-format off |
| 289 | ¶ |
| 290 | {{range $f := AllCommands $}} |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 291 | {{Macro "driver.C++.DefineProcHookStub" $f}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 292 | {{end}} |
| 293 | // clang-format on |
| 294 | ¶ |
| 295 | const ProcHook g_proc_hooks[] = { |
| 296 | // clang-format off |
| 297 | {{range $f := SortBy (AllCommands $) "FunctionName"}} |
| 298 | {{if (Macro "driver.IsIntercepted" $f)}} |
| 299 | {{ if (Macro "IsGloballyDispatched" $f)}} |
| 300 | {{Macro "driver.C++.DefineGlobalProcHook" $f}} |
| 301 | {{else if (Macro "IsInstanceDispatched" $f)}} |
| 302 | {{Macro "driver.C++.DefineInstanceProcHook" $f}} |
| 303 | {{else if (Macro "IsDeviceDispatched" $f)}} |
| 304 | {{Macro "driver.C++.DefineDeviceProcHook" $f}} |
| 305 | {{end}} |
| 306 | {{end}} |
| 307 | {{end}} |
| 308 | // clang-format on |
| 309 | }; |
| 310 | ¶ |
| 311 | »} // anonymous |
| 312 | ¶ |
| 313 | const ProcHook* GetProcHook(const char* name) { |
| 314 | const auto& begin = g_proc_hooks; |
| 315 | const auto& end = g_proc_hooks + |
| 316 | sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]); |
| 317 | const auto hook = std::lower_bound(begin, end, name, |
| 318 | [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; }); |
| 319 | return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr; |
| 320 | } |
| 321 | ¶ |
| 322 | ProcHook::Extension GetProcHookExtension(const char* name) { |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 323 | {{$exts := Strings (Macro "driver.KnownExtensions") | SplitOn "\n"}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 324 | // clang-format off |
| 325 | {{range $e := $exts}} |
| 326 | if (strcmp(name, "{{$e}}") == 0) return ProcHook::{{TrimPrefix "VK_" $e}}; |
| 327 | {{end}} |
| 328 | // clang-format on |
| 329 | return ProcHook::EXTENSION_UNKNOWN; |
| 330 | } |
| 331 | ¶ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 332 | {{Macro "C++.DefineInitProcMacro" "driver"}} |
| 333 | ¶ |
| 334 | {{Macro "driver.C++.DefineInitProcExtMacro"}} |
| 335 | ¶ |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 336 | bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc, |
| 337 | const std::bitset<ProcHook::EXTENSION_COUNT> &extensions) |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 338 | { |
| 339 | auto& data = GetData(instance); |
| 340 | bool success = true; |
| 341 | ¶ |
| 342 | // clang-format off |
| 343 | {{range $f := AllCommands $}} |
| 344 | {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}} |
| 345 | {{Macro "C++.InitProc" $f}} |
| 346 | {{end}} |
| 347 | {{end}} |
| 348 | // clang-format on |
| 349 | ¶ |
| 350 | return success; |
| 351 | } |
| 352 | ¶ |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 353 | bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc, |
| 354 | const std::bitset<ProcHook::EXTENSION_COUNT> &extensions) |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 355 | { |
| 356 | auto& data = GetData(dev); |
| 357 | bool success = true; |
| 358 | ¶ |
| 359 | // clang-format off |
| 360 | {{range $f := AllCommands $}} |
| 361 | {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}} |
| 362 | {{Macro "C++.InitProc" $f}} |
| 363 | {{end}} |
| 364 | {{end}} |
| 365 | // clang-format on |
| 366 | ¶ |
| 367 | return success; |
| 368 | } |
| 369 | ¶ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 370 | »} // namespace driver |
| 371 | »} // namespace vulkan |
| 372 | ¶ |
| 373 | // clang-format on |
| 374 | ¶{{end}} |
| 375 | |
| 376 | |
| 377 | {{/* |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 378 | ------------------------------------------------------------------------------ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 379 | Emits a declaration of a dispatch/driver table entry. |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 380 | ------------------------------------------------------------------------------ |
| 381 | */}} |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 382 | {{define "C++.DeclareTableEntry"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 383 | {{AssertType $ "Function"}} |
| 384 | |
| 385 | {{Macro "FunctionPtrName" $}} {{Macro "BaseName" $}} |
| 386 | {{end}} |
| 387 | |
| 388 | |
| 389 | {{/* |
| 390 | ------------------------------------------------------------------------------- |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 391 | Emits INIT_PROC macro. |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 392 | ------------------------------------------------------------------------------- |
| 393 | */}} |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 394 | {{define "C++.DefineInitProcMacro"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 395 | #define UNLIKELY(expr) __builtin_expect((expr), 0) |
| 396 | ¶ |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 397 | #define INIT_PROC(required, obj, proc) do { \ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 398 | data.{{$}}.proc = reinterpret_cast<PFN_vk ## proc>( \ |
| 399 | get_proc(obj, "vk" # proc)); \ |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 400 | if (UNLIKELY(required && !data.{{$}}.proc)) { \ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 401 | ALOGE("missing " # obj " proc: vk" # proc); \ |
| 402 | success = false; \ |
| 403 | } \ |
| 404 | } while(0) |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 405 | {{end}} |
| 406 | |
| 407 | |
| 408 | {{/* |
| 409 | ------------------------------------------------------------------------------- |
| 410 | Emits code to invoke INIT_PROC or INIT_PROC_EXT. |
| 411 | ------------------------------------------------------------------------------- |
| 412 | */}} |
| 413 | {{define "C++.InitProc"}} |
| 414 | {{AssertType $ "Function"}} |
| 415 | |
| 416 | {{$ext := GetAnnotation $ "extension"}} |
| 417 | {{if $ext}} |
Jesse Hall | d1abd74 | 2017-02-09 21:45:51 -0800 | [diff] [blame] | 418 | INIT_PROC_EXT({{Macro "BaseName" $ext}}, § |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 419 | {{else}} |
Jesse Hall | d1abd74 | 2017-02-09 21:45:51 -0800 | [diff] [blame] | 420 | INIT_PROC(§ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 421 | {{end}} |
| 422 | |
Ian Elliott | 28bd2c3 | 2017-10-13 09:21:12 -0600 | [diff] [blame] | 423 | {{if GetAnnotation $ "optional"}}false{{else if GetAnnotation $ "vulkan1_1"}}false{{else}}true{{end}}, § |
Jesse Hall | d1abd74 | 2017-02-09 21:45:51 -0800 | [diff] [blame] | 424 | |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 425 | {{if (Macro "IsInstanceDispatched" $)}} |
| 426 | instance, § |
| 427 | {{else}} |
| 428 | dev, § |
| 429 | {{end}} |
| 430 | |
| 431 | {{Macro "BaseName" $}}); |
| 432 | {{end}} |
| 433 | |
| 434 | |
| 435 | {{/* |
| 436 | ------------------------------------------------------------------------------ |
| 437 | Emits true if a function is exported and instance-dispatched. |
| 438 | ------------------------------------------------------------------------------ |
| 439 | */}} |
| 440 | {{define "api.IsInstanceDispatchTableEntry"}} |
| 441 | {{AssertType $ "Function"}} |
| 442 | |
| 443 | {{if and (Macro "IsFunctionExported" $) (Macro "IsInstanceDispatched" $)}} |
Chia-I Wu | dbd33bc | 2016-06-02 11:25:47 +0800 | [diff] [blame] | 444 | {{/* deprecated and unused internally */}} |
| 445 | {{if not (eq $.Name "vkEnumerateDeviceLayerProperties")}} |
| 446 | true |
| 447 | {{end}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 448 | {{end}} |
| 449 | {{end}} |
| 450 | |
| 451 | |
| 452 | {{/* |
| 453 | ------------------------------------------------------------------------------ |
| 454 | Emits true if a function is exported and device-dispatched. |
| 455 | ------------------------------------------------------------------------------ |
| 456 | */}} |
| 457 | {{define "api.IsDeviceDispatchTableEntry"}} |
| 458 | {{AssertType $ "Function"}} |
| 459 | |
| 460 | {{if and (Macro "IsFunctionExported" $) (Macro "IsDeviceDispatched" $)}} |
| 461 | true |
| 462 | {{end}} |
| 463 | {{end}} |
| 464 | |
| 465 | |
| 466 | {{/* |
| 467 | ------------------------------------------------------------------------------ |
| 468 | Emits true if a function is intercepted by vulkan::api. |
| 469 | ------------------------------------------------------------------------------ |
| 470 | */}} |
| 471 | {{define "api.IsIntercepted"}} |
| 472 | {{AssertType $ "Function"}} |
| 473 | |
| 474 | {{if (Macro "IsFunctionSupported" $)}} |
| 475 | {{/* Global functions cannot be dispatched at all */}} |
| 476 | {{ if (Macro "IsGloballyDispatched" $)}}true |
| 477 | |
| 478 | {{/* VkPhysicalDevice functions that manage device layers */}} |
| 479 | {{else if eq $.Name "vkCreateDevice"}}true |
| 480 | {{else if eq $.Name "vkEnumerateDeviceLayerProperties"}}true |
| 481 | {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true |
| 482 | |
| 483 | {{/* Destroy functions of dispatchable objects */}} |
| 484 | {{else if eq $.Name "vkDestroyInstance"}}true |
| 485 | {{else if eq $.Name "vkDestroyDevice"}}true |
| 486 | |
| 487 | {{end}} |
| 488 | {{end}} |
| 489 | {{end}} |
| 490 | |
| 491 | |
| 492 | {{/* |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 493 | ------------------------------------------------------------------------------- |
| 494 | Emits INIT_PROC_EXT macro for vulkan::api. |
| 495 | ------------------------------------------------------------------------------- |
| 496 | */}} |
| 497 | {{define "api.C++.DefineInitProcExtMacro"}} |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 498 | // Exported extension functions may be invoked even when their extensions |
| 499 | // are disabled. Dispatch to stubs when that happens. |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 500 | #define INIT_PROC_EXT(ext, required, obj, proc) do { \ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 501 | if (extensions[driver::ProcHook::ext]) \ |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 502 | INIT_PROC(required, obj, proc); \ |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 503 | else \ |
| 504 | data.dispatch.proc = disabled ## proc; \ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 505 | } while(0) |
| 506 | {{end}} |
| 507 | |
| 508 | |
| 509 | {{/* |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 510 | ------------------------------------------------------------------------------- |
| 511 | Emits a stub for an exported extension function. |
| 512 | ------------------------------------------------------------------------------- |
| 513 | */}} |
| 514 | {{define "api.C++.DefineExtensionStub"}} |
| 515 | {{AssertType $ "Function"}} |
| 516 | |
| 517 | {{$ext := GetAnnotation $ "extension"}} |
| 518 | {{if and $ext (Macro "IsFunctionExported" $)}} |
| 519 | {{$ext_name := index $ext.Arguments 0}} |
| 520 | |
| 521 | {{$base := (Macro "BaseName" $)}} |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 522 | |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 523 | {{$p0 := (index $.CallParameters 0)}} |
| 524 | {{$ptail := (Tail 1 $.CallParameters)}} |
| 525 | |
| 526 | {{$first_type := (Macro "Parameter" $p0)}} |
| 527 | {{$tail_types := (ForEach $ptail "ParameterType" | JoinWith ", ")}} |
| 528 | |
| 529 | VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$first_type}}, {{$tail_types}}) { |
| 530 | driver::Logger({{$p0.Name}}).Err({{$p0.Name}}, § |
| 531 | "{{$ext_name}} not enabled. Exported {{$.Name}} not executed."); |
Chia-I Wu | 8925efd | 2016-04-13 15:13:21 +0800 | [diff] [blame] | 532 | {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}} |
| 533 | } |
| 534 | ¶ |
| 535 | {{end}} |
| 536 | {{end}} |
| 537 | |
| 538 | |
| 539 | {{/* |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 540 | ------------------------------------------------------------------------------ |
| 541 | Emits code for vkGetInstanceProcAddr for function interception. |
| 542 | ------------------------------------------------------------------------------ |
| 543 | */}} |
| 544 | {{define "api.C++.InterceptInstanceProcAddr"}} |
| 545 | {{AssertType $ "API"}} |
| 546 | |
| 547 | // global functions |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 548 | if (instance == VK_NULL_HANDLE) { |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 549 | {{range $f := AllCommands $}} |
| 550 | {{if (Macro "IsGloballyDispatched" $f)}} |
| 551 | if (strcmp(pName, "{{$f.Name}}") == 0) return § |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 552 | reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 553 | {{end}} |
| 554 | {{end}} |
| 555 | ¶ |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 556 | ALOGE("invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, \"%s\") call", pName); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 557 | return nullptr; |
| 558 | } |
| 559 | ¶ |
| 560 | static const struct Hook { |
| 561 | const char* name; |
| 562 | PFN_vkVoidFunction proc; |
| 563 | } hooks[] = { |
| 564 | {{range $f := SortBy (AllCommands $) "FunctionName"}} |
| 565 | {{if (Macro "IsFunctionExported" $f)}} |
| 566 | {{/* hide global functions */}} |
| 567 | {{if (Macro "IsGloballyDispatched" $f)}} |
| 568 | { "{{$f.Name}}", nullptr }, |
| 569 | |
| 570 | {{/* redirect intercepted functions */}} |
| 571 | {{else if (Macro "api.IsIntercepted" $f)}} |
| 572 | { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§ |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 573 | {{Macro "BaseName" $f}}) }, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 574 | |
| 575 | {{/* redirect vkGetInstanceProcAddr to itself */}} |
| 576 | {{else if eq $f.Name "vkGetInstanceProcAddr"}} |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 577 | { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) }, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 578 | |
| 579 | {{/* redirect device functions to themselves as a workaround for |
| 580 | layers that do not intercept in their vkGetInstanceProcAddr */}} |
| 581 | {{else if (Macro "IsDeviceDispatched" $f)}} |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 582 | { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) }, |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 583 | |
| 584 | {{end}} |
| 585 | {{end}} |
| 586 | {{end}} |
| 587 | }; |
| 588 | // clang-format on |
| 589 | constexpr size_t count = sizeof(hooks) / sizeof(hooks[0]); |
| 590 | auto hook = std::lower_bound( |
| 591 | hooks, hooks + count, pName, |
| 592 | [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; }); |
| 593 | if (hook < hooks + count && strcmp(hook->name, pName) == 0) { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 594 | if (!hook->proc) { |
| 595 | vulkan::driver::Logger(instance).Err( |
| 596 | instance, "invalid vkGetInstanceProcAddr(%p, \"%s\") call", |
| 597 | instance, pName); |
| 598 | } |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 599 | return hook->proc; |
| 600 | } |
| 601 | // clang-format off |
| 602 | ¶ |
| 603 | {{end}} |
| 604 | |
| 605 | |
| 606 | {{/* |
| 607 | ------------------------------------------------------------------------------ |
| 608 | Emits code for vkGetDeviceProcAddr for function interception. |
| 609 | ------------------------------------------------------------------------------ |
| 610 | */}} |
| 611 | {{define "api.C++.InterceptDeviceProcAddr"}} |
| 612 | {{AssertType $ "API"}} |
| 613 | |
| 614 | if (device == VK_NULL_HANDLE) { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 615 | ALOGE("invalid vkGetDeviceProcAddr(VK_NULL_HANDLE, ...) call"); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 616 | return nullptr; |
| 617 | } |
| 618 | ¶ |
| 619 | static const char* const known_non_device_names[] = { |
| 620 | {{range $f := SortBy (AllCommands $) "FunctionName"}} |
| 621 | {{if (Macro "IsFunctionSupported" $f)}} |
| 622 | {{if not (Macro "IsDeviceDispatched" $f)}} |
| 623 | "{{$f.Name}}", |
| 624 | {{end}} |
| 625 | {{end}} |
| 626 | {{end}} |
| 627 | }; |
| 628 | // clang-format on |
| 629 | constexpr size_t count = sizeof(known_non_device_names) / |
| 630 | sizeof(known_non_device_names[0]); |
| 631 | if (!pName || |
| 632 | std::binary_search( |
| 633 | known_non_device_names, known_non_device_names + count, pName, |
| 634 | [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 635 | vulkan::driver::Logger(device).Err(§ |
| 636 | device, "invalid vkGetDeviceProcAddr(%p, \"%s\") call", device,§ |
| 637 | (pName) ? pName : "(null)"); |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 638 | return nullptr; |
| 639 | } |
| 640 | // clang-format off |
| 641 | ¶ |
Chia-I Wu | c56603e | 2016-04-12 11:16:17 +0800 | [diff] [blame] | 642 | {{range $f := AllCommands $}} |
| 643 | {{if (Macro "IsDeviceDispatched" $f)}} |
| 644 | {{ if (Macro "api.IsIntercepted" $f)}} |
| 645 | if (strcmp(pName, "{{$f.Name}}") == 0) return § |
| 646 | reinterpret_cast<PFN_vkVoidFunction>(§ |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 647 | {{Macro "BaseName" $f}}); |
Chia-I Wu | c56603e | 2016-04-12 11:16:17 +0800 | [diff] [blame] | 648 | {{else if eq $f.Name "vkGetDeviceProcAddr"}} |
| 649 | if (strcmp(pName, "{{$f.Name}}") == 0) return § |
| 650 | reinterpret_cast<PFN_vkVoidFunction>(§ |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 651 | {{Macro "BaseName" $f}}); |
Chia-I Wu | c56603e | 2016-04-12 11:16:17 +0800 | [diff] [blame] | 652 | {{end}} |
| 653 | {{end}} |
| 654 | {{end}} |
| 655 | ¶ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 656 | {{end}} |
| 657 | |
| 658 | |
| 659 | {{/* |
| 660 | ------------------------------------------------------------------------------ |
| 661 | Emits code to dispatch a function. |
| 662 | ------------------------------------------------------------------------------ |
| 663 | */}} |
| 664 | {{define "api.C++.Dispatch"}} |
| 665 | {{AssertType $ "Function"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 666 | {{if (Macro "api.IsIntercepted" $)}} |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 667 | {{Error "$.Name should not be generated"}} |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 668 | {{end}} |
| 669 | |
Chia-I Wu | 3e654dc | 2016-05-20 16:15:06 +0800 | [diff] [blame] | 670 | {{if not (IsVoid $.Return.Type)}}return §{{end}} |
| 671 | |
| 672 | {{$p0 := index $.CallParameters 0}} |
| 673 | GetData({{$p0.Name}}).dispatch.§ |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 674 | {{Macro "BaseName" $}}({{Macro "Arguments" $}}); |
| 675 | {{end}} |
| 676 | |
| 677 | |
| 678 | {{/* |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 679 | ------------------------------------------------------------------------------ |
| 680 | Emits a list of extensions intercepted by vulkan::driver. |
| 681 | ------------------------------------------------------------------------------ |
| 682 | */}} |
| 683 | {{define "driver.InterceptedExtensions"}} |
| 684 | VK_ANDROID_native_buffer |
| 685 | VK_EXT_debug_report |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 686 | VK_EXT_hdr_metadata |
Courtney Goeltzenleuchter | e278daf | 2017-02-02 16:54:57 -0700 | [diff] [blame] | 687 | VK_EXT_swapchain_colorspace |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 688 | VK_GOOGLE_display_timing |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 689 | VK_KHR_android_surface |
Ian Elliott | 948233a | 2017-01-06 12:13:23 -0700 | [diff] [blame] | 690 | VK_KHR_incremental_present |
Courtney Goeltzenleuchter | e278daf | 2017-02-02 16:54:57 -0700 | [diff] [blame] | 691 | VK_KHR_shared_presentable_image |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 692 | VK_KHR_surface |
| 693 | VK_KHR_swapchain |
Chris Forbes | 2452cf7 | 2017-03-16 16:30:17 +1300 | [diff] [blame] | 694 | VK_KHR_get_surface_capabilities2 |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 695 | {{end}} |
| 696 | |
| 697 | |
| 698 | {{/* |
| 699 | ------------------------------------------------------------------------------ |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 700 | Emits a list of extensions known to vulkan::driver. |
| 701 | ------------------------------------------------------------------------------ |
| 702 | */}} |
| 703 | {{define "driver.KnownExtensions"}} |
| 704 | {{Macro "driver.InterceptedExtensions"}} |
| 705 | VK_KHR_get_physical_device_properties2 |
Jesse Hall | caea411 | 2018-01-18 15:40:46 -0800 | [diff] [blame] | 706 | VK_ANDROID_external_memory_android_hardware_buffer |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 707 | VK_KHR_bind_memory2 |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 708 | {{end}} |
| 709 | |
| 710 | |
| 711 | {{/* |
| 712 | ------------------------------------------------------------------------------ |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 713 | Emits true if an extension is intercepted by vulkan::driver. |
| 714 | ------------------------------------------------------------------------------ |
| 715 | */}} |
| 716 | {{define "driver.IsExtensionIntercepted"}} |
| 717 | {{$ext_name := index $.Arguments 0}} |
| 718 | {{$filters := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}} |
| 719 | |
| 720 | {{range $f := $filters}} |
| 721 | {{if eq $ext_name $f}}true{{end}} |
| 722 | {{end}} |
| 723 | {{end}} |
| 724 | |
| 725 | |
| 726 | {{/* |
| 727 | ------------------------------------------------------------------------------ |
| 728 | Emits true if a function is intercepted by vulkan::driver. |
| 729 | ------------------------------------------------------------------------------ |
| 730 | */}} |
| 731 | {{define "driver.IsIntercepted"}} |
| 732 | {{AssertType $ "Function"}} |
| 733 | |
| 734 | {{if (Macro "IsFunctionSupported" $)}} |
| 735 | {{/* Create functions of dispatchable objects */}} |
| 736 | {{ if eq $.Name "vkCreateInstance"}}true |
| 737 | {{else if eq $.Name "vkCreateDevice"}}true |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 738 | {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true |
Daniel Koch | 09f7bf9 | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 739 | {{else if eq $.Name "vkEnumeratePhysicalDeviceGroups"}}true |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 740 | {{else if eq $.Name "vkGetDeviceQueue"}}true |
Daniel Koch | 09f7bf9 | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 741 | {{else if eq $.Name "vkGetDeviceQueue2"}}true |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 742 | {{else if eq $.Name "vkAllocateCommandBuffers"}}true |
| 743 | |
| 744 | {{/* Destroy functions of dispatchable objects */}} |
| 745 | {{else if eq $.Name "vkDestroyInstance"}}true |
| 746 | {{else if eq $.Name "vkDestroyDevice"}}true |
| 747 | |
| 748 | {{/* Enumeration of extensions */}} |
| 749 | {{else if eq $.Name "vkEnumerateInstanceExtensionProperties"}}true |
| 750 | {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true |
| 751 | |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 752 | {{else if eq $.Name "vkGetInstanceProcAddr"}}true |
| 753 | {{else if eq $.Name "vkGetDeviceProcAddr"}}true |
| 754 | |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 755 | {{/* VK_KHR_swapchain v69 requirement */}} |
| 756 | {{else if eq $.Name "vkBindImageMemory2"}}true |
| 757 | {{else if eq $.Name "vkBindImageMemory2KHR"}}true |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 758 | {{end}} |
| 759 | |
| 760 | {{$ext := GetAnnotation $ "extension"}} |
| 761 | {{if $ext}} |
| 762 | {{Macro "driver.IsExtensionIntercepted" $ext}} |
| 763 | {{end}} |
| 764 | |
| 765 | {{end}} |
| 766 | {{end}} |
| 767 | |
| 768 | |
| 769 | {{/* |
| 770 | ------------------------------------------------------------------------------ |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 771 | Emits true if a function needs a ProcHook stub. |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 772 | ------------------------------------------------------------------------------ |
| 773 | */}} |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 774 | {{define "driver.NeedProcHookStub"}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 775 | {{AssertType $ "Function"}} |
| 776 | |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 777 | {{if and (Macro "driver.IsIntercepted" $) (Macro "IsDeviceDispatched" $)}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 778 | {{$ext := GetAnnotation $ "extension"}} |
| 779 | {{if $ext}} |
| 780 | {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}} |
| 781 | {{end}} |
| 782 | {{end}} |
| 783 | {{end}} |
| 784 | |
| 785 | |
| 786 | {{/* |
| 787 | ------------------------------------------------------------------------------- |
| 788 | Emits definition of struct ProcHook. |
| 789 | ------------------------------------------------------------------------------- |
| 790 | */}} |
| 791 | {{define "driver.C++.DefineProcHookType"}} |
| 792 | struct ProcHook { |
| 793 | enum Type { |
| 794 | GLOBAL, |
| 795 | INSTANCE, |
| 796 | DEVICE, |
| 797 | }; |
| 798 | |
| 799 | enum Extension { |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 800 | {{$exts := Strings (Macro "driver.KnownExtensions") | SplitOn "\n"}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 801 | {{range $e := $exts}} |
| 802 | {{TrimPrefix "VK_" $e}}, |
| 803 | {{end}} |
| 804 | ¶ |
| 805 | EXTENSION_CORE, // valid bit |
| 806 | EXTENSION_COUNT, |
| 807 | EXTENSION_UNKNOWN, |
| 808 | }; |
| 809 | ¶ |
| 810 | const char* name; |
| 811 | Type type; |
| 812 | Extension extension; |
| 813 | ¶ |
| 814 | PFN_vkVoidFunction proc; |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 815 | PFN_vkVoidFunction checked_proc; // always nullptr for non-device hooks |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 816 | }; |
| 817 | {{end}} |
| 818 | |
| 819 | |
| 820 | {{/* |
| 821 | ------------------------------------------------------------------------------- |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 822 | Emits INIT_PROC_EXT macro for vulkan::driver. |
| 823 | ------------------------------------------------------------------------------- |
| 824 | */}} |
| 825 | {{define "driver.C++.DefineInitProcExtMacro"}} |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 826 | #define INIT_PROC_EXT(ext, required, obj, proc) do { \ |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 827 | if (extensions[ProcHook::ext]) \ |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 828 | INIT_PROC(required, obj, proc); \ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 829 | } while(0) |
| 830 | {{end}} |
| 831 | |
| 832 | |
| 833 | {{/* |
| 834 | ------------------------------------------------------------------------------- |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 835 | Emits a stub for ProcHook::checked_proc. |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 836 | ------------------------------------------------------------------------------- |
| 837 | */}} |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 838 | {{define "driver.C++.DefineProcHookStub"}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 839 | {{AssertType $ "Function"}} |
| 840 | |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 841 | {{if (Macro "driver.NeedProcHookStub" $)}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 842 | {{$ext := GetAnnotation $ "extension"}} |
| 843 | {{$ext_name := index $ext.Arguments 0}} |
| 844 | |
| 845 | {{$base := (Macro "BaseName" $)}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 846 | |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 847 | VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) { |
| 848 | {{$p0 := index $.CallParameters 0}} |
| 849 | {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 850 | |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 851 | if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) { |
| 852 | {{if not (IsVoid $.Return.Type)}}return §{{end}} |
| 853 | {{$base}}({{Macro "Arguments" $}}); |
| 854 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 855 | Logger({{$p0.Name}}).Err({{$p0.Name}}, "{{$ext_name}} not enabled. {{$.Name}} not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 856 | {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 857 | } |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 858 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 859 | ¶ |
| 860 | {{end}} |
| 861 | {{end}} |
| 862 | |
| 863 | |
| 864 | {{/* |
| 865 | ------------------------------------------------------------------------------- |
| 866 | Emits definition of a global ProcHook. |
| 867 | ------------------------------------------------------------------------------- |
| 868 | */}} |
| 869 | {{define "driver.C++.DefineGlobalProcHook"}} |
| 870 | {{AssertType $ "Function"}} |
| 871 | |
| 872 | {{$base := (Macro "BaseName" $)}} |
| 873 | |
| 874 | {{$ext := GetAnnotation $ "extension"}} |
| 875 | {{if $ext}} |
| 876 | {{Error "invalid global extension"}} |
| 877 | {{end}} |
| 878 | |
| 879 | { |
| 880 | "{{$.Name}}", |
| 881 | ProcHook::GLOBAL, |
| 882 | ProcHook::EXTENSION_CORE, |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 883 | reinterpret_cast<PFN_vkVoidFunction>({{$base}}), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 884 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 885 | }, |
| 886 | {{end}} |
| 887 | |
| 888 | |
| 889 | {{/* |
| 890 | ------------------------------------------------------------------------------- |
| 891 | Emits definition of an instance ProcHook. |
| 892 | ------------------------------------------------------------------------------- |
| 893 | */}} |
| 894 | {{define "driver.C++.DefineInstanceProcHook"}} |
| 895 | {{AssertType $ "Function"}} |
| 896 | |
| 897 | {{$base := (Macro "BaseName" $)}} |
| 898 | |
| 899 | { |
| 900 | "{{$.Name}}", |
| 901 | ProcHook::INSTANCE, |
| 902 | |
| 903 | {{$ext := GetAnnotation $ "extension"}} |
| 904 | {{if $ext}} |
| 905 | ProcHook::{{Macro "BaseName" $ext}}, |
| 906 | |
| 907 | {{if (Macro "IsExtensionInternal" $ext)}} |
| 908 | nullptr, |
| 909 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 910 | {{else}} |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 911 | reinterpret_cast<PFN_vkVoidFunction>({{$base}}), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 912 | nullptr, |
| 913 | {{end}} |
| 914 | {{else}} |
| 915 | ProcHook::EXTENSION_CORE, |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 916 | reinterpret_cast<PFN_vkVoidFunction>({{$base}}), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 917 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 918 | {{end}} |
| 919 | }, |
| 920 | {{end}} |
| 921 | |
| 922 | |
| 923 | {{/* |
| 924 | ------------------------------------------------------------------------------- |
| 925 | Emits definition of a device ProcHook. |
| 926 | ------------------------------------------------------------------------------- |
| 927 | */}} |
| 928 | {{define "driver.C++.DefineDeviceProcHook"}} |
| 929 | {{AssertType $ "Function"}} |
| 930 | |
| 931 | {{$base := (Macro "BaseName" $)}} |
| 932 | |
| 933 | { |
| 934 | "{{$.Name}}", |
| 935 | ProcHook::DEVICE, |
| 936 | |
| 937 | {{$ext := GetAnnotation $ "extension"}} |
| 938 | {{if $ext}} |
| 939 | ProcHook::{{Macro "BaseName" $ext}}, |
| 940 | |
| 941 | {{if (Macro "IsExtensionInternal" $ext)}} |
| 942 | nullptr, |
| 943 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 944 | {{else}} |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 945 | reinterpret_cast<PFN_vkVoidFunction>({{$base}}), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 946 | reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}), |
| 947 | {{end}} |
| 948 | {{else}} |
Chia-I Wu | 4901db7 | 2016-03-24 16:38:58 +0800 | [diff] [blame] | 949 | ProcHook::EXTENSION_CORE, |
| 950 | reinterpret_cast<PFN_vkVoidFunction>({{$base}}), |
| 951 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 952 | {{end}} |
| 953 | }, |
| 954 | {{end}} |
| 955 | |
| 956 | |
| 957 | {{/* |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 958 | ------------------------------------------------------------------------------- |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 959 | Emits true if a function is needed by vulkan::driver. |
| 960 | ------------------------------------------------------------------------------- |
| 961 | */}} |
| 962 | {{define "driver.IsDriverTableEntry"}} |
| 963 | {{AssertType $ "Function"}} |
| 964 | |
| 965 | {{if (Macro "IsFunctionSupported" $)}} |
| 966 | {{/* Create functions of dispatchable objects */}} |
| 967 | {{ if eq $.Name "vkCreateDevice"}}true |
| 968 | {{else if eq $.Name "vkGetDeviceQueue"}}true |
Daniel Koch | 09f7bf9 | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 969 | {{else if eq $.Name "vkGetDeviceQueue2"}}true |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 970 | {{else if eq $.Name "vkAllocateCommandBuffers"}}true |
| 971 | |
| 972 | {{/* Destroy functions of dispatchable objects */}} |
| 973 | {{else if eq $.Name "vkDestroyInstance"}}true |
| 974 | {{else if eq $.Name "vkDestroyDevice"}}true |
| 975 | |
| 976 | {{/* Enumeration of extensions */}} |
| 977 | {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true |
| 978 | |
| 979 | {{/* We cache physical devices in loader.cpp */}} |
| 980 | {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true |
Daniel Koch | 09f7bf9 | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 981 | {{else if eq $.Name "vkEnumeratePhysicalDeviceGroups"}}true |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 982 | |
| 983 | {{else if eq $.Name "vkGetInstanceProcAddr"}}true |
| 984 | {{else if eq $.Name "vkGetDeviceProcAddr"}}true |
| 985 | |
| 986 | {{/* VK_KHR_swapchain->VK_ANDROID_native_buffer translation */}} |
| 987 | {{else if eq $.Name "vkCreateImage"}}true |
| 988 | {{else if eq $.Name "vkDestroyImage"}}true |
| 989 | |
Jesse Hall | 85bb0c5 | 2017-02-09 22:13:02 -0800 | [diff] [blame] | 990 | {{else if eq $.Name "vkGetPhysicalDeviceProperties"}}true |
Yiwei Zhang | c1c9d3c | 2018-03-13 17:12:11 -0700 | [diff] [blame] | 991 | {{else if eq $.Name "vkGetPhysicalDeviceProperties2"}}true |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 992 | {{else if eq $.Name "vkGetPhysicalDeviceProperties2KHR"}}true |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 993 | |
| 994 | {{/* VK_KHR_swapchain v69 requirement */}} |
| 995 | {{else if eq $.Name "vkBindImageMemory2"}}true |
| 996 | {{else if eq $.Name "vkBindImageMemory2KHR"}}true |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 997 | {{end}} |
| 998 | |
| 999 | {{$ext := GetAnnotation $ "extension"}} |
| 1000 | {{if $ext}} |
| 1001 | {{$ext_name := index $ext.Arguments 0}} |
| 1002 | {{ if eq $ext_name "VK_ANDROID_native_buffer"}}true |
| 1003 | {{else if eq $ext_name "VK_EXT_debug_report"}}true |
| 1004 | {{end}} |
| 1005 | {{end}} |
| 1006 | {{end}} |
| 1007 | {{end}} |
| 1008 | |
| 1009 | |
| 1010 | {{/* |
| 1011 | ------------------------------------------------------------------------------ |
| 1012 | Emits true if an instance-dispatched function is needed by vulkan::driver. |
| 1013 | ------------------------------------------------------------------------------ |
| 1014 | */}} |
| 1015 | {{define "driver.IsInstanceDriverTableEntry"}} |
| 1016 | {{AssertType $ "Function"}} |
| 1017 | |
| 1018 | {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsInstanceDispatched" $)}} |
| 1019 | true |
| 1020 | {{end}} |
| 1021 | {{end}} |
| 1022 | |
| 1023 | |
| 1024 | {{/* |
| 1025 | ------------------------------------------------------------------------------ |
| 1026 | Emits true if a device-dispatched function is needed by vulkan::driver. |
| 1027 | ------------------------------------------------------------------------------ |
| 1028 | */}} |
| 1029 | {{define "driver.IsDeviceDriverTableEntry"}} |
| 1030 | {{AssertType $ "Function"}} |
| 1031 | |
| 1032 | {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsDeviceDispatched" $)}} |
| 1033 | true |
| 1034 | {{end}} |
| 1035 | {{end}} |
| 1036 | |
| 1037 | |
| 1038 | {{/* |
| 1039 | ------------------------------------------------------------------------------- |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1040 | Emits a function/extension name without the "vk"/"VK_" prefix. |
| 1041 | ------------------------------------------------------------------------------- |
| 1042 | */}} |
| 1043 | {{define "BaseName"}} |
| 1044 | {{ if IsFunction $}}{{TrimPrefix "vk" $.Name}} |
| 1045 | {{else if eq $.Name "extension"}}{{TrimPrefix "VK_" (index $.Arguments 0)}} |
| 1046 | {{else}}{{Error "invalid use of BaseName"}} |
| 1047 | {{end}} |
| 1048 | {{end}} |
| 1049 | |
| 1050 | |
| 1051 | {{/* |
| 1052 | ------------------------------------------------------------------------------- |
| 1053 | Emits a comma-separated list of C parameter names for the given command. |
| 1054 | ------------------------------------------------------------------------------- |
| 1055 | */}} |
| 1056 | {{define "Arguments"}} |
| 1057 | {{AssertType $ "Function"}} |
| 1058 | |
| 1059 | {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}} |
| 1060 | {{end}} |
| 1061 | |
| 1062 | |
| 1063 | {{/* |
| 1064 | ------------------------------------------------------------------------------ |
| 1065 | ------------------------------------------------------------------------------ |
| 1066 | */}} |
| 1067 | {{define "IsGloballyDispatched"}} |
| 1068 | {{AssertType $ "Function"}} |
| 1069 | {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Global")}} |
| 1070 | true |
| 1071 | {{end}} |
| 1072 | {{end}} |
| 1073 | |
| 1074 | |
| 1075 | {{/* |
| 1076 | ------------------------------------------------------------------------------ |
| 1077 | Emit "true" for supported functions that undergo table dispatch. Only global |
| 1078 | functions and functions handled in the loader top without calling into |
| 1079 | lower layers are not dispatched. |
| 1080 | ------------------------------------------------------------------------------ |
| 1081 | */}} |
| 1082 | {{define "IsInstanceDispatched"}} |
| 1083 | {{AssertType $ "Function"}} |
| 1084 | {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Instance")}} |
| 1085 | true |
| 1086 | {{end}} |
| 1087 | {{end}} |
| 1088 | |
| 1089 | |
| 1090 | {{/* |
| 1091 | ------------------------------------------------------------------------------ |
| 1092 | Emit "true" for supported functions that can have device-specific dispatch. |
| 1093 | ------------------------------------------------------------------------------ |
| 1094 | */}} |
| 1095 | {{define "IsDeviceDispatched"}} |
| 1096 | {{AssertType $ "Function"}} |
| 1097 | {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Device")}} |
| 1098 | true |
| 1099 | {{end}} |
| 1100 | {{end}} |
| 1101 | |
| 1102 | |
| 1103 | {{/* |
| 1104 | ------------------------------------------------------------------------------ |
| 1105 | Emit "true" if a function is core or from a supportable extension. |
| 1106 | ------------------------------------------------------------------------------ |
| 1107 | */}} |
| 1108 | {{define "IsFunctionSupported"}} |
| 1109 | {{AssertType $ "Function"}} |
| 1110 | {{if not (GetAnnotation $ "pfn")}} |
| 1111 | {{$ext := GetAnnotation $ "extension"}} |
| 1112 | {{if not $ext}}true |
| 1113 | {{else if not (Macro "IsExtensionBlacklisted" $ext)}}true |
| 1114 | {{end}} |
| 1115 | {{end}} |
| 1116 | {{end}} |
| 1117 | |
| 1118 | |
| 1119 | {{/* |
| 1120 | ------------------------------------------------------------------------------ |
| 1121 | Decides whether a function should be exported from the Android Vulkan |
| 1122 | library. Functions in the core API and in loader extensions are exported. |
| 1123 | ------------------------------------------------------------------------------ |
| 1124 | */}} |
| 1125 | {{define "IsFunctionExported"}} |
| 1126 | {{AssertType $ "Function"}} |
| 1127 | |
| 1128 | {{if (Macro "IsFunctionSupported" $)}} |
| 1129 | {{$ext := GetAnnotation $ "extension"}} |
| 1130 | {{if $ext}} |
| 1131 | {{Macro "IsExtensionExported" $ext}} |
| 1132 | {{else}} |
| 1133 | true |
| 1134 | {{end}} |
| 1135 | {{end}} |
| 1136 | {{end}} |
| 1137 | |
| 1138 | |
| 1139 | {{/* |
| 1140 | ------------------------------------------------------------------------------ |
| 1141 | Emit "true" if an extension is unsupportable on Android. |
| 1142 | ------------------------------------------------------------------------------ |
| 1143 | */}} |
| 1144 | {{define "IsExtensionBlacklisted"}} |
| 1145 | {{$ext := index $.Arguments 0}} |
| 1146 | {{ if eq $ext "VK_KHR_display"}}true |
| 1147 | {{else if eq $ext "VK_KHR_display_swapchain"}}true |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1148 | {{else if eq $ext "VK_KHR_mir_surface"}}true |
Jesse Hall | 77ad05b | 2017-03-10 22:02:20 -0800 | [diff] [blame] | 1149 | {{else if eq $ext "VK_KHR_xcb_surface"}}true |
| 1150 | {{else if eq $ext "VK_KHR_xlib_surface"}}true |
| 1151 | {{else if eq $ext "VK_KHR_wayland_surface"}}true |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1152 | {{else if eq $ext "VK_KHR_win32_surface"}}true |
Jesse Hall | 9492f99 | 2017-08-28 12:10:06 -0700 | [diff] [blame] | 1153 | {{else if eq $ext "VK_KHR_external_memory_win32"}}true |
| 1154 | {{else if eq $ext "VK_KHR_win32_keyed_mutex"}}true |
| 1155 | {{else if eq $ext "VK_KHR_external_semaphore_win32"}}true |
| 1156 | {{else if eq $ext "VK_KHR_external_fence_win32"}}true |
Jesse Hall | 77ad05b | 2017-03-10 22:02:20 -0800 | [diff] [blame] | 1157 | {{else if eq $ext "VK_EXT_acquire_xlib_display"}}true |
| 1158 | {{else if eq $ext "VK_EXT_direct_mode_display"}}true |
| 1159 | {{else if eq $ext "VK_EXT_display_surface_counter"}}true |
| 1160 | {{else if eq $ext "VK_EXT_display_control"}}true |
Jesse Hall | 497c46f | 2018-10-08 12:52:48 -0700 | [diff] [blame] | 1161 | {{else if eq $ext "VK_FUCHSIA_imagepipe_surface"}}true |
Jesse Hall | ad25084 | 2017-03-10 18:35:38 -0800 | [diff] [blame] | 1162 | {{else if eq $ext "VK_MVK_ios_surface"}}true |
| 1163 | {{else if eq $ext "VK_MVK_macos_surface"}}true |
Jesse Hall | 77ad05b | 2017-03-10 22:02:20 -0800 | [diff] [blame] | 1164 | {{else if eq $ext "VK_NN_vi_surface"}}true |
Jesse Hall | eb02c47 | 2017-02-24 15:13:45 -0800 | [diff] [blame] | 1165 | {{else if eq $ext "VK_NV_external_memory_win32"}}true |
| 1166 | {{else if eq $ext "VK_NV_win32_keyed_mutex"}}true |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1167 | {{end}} |
| 1168 | {{end}} |
| 1169 | |
| 1170 | |
| 1171 | {{/* |
| 1172 | ------------------------------------------------------------------------------ |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 1173 | Reports whether an extension has functions exported by the loader. |
| 1174 | E.g. applications can directly link to an extension function. |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1175 | ------------------------------------------------------------------------------ |
| 1176 | */}} |
| 1177 | {{define "IsExtensionExported"}} |
| 1178 | {{$ext := index $.Arguments 0}} |
| 1179 | {{ if eq $ext "VK_KHR_surface"}}true |
| 1180 | {{else if eq $ext "VK_KHR_swapchain"}}true |
| 1181 | {{else if eq $ext "VK_KHR_android_surface"}}true |
Jesse Hall | caea411 | 2018-01-18 15:40:46 -0800 | [diff] [blame] | 1182 | {{else if eq $ext "VK_ANDROID_external_memory_android_hardware_buffer"}}true |
Chia-I Wu | 0c20324 | 2016-03-15 13:44:51 +0800 | [diff] [blame] | 1183 | {{end}} |
| 1184 | {{end}} |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 1185 | |
| 1186 | |
| 1187 | {{/* |
| 1188 | ------------------------------------------------------------------------------ |
| 1189 | Reports whether an extension is internal to the loader and drivers, |
| 1190 | so the loader should not enumerate it. |
| 1191 | ------------------------------------------------------------------------------ |
| 1192 | */}} |
| 1193 | {{define "IsExtensionInternal"}} |
| 1194 | {{$ext := index $.Arguments 0}} |
| 1195 | {{ if eq $ext "VK_ANDROID_native_buffer"}}true |
| 1196 | {{end}} |
| 1197 | {{end}} |