blob: b27b36c2b3b6291ebffe47c6e285dd2804cc75d9 [file] [log] [blame]
Chia-I Wu0c203242016-03-15 13:44:51 +08001{{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 Wueb7db122016-03-24 09:11:06 +080024{{$ | 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 Wu0c203242016-03-15 13:44:51 +080026
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
Chia-I Wu8925efd2016-04-13 15:13:21 +080040#include <bitset>
Chia-I Wu0c203242016-03-15 13:44:51 +080041#include <vulkan/vulkan.h>
Chia-I Wu8925efd2016-04-13 15:13:21 +080042#include "driver_gen.h"
Chia-I Wu0c203242016-03-15 13:44:51 +080043
44namespace vulkan
45namespace api
46
47struct InstanceDispatchTable {
48 // clang-format off
49 {{range $f := AllCommands $}}
50 {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}}
Chia-I Wucc5e2762016-03-24 13:01:16 +080051 {{Macro "C++.DeclareTableEntry" $f}};
Chia-I Wu0c203242016-03-15 13:44:51 +080052 {{end}}
53 {{end}}
54 // clang-format on
55};
56
57struct DeviceDispatchTable {
58 // clang-format off
59 {{range $f := AllCommands $}}
60 {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}}
Chia-I Wucc5e2762016-03-24 13:01:16 +080061 {{Macro "C++.DeclareTableEntry" $f}};
Chia-I Wu0c203242016-03-15 13:44:51 +080062 {{end}}
63 {{end}}
64 // clang-format on
65};
66
Chia-I Wu8925efd2016-04-13 15:13:21 +080067bool InitDispatchTable(
68 VkInstance instance,
69 PFN_vkGetInstanceProcAddr get_proc,
70 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions);
71bool InitDispatchTable(
72 VkDevice dev,
73 PFN_vkGetDeviceProcAddr get_proc,
74 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions);
Chia-I Wu0c203242016-03-15 13:44:51 +080075
76»} // namespace api
77»} // namespace vulkan
78
79#endif // LIBVULKAN_API_GEN_H
80¶{{end}}
81
82
83{{/*
84-------------------------------------------------------------------------------
85 api_gen.cpp
86-------------------------------------------------------------------------------
87*/}}
88{{define "api_gen.cpp"}}
89{{Macro "Copyright"}}
90
91// WARNING: This file is generated. See ../README.md for instructions.
92
93#include <string.h>
94#include <algorithm>
Mark Salyzyna5e161b2016-09-29 08:08:05 -070095#include <android/log.h>
Chia-I Wu0c203242016-03-15 13:44:51 +080096
Chia-I Wu3e654dc2016-05-20 16:15:06 +080097// to catch mismatches between vulkan.h and this file
98#undef VK_NO_PROTOTYPES
Chia-I Wu0c203242016-03-15 13:44:51 +080099#include "api.h"
100
101namespace vulkan
102namespace api
103
Chia-I Wucc5e2762016-03-24 13:01:16 +0800104{{Macro "C++.DefineInitProcMacro" "dispatch"}}
105
106{{Macro "api.C++.DefineInitProcExtMacro"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800107
Chia-I Wu8925efd2016-04-13 15:13:21 +0800108namespace
109
110// clang-format off
111
112{{range $f := AllCommands $}}
113 {{Macro "api.C++.DefineExtensionStub" $f}}
114{{end}}
115// clang-format on
116
117»} // anonymous
118
119bool InitDispatchTable(
120 VkInstance instance,
121 PFN_vkGetInstanceProcAddr get_proc,
122 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800123 auto& data = GetData(instance);
124 bool success = true;
125
126 // clang-format off
127 {{range $f := AllCommands $}}
128 {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}}
129 {{Macro "C++.InitProc" $f}}
130 {{end}}
131 {{end}}
132 // clang-format on
133
134 return success;
135}
136
Chia-I Wu8925efd2016-04-13 15:13:21 +0800137bool InitDispatchTable(
138 VkDevice dev,
139 PFN_vkGetDeviceProcAddr get_proc,
140 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800141 auto& data = GetData(dev);
142 bool success = true;
143
144 // clang-format off
145 {{range $f := AllCommands $}}
146 {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}}
147 {{Macro "C++.InitProc" $f}}
148 {{end}}
149 {{end}}
150 // clang-format on
151
152 return success;
153}
154
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800155// clang-format off
156
157namespace
158
159// forward declarations needed by GetInstanceProcAddr and GetDeviceProcAddr
160{{range $f := AllCommands $}}
161 {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
162 VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}});
163 {{end}}
164{{end}}
165
166{{range $f := AllCommands $}}
167 {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
168 VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}}) {
169 {{ if eq $f.Name "vkGetInstanceProcAddr"}}
170 {{Macro "api.C++.InterceptInstanceProcAddr" $}}
171 {{else if eq $f.Name "vkGetDeviceProcAddr"}}
172 {{Macro "api.C++.InterceptDeviceProcAddr" $}}
173 {{end}}
174
175 {{Macro "api.C++.Dispatch" $f}}
176 }
177
178 {{end}}
179{{end}}
180
181»} // anonymous namespace
182
183// clang-format on
184
Chia-I Wu0c203242016-03-15 13:44:51 +0800185»} // namespace api
186»} // namespace vulkan
187
188// clang-format off
189
190{{range $f := AllCommands $}}
191 {{if (Macro "IsFunctionExported" $f)}}
192 __attribute__((visibility("default")))
193 VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) {
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800194 {{if not (IsVoid $f.Return.Type)}}return §{{end}}
195 vulkan::api::{{Macro "BaseName" $f}}({{Macro "Arguments" $f}});
Chia-I Wu0c203242016-03-15 13:44:51 +0800196 }
197
198 {{end}}
199{{end}}
200
201// clang-format on
202¶{{end}}
203
204
205{{/*
Chia-I Wueb7db122016-03-24 09:11:06 +0800206-------------------------------------------------------------------------------
207 driver_gen.h
208-------------------------------------------------------------------------------
209*/}}
210{{define "driver_gen.h"}}
211{{Macro "Copyright"}}
212
213// WARNING: This file is generated. See ../README.md for instructions.
214
215#ifndef LIBVULKAN_DRIVER_GEN_H
216#define LIBVULKAN_DRIVER_GEN_H
217
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800218#include <bitset>
Chia-I Wueb7db122016-03-24 09:11:06 +0800219#include <vulkan/vulkan.h>
220#include <vulkan/vk_android_native_buffer.h>
221
222namespace vulkan
223namespace driver
224
225{{Macro "driver.C++.DefineProcHookType"}}
226
Chia-I Wucc5e2762016-03-24 13:01:16 +0800227struct InstanceDriverTable {
228 // clang-format off
229 {{range $f := AllCommands $}}
230 {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}}
231 {{Macro "C++.DeclareTableEntry" $f}};
232 {{end}}
233 {{end}}
234 // clang-format on
235};
236
237struct DeviceDriverTable {
238 // clang-format off
239 {{range $f := AllCommands $}}
240 {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}}
241 {{Macro "C++.DeclareTableEntry" $f}};
242 {{end}}
243 {{end}}
244 // clang-format on
245};
246
Chia-I Wueb7db122016-03-24 09:11:06 +0800247const ProcHook* GetProcHook(const char* name);
248ProcHook::Extension GetProcHookExtension(const char* name);
249
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800250bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
251 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);
252bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
253 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);
Chia-I Wucc5e2762016-03-24 13:01:16 +0800254
Chia-I Wueb7db122016-03-24 09:11:06 +0800255»} // namespace driver
256»} // namespace vulkan
257
258#endif // LIBVULKAN_DRIVER_TABLE_H
259¶{{end}}
260
261
262{{/*
263-------------------------------------------------------------------------------
264 driver_gen.cpp
265-------------------------------------------------------------------------------
266*/}}
267{{define "driver_gen.cpp"}}
268{{Macro "Copyright"}}
269
270// WARNING: This file is generated. See ../README.md for instructions.
271
272#include <string.h>
273#include <algorithm>
Mark Salyzyna5e161b2016-09-29 08:08:05 -0700274#include <android/log.h>
Chia-I Wueb7db122016-03-24 09:11:06 +0800275
276#include "driver.h"
Chia-I Wueb7db122016-03-24 09:11:06 +0800277
278namespace vulkan
279namespace driver
280
281namespace
282
283// clang-format off
284
285{{range $f := AllCommands $}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800286 {{Macro "driver.C++.DefineProcHookStub" $f}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800287{{end}}
288// clang-format on
289
290const ProcHook g_proc_hooks[] = {
291 // clang-format off
292 {{range $f := SortBy (AllCommands $) "FunctionName"}}
293 {{if (Macro "driver.IsIntercepted" $f)}}
294 {{ if (Macro "IsGloballyDispatched" $f)}}
295 {{Macro "driver.C++.DefineGlobalProcHook" $f}}
296 {{else if (Macro "IsInstanceDispatched" $f)}}
297 {{Macro "driver.C++.DefineInstanceProcHook" $f}}
298 {{else if (Macro "IsDeviceDispatched" $f)}}
299 {{Macro "driver.C++.DefineDeviceProcHook" $f}}
300 {{end}}
301 {{end}}
302 {{end}}
303 // clang-format on
304};
305
306»} // anonymous
307
308const ProcHook* GetProcHook(const char* name) {
309 const auto& begin = g_proc_hooks;
310 const auto& end = g_proc_hooks +
311 sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]);
312 const auto hook = std::lower_bound(begin, end, name,
313 [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; });
314 return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr;
315}
316
317ProcHook::Extension GetProcHookExtension(const char* name) {
318 {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
319 // clang-format off
320 {{range $e := $exts}}
321 if (strcmp(name, "{{$e}}") == 0) return ProcHook::{{TrimPrefix "VK_" $e}};
322 {{end}}
323 // clang-format on
324 return ProcHook::EXTENSION_UNKNOWN;
325}
326
Chia-I Wucc5e2762016-03-24 13:01:16 +0800327{{Macro "C++.DefineInitProcMacro" "driver"}}
328
329{{Macro "driver.C++.DefineInitProcExtMacro"}}
330
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800331bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
332 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
Chia-I Wucc5e2762016-03-24 13:01:16 +0800333{
334 auto& data = GetData(instance);
335 bool success = true;
336
337 // clang-format off
338 {{range $f := AllCommands $}}
339 {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}}
340 {{Macro "C++.InitProc" $f}}
341 {{end}}
342 {{end}}
343 // clang-format on
344
345 return success;
346}
347
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800348bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
349 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
Chia-I Wucc5e2762016-03-24 13:01:16 +0800350{
351 auto& data = GetData(dev);
352 bool success = true;
353
354 // clang-format off
355 {{range $f := AllCommands $}}
356 {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}}
357 {{Macro "C++.InitProc" $f}}
358 {{end}}
359 {{end}}
360 // clang-format on
361
362 return success;
363}
364
Chia-I Wueb7db122016-03-24 09:11:06 +0800365»} // namespace driver
366»} // namespace vulkan
367
368// clang-format on
369¶{{end}}
370
371
372{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800373------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800374 Emits a declaration of a dispatch/driver table entry.
Chia-I Wu0c203242016-03-15 13:44:51 +0800375------------------------------------------------------------------------------
376*/}}
Chia-I Wucc5e2762016-03-24 13:01:16 +0800377{{define "C++.DeclareTableEntry"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800378 {{AssertType $ "Function"}}
379
380 {{Macro "FunctionPtrName" $}} {{Macro "BaseName" $}}
381{{end}}
382
383
384{{/*
385-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800386 Emits INIT_PROC macro.
Chia-I Wu0c203242016-03-15 13:44:51 +0800387-------------------------------------------------------------------------------
388*/}}
Chia-I Wucc5e2762016-03-24 13:01:16 +0800389{{define "C++.DefineInitProcMacro"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800390 #define UNLIKELY(expr) __builtin_expect((expr), 0)
391
Chris Forbes5948b3e2016-12-23 13:49:53 +1300392 #define INIT_PROC(required, obj, proc) do { \
Chia-I Wu0c203242016-03-15 13:44:51 +0800393 data.{{$}}.proc = reinterpret_cast<PFN_vk ## proc>( \
394 get_proc(obj, "vk" # proc)); \
Chris Forbes5948b3e2016-12-23 13:49:53 +1300395 if (UNLIKELY(required && !data.{{$}}.proc)) { \
Chia-I Wu0c203242016-03-15 13:44:51 +0800396 ALOGE("missing " # obj " proc: vk" # proc); \
397 success = false; \
398 } \
399 } while(0)
Chia-I Wu0c203242016-03-15 13:44:51 +0800400{{end}}
401
402
403{{/*
404-------------------------------------------------------------------------------
405 Emits code to invoke INIT_PROC or INIT_PROC_EXT.
406-------------------------------------------------------------------------------
407*/}}
408{{define "C++.InitProc"}}
409 {{AssertType $ "Function"}}
410
411 {{$ext := GetAnnotation $ "extension"}}
Chris Forbes5948b3e2016-12-23 13:49:53 +1300412 {{$required := (Macro "IsRequiredFunction" $)}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800413 {{if $ext}}
Chris Forbes5948b3e2016-12-23 13:49:53 +1300414 INIT_PROC_EXT({{Macro "BaseName" $ext}}, {{$required}}, §
Chia-I Wu0c203242016-03-15 13:44:51 +0800415 {{else}}
Chris Forbes5948b3e2016-12-23 13:49:53 +1300416 INIT_PROC({{$required}}, §
Chia-I Wu0c203242016-03-15 13:44:51 +0800417 {{end}}
418
419 {{if (Macro "IsInstanceDispatched" $)}}
420 instance, §
421 {{else}}
422 dev, §
423 {{end}}
424
425 {{Macro "BaseName" $}});
426{{end}}
427
428
429{{/*
430------------------------------------------------------------------------------
Chris Forbes5948b3e2016-12-23 13:49:53 +1300431 Emits true if a function /must/ be resolved. The only time this is not
432 the case is for extension-added functions added in a later revision of the
433 extension, and where we have to cope with drivers written against an older
434 revision.
435------------------------------------------------------------------------------
436*/}}
437{{define "IsRequiredFunction"}}
438 {{AssertType $ "Function"}}
439
440 {{if eq $.Name "vkGetSwapchainGrallocUsage2ANDROID"}}
441 false
442 {{else}}
443 true
444 {{end}}
445{{end}}
446
447
448{{/*
449------------------------------------------------------------------------------
Chia-I Wu0c203242016-03-15 13:44:51 +0800450 Emits true if a function is exported and instance-dispatched.
451------------------------------------------------------------------------------
452*/}}
453{{define "api.IsInstanceDispatchTableEntry"}}
454 {{AssertType $ "Function"}}
455
456 {{if and (Macro "IsFunctionExported" $) (Macro "IsInstanceDispatched" $)}}
Chia-I Wudbd33bc2016-06-02 11:25:47 +0800457 {{/* deprecated and unused internally */}}
458 {{if not (eq $.Name "vkEnumerateDeviceLayerProperties")}}
459 true
460 {{end}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800461 {{end}}
462{{end}}
463
464
465{{/*
466------------------------------------------------------------------------------
467 Emits true if a function is exported and device-dispatched.
468------------------------------------------------------------------------------
469*/}}
470{{define "api.IsDeviceDispatchTableEntry"}}
471 {{AssertType $ "Function"}}
472
473 {{if and (Macro "IsFunctionExported" $) (Macro "IsDeviceDispatched" $)}}
474 true
475 {{end}}
476{{end}}
477
478
479{{/*
480------------------------------------------------------------------------------
481 Emits true if a function is intercepted by vulkan::api.
482------------------------------------------------------------------------------
483*/}}
484{{define "api.IsIntercepted"}}
485 {{AssertType $ "Function"}}
486
487 {{if (Macro "IsFunctionSupported" $)}}
488 {{/* Global functions cannot be dispatched at all */}}
489 {{ if (Macro "IsGloballyDispatched" $)}}true
490
491 {{/* VkPhysicalDevice functions that manage device layers */}}
492 {{else if eq $.Name "vkCreateDevice"}}true
493 {{else if eq $.Name "vkEnumerateDeviceLayerProperties"}}true
494 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
495
496 {{/* Destroy functions of dispatchable objects */}}
497 {{else if eq $.Name "vkDestroyInstance"}}true
498 {{else if eq $.Name "vkDestroyDevice"}}true
499
500 {{end}}
501 {{end}}
502{{end}}
503
504
505{{/*
Chia-I Wucc5e2762016-03-24 13:01:16 +0800506-------------------------------------------------------------------------------
507 Emits INIT_PROC_EXT macro for vulkan::api.
508-------------------------------------------------------------------------------
509*/}}
510{{define "api.C++.DefineInitProcExtMacro"}}
Chia-I Wu8925efd2016-04-13 15:13:21 +0800511 // Exported extension functions may be invoked even when their extensions
512 // are disabled. Dispatch to stubs when that happens.
Chris Forbes5948b3e2016-12-23 13:49:53 +1300513 #define INIT_PROC_EXT(ext, required, obj, proc) do { \
Chia-I Wu8925efd2016-04-13 15:13:21 +0800514 if (extensions[driver::ProcHook::ext]) \
Chris Forbes5948b3e2016-12-23 13:49:53 +1300515 INIT_PROC(required, obj, proc); \
Chia-I Wu8925efd2016-04-13 15:13:21 +0800516 else \
517 data.dispatch.proc = disabled ## proc; \
Chia-I Wucc5e2762016-03-24 13:01:16 +0800518 } while(0)
519{{end}}
520
521
522{{/*
Chia-I Wu8925efd2016-04-13 15:13:21 +0800523-------------------------------------------------------------------------------
524 Emits a stub for an exported extension function.
525-------------------------------------------------------------------------------
526*/}}
527{{define "api.C++.DefineExtensionStub"}}
528 {{AssertType $ "Function"}}
529
530 {{$ext := GetAnnotation $ "extension"}}
531 {{if and $ext (Macro "IsFunctionExported" $)}}
532 {{$ext_name := index $ext.Arguments 0}}
533
534 {{$base := (Macro "BaseName" $)}}
Chia-I Wu8925efd2016-04-13 15:13:21 +0800535
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800536 {{$p0 := (index $.CallParameters 0)}}
537 {{$ptail := (Tail 1 $.CallParameters)}}
538
539 {{$first_type := (Macro "Parameter" $p0)}}
540 {{$tail_types := (ForEach $ptail "ParameterType" | JoinWith ", ")}}
541
542 VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$first_type}}, {{$tail_types}}) {
543 driver::Logger({{$p0.Name}}).Err({{$p0.Name}}, §
544 "{{$ext_name}} not enabled. Exported {{$.Name}} not executed.");
Chia-I Wu8925efd2016-04-13 15:13:21 +0800545 {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
546 }
547
548 {{end}}
549{{end}}
550
551
552{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800553------------------------------------------------------------------------------
554 Emits code for vkGetInstanceProcAddr for function interception.
555------------------------------------------------------------------------------
556*/}}
557{{define "api.C++.InterceptInstanceProcAddr"}}
558 {{AssertType $ "API"}}
559
560 // global functions
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800561 if (instance == VK_NULL_HANDLE) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800562 {{range $f := AllCommands $}}
563 {{if (Macro "IsGloballyDispatched" $f)}}
564 if (strcmp(pName, "{{$f.Name}}") == 0) return §
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800565 reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}});
Chia-I Wu0c203242016-03-15 13:44:51 +0800566 {{end}}
567 {{end}}
568
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800569 ALOGE("invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, \"%s\") call", pName);
Chia-I Wu0c203242016-03-15 13:44:51 +0800570 return nullptr;
571 }
572
573 static const struct Hook {
574 const char* name;
575 PFN_vkVoidFunction proc;
576 } hooks[] = {
577 {{range $f := SortBy (AllCommands $) "FunctionName"}}
578 {{if (Macro "IsFunctionExported" $f)}}
579 {{/* hide global functions */}}
580 {{if (Macro "IsGloballyDispatched" $f)}}
581 { "{{$f.Name}}", nullptr },
582
583 {{/* redirect intercepted functions */}}
584 {{else if (Macro "api.IsIntercepted" $f)}}
585 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800586 {{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800587
588 {{/* redirect vkGetInstanceProcAddr to itself */}}
589 {{else if eq $f.Name "vkGetInstanceProcAddr"}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800590 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800591
592 {{/* redirect device functions to themselves as a workaround for
593 layers that do not intercept in their vkGetInstanceProcAddr */}}
594 {{else if (Macro "IsDeviceDispatched" $f)}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800595 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800596
597 {{end}}
598 {{end}}
599 {{end}}
600 };
601 // clang-format on
602 constexpr size_t count = sizeof(hooks) / sizeof(hooks[0]);
603 auto hook = std::lower_bound(
604 hooks, hooks + count, pName,
605 [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
606 if (hook < hooks + count && strcmp(hook->name, pName) == 0) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800607 if (!hook->proc) {
608 vulkan::driver::Logger(instance).Err(
609 instance, "invalid vkGetInstanceProcAddr(%p, \"%s\") call",
610 instance, pName);
611 }
Chia-I Wu0c203242016-03-15 13:44:51 +0800612 return hook->proc;
613 }
614 // clang-format off
615
616{{end}}
617
618
619{{/*
620------------------------------------------------------------------------------
621 Emits code for vkGetDeviceProcAddr for function interception.
622------------------------------------------------------------------------------
623*/}}
624{{define "api.C++.InterceptDeviceProcAddr"}}
625 {{AssertType $ "API"}}
626
627 if (device == VK_NULL_HANDLE) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800628 ALOGE("invalid vkGetDeviceProcAddr(VK_NULL_HANDLE, ...) call");
Chia-I Wu0c203242016-03-15 13:44:51 +0800629 return nullptr;
630 }
631
632 static const char* const known_non_device_names[] = {
633 {{range $f := SortBy (AllCommands $) "FunctionName"}}
634 {{if (Macro "IsFunctionSupported" $f)}}
635 {{if not (Macro "IsDeviceDispatched" $f)}}
636 "{{$f.Name}}",
637 {{end}}
638 {{end}}
639 {{end}}
640 };
641 // clang-format on
642 constexpr size_t count = sizeof(known_non_device_names) /
643 sizeof(known_non_device_names[0]);
644 if (!pName ||
645 std::binary_search(
646 known_non_device_names, known_non_device_names + count, pName,
647 [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800648 vulkan::driver::Logger(device).Err
649 device, "invalid vkGetDeviceProcAddr(%p, \"%s\") call", device
650 (pName) ? pName : "(null)");
Chia-I Wu0c203242016-03-15 13:44:51 +0800651 return nullptr;
652 }
653 // clang-format off
654
Chia-I Wuc56603e2016-04-12 11:16:17 +0800655 {{range $f := AllCommands $}}
656 {{if (Macro "IsDeviceDispatched" $f)}}
657 {{ if (Macro "api.IsIntercepted" $f)}}
658 if (strcmp(pName, "{{$f.Name}}") == 0) return §
659 reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800660 {{Macro "BaseName" $f}});
Chia-I Wuc56603e2016-04-12 11:16:17 +0800661 {{else if eq $f.Name "vkGetDeviceProcAddr"}}
662 if (strcmp(pName, "{{$f.Name}}") == 0) return §
663 reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800664 {{Macro "BaseName" $f}});
Chia-I Wuc56603e2016-04-12 11:16:17 +0800665 {{end}}
666 {{end}}
667 {{end}}
668
Chia-I Wu0c203242016-03-15 13:44:51 +0800669{{end}}
670
671
672{{/*
673------------------------------------------------------------------------------
674 Emits code to dispatch a function.
675------------------------------------------------------------------------------
676*/}}
677{{define "api.C++.Dispatch"}}
678 {{AssertType $ "Function"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800679 {{if (Macro "api.IsIntercepted" $)}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800680 {{Error "$.Name should not be generated"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800681 {{end}}
682
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800683 {{if not (IsVoid $.Return.Type)}}return §{{end}}
684
685 {{$p0 := index $.CallParameters 0}}
686 GetData({{$p0.Name}}).dispatch
Chia-I Wu0c203242016-03-15 13:44:51 +0800687 {{Macro "BaseName" $}}({{Macro "Arguments" $}});
688{{end}}
689
690
691{{/*
Chia-I Wueb7db122016-03-24 09:11:06 +0800692------------------------------------------------------------------------------
693 Emits a list of extensions intercepted by vulkan::driver.
694------------------------------------------------------------------------------
695*/}}
696{{define "driver.InterceptedExtensions"}}
697VK_ANDROID_native_buffer
698VK_EXT_debug_report
699VK_KHR_android_surface
Ian Elliott948233a2017-01-06 12:13:23 -0700700VK_KHR_incremental_present
Chia-I Wueb7db122016-03-24 09:11:06 +0800701VK_KHR_surface
702VK_KHR_swapchain
703{{end}}
704
705
706{{/*
707------------------------------------------------------------------------------
708 Emits true if an extension is intercepted by vulkan::driver.
709------------------------------------------------------------------------------
710*/}}
711{{define "driver.IsExtensionIntercepted"}}
712 {{$ext_name := index $.Arguments 0}}
713 {{$filters := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
714
715 {{range $f := $filters}}
716 {{if eq $ext_name $f}}true{{end}}
717 {{end}}
718{{end}}
719
720
721{{/*
722------------------------------------------------------------------------------
723 Emits true if a function is intercepted by vulkan::driver.
724------------------------------------------------------------------------------
725*/}}
726{{define "driver.IsIntercepted"}}
727 {{AssertType $ "Function"}}
728
729 {{if (Macro "IsFunctionSupported" $)}}
730 {{/* Create functions of dispatchable objects */}}
731 {{ if eq $.Name "vkCreateInstance"}}true
732 {{else if eq $.Name "vkCreateDevice"}}true
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800733 {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true
Chia-I Wueb7db122016-03-24 09:11:06 +0800734 {{else if eq $.Name "vkGetDeviceQueue"}}true
735 {{else if eq $.Name "vkAllocateCommandBuffers"}}true
736
737 {{/* Destroy functions of dispatchable objects */}}
738 {{else if eq $.Name "vkDestroyInstance"}}true
739 {{else if eq $.Name "vkDestroyDevice"}}true
740
741 {{/* Enumeration of extensions */}}
742 {{else if eq $.Name "vkEnumerateInstanceExtensionProperties"}}true
743 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
744
Chia-I Wueb7db122016-03-24 09:11:06 +0800745 {{else if eq $.Name "vkGetInstanceProcAddr"}}true
746 {{else if eq $.Name "vkGetDeviceProcAddr"}}true
747
748 {{end}}
749
750 {{$ext := GetAnnotation $ "extension"}}
751 {{if $ext}}
752 {{Macro "driver.IsExtensionIntercepted" $ext}}
753 {{end}}
754
755 {{end}}
756{{end}}
757
758
759{{/*
760------------------------------------------------------------------------------
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800761 Emits true if a function needs a ProcHook stub.
Chia-I Wueb7db122016-03-24 09:11:06 +0800762------------------------------------------------------------------------------
763*/}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800764{{define "driver.NeedProcHookStub"}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800765 {{AssertType $ "Function"}}
766
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800767 {{if and (Macro "driver.IsIntercepted" $) (Macro "IsDeviceDispatched" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800768 {{$ext := GetAnnotation $ "extension"}}
769 {{if $ext}}
770 {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}}
771 {{end}}
772 {{end}}
773{{end}}
774
775
776{{/*
777-------------------------------------------------------------------------------
778 Emits definition of struct ProcHook.
779-------------------------------------------------------------------------------
780*/}}
781{{define "driver.C++.DefineProcHookType"}}
782 struct ProcHook {
783 enum Type {
784 GLOBAL,
785 INSTANCE,
786 DEVICE,
787 };
788
789 enum Extension {
790 {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
791 {{range $e := $exts}}
792 {{TrimPrefix "VK_" $e}},
793 {{end}}
794
795 EXTENSION_CORE, // valid bit
796 EXTENSION_COUNT,
797 EXTENSION_UNKNOWN,
798 };
799
800 const char* name;
801 Type type;
802 Extension extension;
803
804 PFN_vkVoidFunction proc;
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800805 PFN_vkVoidFunction checked_proc; // always nullptr for non-device hooks
Chia-I Wueb7db122016-03-24 09:11:06 +0800806 };
807{{end}}
808
809
810{{/*
811-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800812 Emits INIT_PROC_EXT macro for vulkan::driver.
813-------------------------------------------------------------------------------
814*/}}
815{{define "driver.C++.DefineInitProcExtMacro"}}
Chris Forbes5948b3e2016-12-23 13:49:53 +1300816 #define INIT_PROC_EXT(ext, required, obj, proc) do { \
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800817 if (extensions[ProcHook::ext]) \
Chris Forbes5948b3e2016-12-23 13:49:53 +1300818 INIT_PROC(required, obj, proc); \
Chia-I Wucc5e2762016-03-24 13:01:16 +0800819 } while(0)
820{{end}}
821
822
823{{/*
824-------------------------------------------------------------------------------
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800825 Emits a stub for ProcHook::checked_proc.
Chia-I Wueb7db122016-03-24 09:11:06 +0800826-------------------------------------------------------------------------------
827*/}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800828{{define "driver.C++.DefineProcHookStub"}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800829 {{AssertType $ "Function"}}
830
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800831 {{if (Macro "driver.NeedProcHookStub" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800832 {{$ext := GetAnnotation $ "extension"}}
833 {{$ext_name := index $ext.Arguments 0}}
834
835 {{$base := (Macro "BaseName" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800836
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800837 VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
838 {{$p0 := index $.CallParameters 0}}
839 {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800840
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800841 if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) {
842 {{if not (IsVoid $.Return.Type)}}return §{{end}}
843 {{$base}}({{Macro "Arguments" $}});
844 } else {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800845 Logger({{$p0.Name}}).Err({{$p0.Name}}, "{{$ext_name}} not enabled. {{$.Name}} not executed.");
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800846 {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800847 }
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800848 }
Chia-I Wueb7db122016-03-24 09:11:06 +0800849
850 {{end}}
851{{end}}
852
853
854{{/*
855-------------------------------------------------------------------------------
856 Emits definition of a global ProcHook.
857-------------------------------------------------------------------------------
858*/}}
859{{define "driver.C++.DefineGlobalProcHook"}}
860 {{AssertType $ "Function"}}
861
862 {{$base := (Macro "BaseName" $)}}
863
864 {{$ext := GetAnnotation $ "extension"}}
865 {{if $ext}}
866 {{Error "invalid global extension"}}
867 {{end}}
868
869 {
870 "{{$.Name}}",
871 ProcHook::GLOBAL,
872 ProcHook::EXTENSION_CORE,
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800873 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800874 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800875 },
876{{end}}
877
878
879{{/*
880-------------------------------------------------------------------------------
881 Emits definition of an instance ProcHook.
882-------------------------------------------------------------------------------
883*/}}
884{{define "driver.C++.DefineInstanceProcHook"}}
885 {{AssertType $ "Function"}}
886
887 {{$base := (Macro "BaseName" $)}}
888
889 {
890 "{{$.Name}}",
891 ProcHook::INSTANCE,
892
893 {{$ext := GetAnnotation $ "extension"}}
894 {{if $ext}}
895 ProcHook::{{Macro "BaseName" $ext}},
896
897 {{if (Macro "IsExtensionInternal" $ext)}}
898 nullptr,
899 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800900 {{else}}
Chia-I Wu62262232016-03-26 07:06:44 +0800901 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800902 nullptr,
903 {{end}}
904 {{else}}
905 ProcHook::EXTENSION_CORE,
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800906 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800907 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800908 {{end}}
909 },
910{{end}}
911
912
913{{/*
914-------------------------------------------------------------------------------
915 Emits definition of a device ProcHook.
916-------------------------------------------------------------------------------
917*/}}
918{{define "driver.C++.DefineDeviceProcHook"}}
919 {{AssertType $ "Function"}}
920
921 {{$base := (Macro "BaseName" $)}}
922
923 {
924 "{{$.Name}}",
925 ProcHook::DEVICE,
926
927 {{$ext := GetAnnotation $ "extension"}}
928 {{if $ext}}
929 ProcHook::{{Macro "BaseName" $ext}},
930
931 {{if (Macro "IsExtensionInternal" $ext)}}
932 nullptr,
933 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800934 {{else}}
Chia-I Wu62262232016-03-26 07:06:44 +0800935 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800936 reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
937 {{end}}
938 {{else}}
Chia-I Wu4901db72016-03-24 16:38:58 +0800939 ProcHook::EXTENSION_CORE,
940 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
941 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800942 {{end}}
943 },
944{{end}}
945
946
947{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800948-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800949 Emits true if a function is needed by vulkan::driver.
950-------------------------------------------------------------------------------
951*/}}
952{{define "driver.IsDriverTableEntry"}}
953 {{AssertType $ "Function"}}
954
955 {{if (Macro "IsFunctionSupported" $)}}
956 {{/* Create functions of dispatchable objects */}}
957 {{ if eq $.Name "vkCreateDevice"}}true
958 {{else if eq $.Name "vkGetDeviceQueue"}}true
959 {{else if eq $.Name "vkAllocateCommandBuffers"}}true
960
961 {{/* Destroy functions of dispatchable objects */}}
962 {{else if eq $.Name "vkDestroyInstance"}}true
963 {{else if eq $.Name "vkDestroyDevice"}}true
964
965 {{/* Enumeration of extensions */}}
966 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
967
968 {{/* We cache physical devices in loader.cpp */}}
969 {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true
970
971 {{else if eq $.Name "vkGetInstanceProcAddr"}}true
972 {{else if eq $.Name "vkGetDeviceProcAddr"}}true
973
974 {{/* VK_KHR_swapchain->VK_ANDROID_native_buffer translation */}}
975 {{else if eq $.Name "vkCreateImage"}}true
976 {{else if eq $.Name "vkDestroyImage"}}true
977
978 {{end}}
979
980 {{$ext := GetAnnotation $ "extension"}}
981 {{if $ext}}
982 {{$ext_name := index $ext.Arguments 0}}
983 {{ if eq $ext_name "VK_ANDROID_native_buffer"}}true
984 {{else if eq $ext_name "VK_EXT_debug_report"}}true
985 {{end}}
986 {{end}}
987 {{end}}
988{{end}}
989
990
991{{/*
992------------------------------------------------------------------------------
993 Emits true if an instance-dispatched function is needed by vulkan::driver.
994------------------------------------------------------------------------------
995*/}}
996{{define "driver.IsInstanceDriverTableEntry"}}
997 {{AssertType $ "Function"}}
998
999 {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsInstanceDispatched" $)}}
1000 true
1001 {{end}}
1002{{end}}
1003
1004
1005{{/*
1006------------------------------------------------------------------------------
1007 Emits true if a device-dispatched function is needed by vulkan::driver.
1008------------------------------------------------------------------------------
1009*/}}
1010{{define "driver.IsDeviceDriverTableEntry"}}
1011 {{AssertType $ "Function"}}
1012
1013 {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsDeviceDispatched" $)}}
1014 true
1015 {{end}}
1016{{end}}
1017
1018
1019{{/*
1020-------------------------------------------------------------------------------
Chia-I Wu0c203242016-03-15 13:44:51 +08001021 Emits a function/extension name without the "vk"/"VK_" prefix.
1022-------------------------------------------------------------------------------
1023*/}}
1024{{define "BaseName"}}
1025 {{ if IsFunction $}}{{TrimPrefix "vk" $.Name}}
1026 {{else if eq $.Name "extension"}}{{TrimPrefix "VK_" (index $.Arguments 0)}}
1027 {{else}}{{Error "invalid use of BaseName"}}
1028 {{end}}
1029{{end}}
1030
1031
1032{{/*
1033-------------------------------------------------------------------------------
1034 Emits a comma-separated list of C parameter names for the given command.
1035-------------------------------------------------------------------------------
1036*/}}
1037{{define "Arguments"}}
1038 {{AssertType $ "Function"}}
1039
1040 {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}}
1041{{end}}
1042
1043
1044{{/*
1045------------------------------------------------------------------------------
1046------------------------------------------------------------------------------
1047*/}}
1048{{define "IsGloballyDispatched"}}
1049 {{AssertType $ "Function"}}
1050 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Global")}}
1051 true
1052 {{end}}
1053{{end}}
1054
1055
1056{{/*
1057------------------------------------------------------------------------------
1058 Emit "true" for supported functions that undergo table dispatch. Only global
1059 functions and functions handled in the loader top without calling into
1060 lower layers are not dispatched.
1061------------------------------------------------------------------------------
1062*/}}
1063{{define "IsInstanceDispatched"}}
1064 {{AssertType $ "Function"}}
1065 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Instance")}}
1066 true
1067 {{end}}
1068{{end}}
1069
1070
1071{{/*
1072------------------------------------------------------------------------------
1073 Emit "true" for supported functions that can have device-specific dispatch.
1074------------------------------------------------------------------------------
1075*/}}
1076{{define "IsDeviceDispatched"}}
1077 {{AssertType $ "Function"}}
1078 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Device")}}
1079 true
1080 {{end}}
1081{{end}}
1082
1083
1084{{/*
1085------------------------------------------------------------------------------
1086 Emit "true" if a function is core or from a supportable extension.
1087------------------------------------------------------------------------------
1088*/}}
1089{{define "IsFunctionSupported"}}
1090 {{AssertType $ "Function"}}
1091 {{if not (GetAnnotation $ "pfn")}}
1092 {{$ext := GetAnnotation $ "extension"}}
1093 {{if not $ext}}true
1094 {{else if not (Macro "IsExtensionBlacklisted" $ext)}}true
1095 {{end}}
1096 {{end}}
1097{{end}}
1098
1099
1100{{/*
1101------------------------------------------------------------------------------
1102 Decides whether a function should be exported from the Android Vulkan
1103 library. Functions in the core API and in loader extensions are exported.
1104------------------------------------------------------------------------------
1105*/}}
1106{{define "IsFunctionExported"}}
1107 {{AssertType $ "Function"}}
1108
1109 {{if (Macro "IsFunctionSupported" $)}}
1110 {{$ext := GetAnnotation $ "extension"}}
1111 {{if $ext}}
1112 {{Macro "IsExtensionExported" $ext}}
1113 {{else}}
1114 true
1115 {{end}}
1116 {{end}}
1117{{end}}
1118
1119
1120{{/*
1121------------------------------------------------------------------------------
1122 Emit "true" if an extension is unsupportable on Android.
1123------------------------------------------------------------------------------
1124*/}}
1125{{define "IsExtensionBlacklisted"}}
1126 {{$ext := index $.Arguments 0}}
1127 {{ if eq $ext "VK_KHR_display"}}true
1128 {{else if eq $ext "VK_KHR_display_swapchain"}}true
1129 {{else if eq $ext "VK_KHR_xlib_surface"}}true
1130 {{else if eq $ext "VK_KHR_xcb_surface"}}true
1131 {{else if eq $ext "VK_KHR_wayland_surface"}}true
1132 {{else if eq $ext "VK_KHR_mir_surface"}}true
1133 {{else if eq $ext "VK_KHR_win32_surface"}}true
1134 {{end}}
1135{{end}}
1136
1137
1138{{/*
1139------------------------------------------------------------------------------
1140 Reports whether an extension is implemented entirely by the loader,
1141 so drivers should not enumerate it.
1142------------------------------------------------------------------------------
1143*/}}
1144{{define "IsExtensionExported"}}
1145 {{$ext := index $.Arguments 0}}
1146 {{ if eq $ext "VK_KHR_surface"}}true
1147 {{else if eq $ext "VK_KHR_swapchain"}}true
1148 {{else if eq $ext "VK_KHR_android_surface"}}true
Ian Elliott948233a2017-01-06 12:13:23 -07001149 {{else if eq $ext "VK_KHR_incremental_present"}}true
Chia-I Wu0c203242016-03-15 13:44:51 +08001150 {{end}}
1151{{end}}
Chia-I Wueb7db122016-03-24 09:11:06 +08001152
1153
1154{{/*
1155------------------------------------------------------------------------------
1156 Reports whether an extension is internal to the loader and drivers,
1157 so the loader should not enumerate it.
1158------------------------------------------------------------------------------
1159*/}}
1160{{define "IsExtensionInternal"}}
1161 {{$ext := index $.Arguments 0}}
1162 {{ if eq $ext "VK_ANDROID_native_buffer"}}true
1163 {{end}}
1164{{end}}