blob: 87ad848687e45e695051ed60decbe61757e2ab9b [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>
Mark Salyzyn7823e122016-09-29 08:08:05 -070094
Chia-I Wu0c203242016-03-15 13:44:51 +080095#include <algorithm>
Mark Salyzyn7823e122016-09-29 08:08:05 -070096
97#include <log/log.h>
Chia-I Wu0c203242016-03-15 13:44:51 +080098
Chia-I Wu3e654dc2016-05-20 16:15:06 +080099// to catch mismatches between vulkan.h and this file
100#undef VK_NO_PROTOTYPES
Chia-I Wu0c203242016-03-15 13:44:51 +0800101#include "api.h"
102
103namespace vulkan
104namespace api
105
Chia-I Wucc5e2762016-03-24 13:01:16 +0800106{{Macro "C++.DefineInitProcMacro" "dispatch"}}
107
108{{Macro "api.C++.DefineInitProcExtMacro"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800109
Chia-I Wu8925efd2016-04-13 15:13:21 +0800110namespace
111
112// clang-format off
113
114{{range $f := AllCommands $}}
115 {{Macro "api.C++.DefineExtensionStub" $f}}
116{{end}}
117// clang-format on
118
119»} // anonymous
120
121bool InitDispatchTable(
122 VkInstance instance,
123 PFN_vkGetInstanceProcAddr get_proc,
124 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800125 auto& data = GetData(instance);
126 bool success = true;
127
128 // clang-format off
129 {{range $f := AllCommands $}}
130 {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}}
131 {{Macro "C++.InitProc" $f}}
132 {{end}}
133 {{end}}
134 // clang-format on
135
136 return success;
137}
138
Chia-I Wu8925efd2016-04-13 15:13:21 +0800139bool InitDispatchTable(
140 VkDevice dev,
141 PFN_vkGetDeviceProcAddr get_proc,
142 const std::bitset<driver::ProcHook::EXTENSION_COUNT> &extensions) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800143 auto& data = GetData(dev);
144 bool success = true;
145
146 // clang-format off
147 {{range $f := AllCommands $}}
148 {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}}
149 {{Macro "C++.InitProc" $f}}
150 {{end}}
151 {{end}}
152 // clang-format on
153
154 return success;
155}
156
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800157// clang-format off
158
159namespace
160
161// forward declarations needed by GetInstanceProcAddr and GetDeviceProcAddr
162{{range $f := AllCommands $}}
163 {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
164 VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}});
165 {{end}}
166{{end}}
167
168{{range $f := AllCommands $}}
169 {{if and (Macro "IsFunctionExported" $f) (not (Macro "api.IsIntercepted" $f))}}
170 VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}}) {
171 {{ if eq $f.Name "vkGetInstanceProcAddr"}}
172 {{Macro "api.C++.InterceptInstanceProcAddr" $}}
173 {{else if eq $f.Name "vkGetDeviceProcAddr"}}
174 {{Macro "api.C++.InterceptDeviceProcAddr" $}}
175 {{end}}
176
177 {{Macro "api.C++.Dispatch" $f}}
178 }
179
180 {{end}}
181{{end}}
182
183»} // anonymous namespace
184
185// clang-format on
186
Chia-I Wu0c203242016-03-15 13:44:51 +0800187»} // namespace api
188»} // namespace vulkan
189
190// clang-format off
191
192{{range $f := AllCommands $}}
193 {{if (Macro "IsFunctionExported" $f)}}
194 __attribute__((visibility("default")))
195 VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) {
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800196 {{if not (IsVoid $f.Return.Type)}}return §{{end}}
197 vulkan::api::{{Macro "BaseName" $f}}({{Macro "Arguments" $f}});
Chia-I Wu0c203242016-03-15 13:44:51 +0800198 }
199
200 {{end}}
201{{end}}
202
203// clang-format on
204¶{{end}}
205
206
207{{/*
Chia-I Wueb7db122016-03-24 09:11:06 +0800208-------------------------------------------------------------------------------
209 driver_gen.h
210-------------------------------------------------------------------------------
211*/}}
212{{define "driver_gen.h"}}
213{{Macro "Copyright"}}
214
215// WARNING: This file is generated. See ../README.md for instructions.
216
217#ifndef LIBVULKAN_DRIVER_GEN_H
218#define LIBVULKAN_DRIVER_GEN_H
219
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800220#include <bitset>
Chia-I Wueb7db122016-03-24 09:11:06 +0800221#include <vulkan/vulkan.h>
222#include <vulkan/vk_android_native_buffer.h>
223
224namespace vulkan
225namespace driver
226
227{{Macro "driver.C++.DefineProcHookType"}}
228
Chia-I Wucc5e2762016-03-24 13:01:16 +0800229struct InstanceDriverTable {
230 // clang-format off
231 {{range $f := AllCommands $}}
232 {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}}
233 {{Macro "C++.DeclareTableEntry" $f}};
234 {{end}}
235 {{end}}
236 // clang-format on
237};
238
239struct DeviceDriverTable {
240 // clang-format off
241 {{range $f := AllCommands $}}
242 {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}}
243 {{Macro "C++.DeclareTableEntry" $f}};
244 {{end}}
245 {{end}}
246 // clang-format on
247};
248
Chia-I Wueb7db122016-03-24 09:11:06 +0800249const ProcHook* GetProcHook(const char* name);
250ProcHook::Extension GetProcHookExtension(const char* name);
251
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800252bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
253 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);
254bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
255 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);
Chia-I Wucc5e2762016-03-24 13:01:16 +0800256
Chia-I Wueb7db122016-03-24 09:11:06 +0800257»} // namespace driver
258»} // namespace vulkan
259
260#endif // LIBVULKAN_DRIVER_TABLE_H
261¶{{end}}
262
263
264{{/*
265-------------------------------------------------------------------------------
266 driver_gen.cpp
267-------------------------------------------------------------------------------
268*/}}
269{{define "driver_gen.cpp"}}
270{{Macro "Copyright"}}
271
272// WARNING: This file is generated. See ../README.md for instructions.
273
274#include <string.h>
Mark Salyzyn7823e122016-09-29 08:08:05 -0700275
Chia-I Wueb7db122016-03-24 09:11:06 +0800276#include <algorithm>
Mark Salyzyn7823e122016-09-29 08:08:05 -0700277
278#include <log/log.h>
Chia-I Wueb7db122016-03-24 09:11:06 +0800279
280#include "driver.h"
Chia-I Wueb7db122016-03-24 09:11:06 +0800281
282namespace vulkan
283namespace driver
284
285namespace
286
287// clang-format off
288
289{{range $f := AllCommands $}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800290 {{Macro "driver.C++.DefineProcHookStub" $f}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800291{{end}}
292// clang-format on
293
294const ProcHook g_proc_hooks[] = {
295 // clang-format off
296 {{range $f := SortBy (AllCommands $) "FunctionName"}}
297 {{if (Macro "driver.IsIntercepted" $f)}}
298 {{ if (Macro "IsGloballyDispatched" $f)}}
299 {{Macro "driver.C++.DefineGlobalProcHook" $f}}
300 {{else if (Macro "IsInstanceDispatched" $f)}}
301 {{Macro "driver.C++.DefineInstanceProcHook" $f}}
302 {{else if (Macro "IsDeviceDispatched" $f)}}
303 {{Macro "driver.C++.DefineDeviceProcHook" $f}}
304 {{end}}
305 {{end}}
306 {{end}}
307 // clang-format on
308};
309
310»} // anonymous
311
312const ProcHook* GetProcHook(const char* name) {
313 const auto& begin = g_proc_hooks;
314 const auto& end = g_proc_hooks +
315 sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]);
316 const auto hook = std::lower_bound(begin, end, name,
317 [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; });
318 return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr;
319}
320
321ProcHook::Extension GetProcHookExtension(const char* name) {
322 {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
323 // clang-format off
324 {{range $e := $exts}}
325 if (strcmp(name, "{{$e}}") == 0) return ProcHook::{{TrimPrefix "VK_" $e}};
326 {{end}}
327 // clang-format on
328 return ProcHook::EXTENSION_UNKNOWN;
329}
330
Chia-I Wucc5e2762016-03-24 13:01:16 +0800331{{Macro "C++.DefineInitProcMacro" "driver"}}
332
333{{Macro "driver.C++.DefineInitProcExtMacro"}}
334
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800335bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
336 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
Chia-I Wucc5e2762016-03-24 13:01:16 +0800337{
338 auto& data = GetData(instance);
339 bool success = true;
340
341 // clang-format off
342 {{range $f := AllCommands $}}
343 {{if (Macro "driver.IsInstanceDriverTableEntry" $f)}}
344 {{Macro "C++.InitProc" $f}}
345 {{end}}
346 {{end}}
347 // clang-format on
348
349 return success;
350}
351
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800352bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
353 const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
Chia-I Wucc5e2762016-03-24 13:01:16 +0800354{
355 auto& data = GetData(dev);
356 bool success = true;
357
358 // clang-format off
359 {{range $f := AllCommands $}}
360 {{if (Macro "driver.IsDeviceDriverTableEntry" $f)}}
361 {{Macro "C++.InitProc" $f}}
362 {{end}}
363 {{end}}
364 // clang-format on
365
366 return success;
367}
368
Chia-I Wueb7db122016-03-24 09:11:06 +0800369»} // namespace driver
370»} // namespace vulkan
371
372// clang-format on
373¶{{end}}
374
375
376{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800377------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800378 Emits a declaration of a dispatch/driver table entry.
Chia-I Wu0c203242016-03-15 13:44:51 +0800379------------------------------------------------------------------------------
380*/}}
Chia-I Wucc5e2762016-03-24 13:01:16 +0800381{{define "C++.DeclareTableEntry"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800382 {{AssertType $ "Function"}}
383
384 {{Macro "FunctionPtrName" $}} {{Macro "BaseName" $}}
385{{end}}
386
387
388{{/*
389-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800390 Emits INIT_PROC macro.
Chia-I Wu0c203242016-03-15 13:44:51 +0800391-------------------------------------------------------------------------------
392*/}}
Chia-I Wucc5e2762016-03-24 13:01:16 +0800393{{define "C++.DefineInitProcMacro"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800394 #define UNLIKELY(expr) __builtin_expect((expr), 0)
395
396 #define INIT_PROC(obj, proc) do { \
397 data.{{$}}.proc = reinterpret_cast<PFN_vk ## proc>( \
398 get_proc(obj, "vk" # proc)); \
399 if (UNLIKELY(!data.{{$}}.proc)) { \
400 ALOGE("missing " # obj " proc: vk" # proc); \
401 success = false; \
402 } \
403 } while(0)
Chia-I Wu0c203242016-03-15 13:44:51 +0800404{{end}}
405
406
407{{/*
408-------------------------------------------------------------------------------
409 Emits code to invoke INIT_PROC or INIT_PROC_EXT.
410-------------------------------------------------------------------------------
411*/}}
412{{define "C++.InitProc"}}
413 {{AssertType $ "Function"}}
414
415 {{$ext := GetAnnotation $ "extension"}}
416 {{if $ext}}
417 INIT_PROC_EXT({{Macro "BaseName" $ext}}, §
418 {{else}}
419 INIT_PROC
420 {{end}}
421
422 {{if (Macro "IsInstanceDispatched" $)}}
423 instance, §
424 {{else}}
425 dev, §
426 {{end}}
427
428 {{Macro "BaseName" $}});
429{{end}}
430
431
432{{/*
433------------------------------------------------------------------------------
434 Emits true if a function is exported and instance-dispatched.
435------------------------------------------------------------------------------
436*/}}
437{{define "api.IsInstanceDispatchTableEntry"}}
438 {{AssertType $ "Function"}}
439
440 {{if and (Macro "IsFunctionExported" $) (Macro "IsInstanceDispatched" $)}}
Chia-I Wudbd33bc2016-06-02 11:25:47 +0800441 {{/* deprecated and unused internally */}}
442 {{if not (eq $.Name "vkEnumerateDeviceLayerProperties")}}
443 true
444 {{end}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800445 {{end}}
446{{end}}
447
448
449{{/*
450------------------------------------------------------------------------------
451 Emits true if a function is exported and device-dispatched.
452------------------------------------------------------------------------------
453*/}}
454{{define "api.IsDeviceDispatchTableEntry"}}
455 {{AssertType $ "Function"}}
456
457 {{if and (Macro "IsFunctionExported" $) (Macro "IsDeviceDispatched" $)}}
458 true
459 {{end}}
460{{end}}
461
462
463{{/*
464------------------------------------------------------------------------------
465 Emits true if a function is intercepted by vulkan::api.
466------------------------------------------------------------------------------
467*/}}
468{{define "api.IsIntercepted"}}
469 {{AssertType $ "Function"}}
470
471 {{if (Macro "IsFunctionSupported" $)}}
472 {{/* Global functions cannot be dispatched at all */}}
473 {{ if (Macro "IsGloballyDispatched" $)}}true
474
475 {{/* VkPhysicalDevice functions that manage device layers */}}
476 {{else if eq $.Name "vkCreateDevice"}}true
477 {{else if eq $.Name "vkEnumerateDeviceLayerProperties"}}true
478 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
479
480 {{/* Destroy functions of dispatchable objects */}}
481 {{else if eq $.Name "vkDestroyInstance"}}true
482 {{else if eq $.Name "vkDestroyDevice"}}true
483
484 {{end}}
485 {{end}}
486{{end}}
487
488
489{{/*
Chia-I Wucc5e2762016-03-24 13:01:16 +0800490-------------------------------------------------------------------------------
491 Emits INIT_PROC_EXT macro for vulkan::api.
492-------------------------------------------------------------------------------
493*/}}
494{{define "api.C++.DefineInitProcExtMacro"}}
Chia-I Wu8925efd2016-04-13 15:13:21 +0800495 // Exported extension functions may be invoked even when their extensions
496 // are disabled. Dispatch to stubs when that happens.
Chia-I Wucc5e2762016-03-24 13:01:16 +0800497 #define INIT_PROC_EXT(ext, obj, proc) do { \
Chia-I Wu8925efd2016-04-13 15:13:21 +0800498 if (extensions[driver::ProcHook::ext]) \
499 INIT_PROC(obj, proc); \
500 else \
501 data.dispatch.proc = disabled ## proc; \
Chia-I Wucc5e2762016-03-24 13:01:16 +0800502 } while(0)
503{{end}}
504
505
506{{/*
Chia-I Wu8925efd2016-04-13 15:13:21 +0800507-------------------------------------------------------------------------------
508 Emits a stub for an exported extension function.
509-------------------------------------------------------------------------------
510*/}}
511{{define "api.C++.DefineExtensionStub"}}
512 {{AssertType $ "Function"}}
513
514 {{$ext := GetAnnotation $ "extension"}}
515 {{if and $ext (Macro "IsFunctionExported" $)}}
516 {{$ext_name := index $ext.Arguments 0}}
517
518 {{$base := (Macro "BaseName" $)}}
Chia-I Wu8925efd2016-04-13 15:13:21 +0800519
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800520 {{$p0 := (index $.CallParameters 0)}}
521 {{$ptail := (Tail 1 $.CallParameters)}}
522
523 {{$first_type := (Macro "Parameter" $p0)}}
524 {{$tail_types := (ForEach $ptail "ParameterType" | JoinWith ", ")}}
525
526 VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$first_type}}, {{$tail_types}}) {
527 driver::Logger({{$p0.Name}}).Err({{$p0.Name}}, §
528 "{{$ext_name}} not enabled. Exported {{$.Name}} not executed.");
Chia-I Wu8925efd2016-04-13 15:13:21 +0800529 {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
530 }
531
532 {{end}}
533{{end}}
534
535
536{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800537------------------------------------------------------------------------------
538 Emits code for vkGetInstanceProcAddr for function interception.
539------------------------------------------------------------------------------
540*/}}
541{{define "api.C++.InterceptInstanceProcAddr"}}
542 {{AssertType $ "API"}}
543
544 // global functions
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800545 if (instance == VK_NULL_HANDLE) {
Chia-I Wu0c203242016-03-15 13:44:51 +0800546 {{range $f := AllCommands $}}
547 {{if (Macro "IsGloballyDispatched" $f)}}
548 if (strcmp(pName, "{{$f.Name}}") == 0) return §
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800549 reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}});
Chia-I Wu0c203242016-03-15 13:44:51 +0800550 {{end}}
551 {{end}}
552
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800553 ALOGE("invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, \"%s\") call", pName);
Chia-I Wu0c203242016-03-15 13:44:51 +0800554 return nullptr;
555 }
556
557 static const struct Hook {
558 const char* name;
559 PFN_vkVoidFunction proc;
560 } hooks[] = {
561 {{range $f := SortBy (AllCommands $) "FunctionName"}}
562 {{if (Macro "IsFunctionExported" $f)}}
563 {{/* hide global functions */}}
564 {{if (Macro "IsGloballyDispatched" $f)}}
565 { "{{$f.Name}}", nullptr },
566
567 {{/* redirect intercepted functions */}}
568 {{else if (Macro "api.IsIntercepted" $f)}}
569 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800570 {{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800571
572 {{/* redirect vkGetInstanceProcAddr to itself */}}
573 {{else if eq $f.Name "vkGetInstanceProcAddr"}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800574 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800575
576 {{/* redirect device functions to themselves as a workaround for
577 layers that do not intercept in their vkGetInstanceProcAddr */}}
578 {{else if (Macro "IsDeviceDispatched" $f)}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800579 { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "BaseName" $f}}) },
Chia-I Wu0c203242016-03-15 13:44:51 +0800580
581 {{end}}
582 {{end}}
583 {{end}}
584 };
585 // clang-format on
586 constexpr size_t count = sizeof(hooks) / sizeof(hooks[0]);
587 auto hook = std::lower_bound(
588 hooks, hooks + count, pName,
589 [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
590 if (hook < hooks + count && strcmp(hook->name, pName) == 0) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800591 if (!hook->proc) {
592 vulkan::driver::Logger(instance).Err(
593 instance, "invalid vkGetInstanceProcAddr(%p, \"%s\") call",
594 instance, pName);
595 }
Chia-I Wu0c203242016-03-15 13:44:51 +0800596 return hook->proc;
597 }
598 // clang-format off
599
600{{end}}
601
602
603{{/*
604------------------------------------------------------------------------------
605 Emits code for vkGetDeviceProcAddr for function interception.
606------------------------------------------------------------------------------
607*/}}
608{{define "api.C++.InterceptDeviceProcAddr"}}
609 {{AssertType $ "API"}}
610
611 if (device == VK_NULL_HANDLE) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800612 ALOGE("invalid vkGetDeviceProcAddr(VK_NULL_HANDLE, ...) call");
Chia-I Wu0c203242016-03-15 13:44:51 +0800613 return nullptr;
614 }
615
616 static const char* const known_non_device_names[] = {
617 {{range $f := SortBy (AllCommands $) "FunctionName"}}
618 {{if (Macro "IsFunctionSupported" $f)}}
619 {{if not (Macro "IsDeviceDispatched" $f)}}
620 "{{$f.Name}}",
621 {{end}}
622 {{end}}
623 {{end}}
624 };
625 // clang-format on
626 constexpr size_t count = sizeof(known_non_device_names) /
627 sizeof(known_non_device_names[0]);
628 if (!pName ||
629 std::binary_search(
630 known_non_device_names, known_non_device_names + count, pName,
631 [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800632 vulkan::driver::Logger(device).Err
633 device, "invalid vkGetDeviceProcAddr(%p, \"%s\") call", device
634 (pName) ? pName : "(null)");
Chia-I Wu0c203242016-03-15 13:44:51 +0800635 return nullptr;
636 }
637 // clang-format off
638
Chia-I Wuc56603e2016-04-12 11:16:17 +0800639 {{range $f := AllCommands $}}
640 {{if (Macro "IsDeviceDispatched" $f)}}
641 {{ if (Macro "api.IsIntercepted" $f)}}
642 if (strcmp(pName, "{{$f.Name}}") == 0) return §
643 reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800644 {{Macro "BaseName" $f}});
Chia-I Wuc56603e2016-04-12 11:16:17 +0800645 {{else if eq $f.Name "vkGetDeviceProcAddr"}}
646 if (strcmp(pName, "{{$f.Name}}") == 0) return §
647 reinterpret_cast<PFN_vkVoidFunction>(§
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800648 {{Macro "BaseName" $f}});
Chia-I Wuc56603e2016-04-12 11:16:17 +0800649 {{end}}
650 {{end}}
651 {{end}}
652
Chia-I Wu0c203242016-03-15 13:44:51 +0800653{{end}}
654
655
656{{/*
657------------------------------------------------------------------------------
658 Emits code to dispatch a function.
659------------------------------------------------------------------------------
660*/}}
661{{define "api.C++.Dispatch"}}
662 {{AssertType $ "Function"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800663 {{if (Macro "api.IsIntercepted" $)}}
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800664 {{Error "$.Name should not be generated"}}
Chia-I Wu0c203242016-03-15 13:44:51 +0800665 {{end}}
666
Chia-I Wu3e654dc2016-05-20 16:15:06 +0800667 {{if not (IsVoid $.Return.Type)}}return §{{end}}
668
669 {{$p0 := index $.CallParameters 0}}
670 GetData({{$p0.Name}}).dispatch
Chia-I Wu0c203242016-03-15 13:44:51 +0800671 {{Macro "BaseName" $}}({{Macro "Arguments" $}});
672{{end}}
673
674
675{{/*
Chia-I Wueb7db122016-03-24 09:11:06 +0800676------------------------------------------------------------------------------
677 Emits a list of extensions intercepted by vulkan::driver.
678------------------------------------------------------------------------------
679*/}}
680{{define "driver.InterceptedExtensions"}}
681VK_ANDROID_native_buffer
682VK_EXT_debug_report
683VK_KHR_android_surface
684VK_KHR_surface
685VK_KHR_swapchain
686{{end}}
687
688
689{{/*
690------------------------------------------------------------------------------
691 Emits true if an extension is intercepted by vulkan::driver.
692------------------------------------------------------------------------------
693*/}}
694{{define "driver.IsExtensionIntercepted"}}
695 {{$ext_name := index $.Arguments 0}}
696 {{$filters := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
697
698 {{range $f := $filters}}
699 {{if eq $ext_name $f}}true{{end}}
700 {{end}}
701{{end}}
702
703
704{{/*
705------------------------------------------------------------------------------
706 Emits true if a function is intercepted by vulkan::driver.
707------------------------------------------------------------------------------
708*/}}
709{{define "driver.IsIntercepted"}}
710 {{AssertType $ "Function"}}
711
712 {{if (Macro "IsFunctionSupported" $)}}
713 {{/* Create functions of dispatchable objects */}}
714 {{ if eq $.Name "vkCreateInstance"}}true
715 {{else if eq $.Name "vkCreateDevice"}}true
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800716 {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true
Chia-I Wueb7db122016-03-24 09:11:06 +0800717 {{else if eq $.Name "vkGetDeviceQueue"}}true
718 {{else if eq $.Name "vkAllocateCommandBuffers"}}true
719
720 {{/* Destroy functions of dispatchable objects */}}
721 {{else if eq $.Name "vkDestroyInstance"}}true
722 {{else if eq $.Name "vkDestroyDevice"}}true
723
724 {{/* Enumeration of extensions */}}
725 {{else if eq $.Name "vkEnumerateInstanceExtensionProperties"}}true
726 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
727
Chia-I Wueb7db122016-03-24 09:11:06 +0800728 {{else if eq $.Name "vkGetInstanceProcAddr"}}true
729 {{else if eq $.Name "vkGetDeviceProcAddr"}}true
730
731 {{end}}
732
733 {{$ext := GetAnnotation $ "extension"}}
734 {{if $ext}}
735 {{Macro "driver.IsExtensionIntercepted" $ext}}
736 {{end}}
737
738 {{end}}
739{{end}}
740
741
742{{/*
743------------------------------------------------------------------------------
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800744 Emits true if a function needs a ProcHook stub.
Chia-I Wueb7db122016-03-24 09:11:06 +0800745------------------------------------------------------------------------------
746*/}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800747{{define "driver.NeedProcHookStub"}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800748 {{AssertType $ "Function"}}
749
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800750 {{if and (Macro "driver.IsIntercepted" $) (Macro "IsDeviceDispatched" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800751 {{$ext := GetAnnotation $ "extension"}}
752 {{if $ext}}
753 {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}}
754 {{end}}
755 {{end}}
756{{end}}
757
758
759{{/*
760-------------------------------------------------------------------------------
761 Emits definition of struct ProcHook.
762-------------------------------------------------------------------------------
763*/}}
764{{define "driver.C++.DefineProcHookType"}}
765 struct ProcHook {
766 enum Type {
767 GLOBAL,
768 INSTANCE,
769 DEVICE,
770 };
771
772 enum Extension {
773 {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
774 {{range $e := $exts}}
775 {{TrimPrefix "VK_" $e}},
776 {{end}}
777
778 EXTENSION_CORE, // valid bit
779 EXTENSION_COUNT,
780 EXTENSION_UNKNOWN,
781 };
782
783 const char* name;
784 Type type;
785 Extension extension;
786
787 PFN_vkVoidFunction proc;
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800788 PFN_vkVoidFunction checked_proc; // always nullptr for non-device hooks
Chia-I Wueb7db122016-03-24 09:11:06 +0800789 };
790{{end}}
791
792
793{{/*
794-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800795 Emits INIT_PROC_EXT macro for vulkan::driver.
796-------------------------------------------------------------------------------
797*/}}
798{{define "driver.C++.DefineInitProcExtMacro"}}
799 #define INIT_PROC_EXT(ext, obj, proc) do { \
Chia-I Wucbe07ef2016-04-13 15:01:00 +0800800 if (extensions[ProcHook::ext]) \
Chia-I Wucc5e2762016-03-24 13:01:16 +0800801 INIT_PROC(obj, proc); \
802 } while(0)
803{{end}}
804
805
806{{/*
807-------------------------------------------------------------------------------
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800808 Emits a stub for ProcHook::checked_proc.
Chia-I Wueb7db122016-03-24 09:11:06 +0800809-------------------------------------------------------------------------------
810*/}}
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800811{{define "driver.C++.DefineProcHookStub"}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800812 {{AssertType $ "Function"}}
813
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800814 {{if (Macro "driver.NeedProcHookStub" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800815 {{$ext := GetAnnotation $ "extension"}}
816 {{$ext_name := index $ext.Arguments 0}}
817
818 {{$base := (Macro "BaseName" $)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800819
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800820 VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
821 {{$p0 := index $.CallParameters 0}}
822 {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800823
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800824 if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) {
825 {{if not (IsVoid $.Return.Type)}}return §{{end}}
826 {{$base}}({{Macro "Arguments" $}});
827 } else {
Chia-I Wu5beb2ac2016-05-04 16:37:23 +0800828 Logger({{$p0.Name}}).Err({{$p0.Name}}, "{{$ext_name}} not enabled. {{$.Name}} not executed.");
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800829 {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
Chia-I Wueb7db122016-03-24 09:11:06 +0800830 }
Chia-I Wu36cc00a2016-04-13 16:52:06 +0800831 }
Chia-I Wueb7db122016-03-24 09:11:06 +0800832
833 {{end}}
834{{end}}
835
836
837{{/*
838-------------------------------------------------------------------------------
839 Emits definition of a global ProcHook.
840-------------------------------------------------------------------------------
841*/}}
842{{define "driver.C++.DefineGlobalProcHook"}}
843 {{AssertType $ "Function"}}
844
845 {{$base := (Macro "BaseName" $)}}
846
847 {{$ext := GetAnnotation $ "extension"}}
848 {{if $ext}}
849 {{Error "invalid global extension"}}
850 {{end}}
851
852 {
853 "{{$.Name}}",
854 ProcHook::GLOBAL,
855 ProcHook::EXTENSION_CORE,
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800856 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800857 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800858 },
859{{end}}
860
861
862{{/*
863-------------------------------------------------------------------------------
864 Emits definition of an instance ProcHook.
865-------------------------------------------------------------------------------
866*/}}
867{{define "driver.C++.DefineInstanceProcHook"}}
868 {{AssertType $ "Function"}}
869
870 {{$base := (Macro "BaseName" $)}}
871
872 {
873 "{{$.Name}}",
874 ProcHook::INSTANCE,
875
876 {{$ext := GetAnnotation $ "extension"}}
877 {{if $ext}}
878 ProcHook::{{Macro "BaseName" $ext}},
879
880 {{if (Macro "IsExtensionInternal" $ext)}}
881 nullptr,
882 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800883 {{else}}
Chia-I Wu62262232016-03-26 07:06:44 +0800884 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800885 nullptr,
886 {{end}}
887 {{else}}
888 ProcHook::EXTENSION_CORE,
Chia-I Wuff4a6c72016-03-24 16:05:56 +0800889 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800890 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800891 {{end}}
892 },
893{{end}}
894
895
896{{/*
897-------------------------------------------------------------------------------
898 Emits definition of a device ProcHook.
899-------------------------------------------------------------------------------
900*/}}
901{{define "driver.C++.DefineDeviceProcHook"}}
902 {{AssertType $ "Function"}}
903
904 {{$base := (Macro "BaseName" $)}}
905
906 {
907 "{{$.Name}}",
908 ProcHook::DEVICE,
909
910 {{$ext := GetAnnotation $ "extension"}}
911 {{if $ext}}
912 ProcHook::{{Macro "BaseName" $ext}},
913
914 {{if (Macro "IsExtensionInternal" $ext)}}
915 nullptr,
916 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800917 {{else}}
Chia-I Wu62262232016-03-26 07:06:44 +0800918 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
Chia-I Wueb7db122016-03-24 09:11:06 +0800919 reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
920 {{end}}
921 {{else}}
Chia-I Wu4901db72016-03-24 16:38:58 +0800922 ProcHook::EXTENSION_CORE,
923 reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
924 nullptr,
Chia-I Wueb7db122016-03-24 09:11:06 +0800925 {{end}}
926 },
927{{end}}
928
929
930{{/*
Chia-I Wu0c203242016-03-15 13:44:51 +0800931-------------------------------------------------------------------------------
Chia-I Wucc5e2762016-03-24 13:01:16 +0800932 Emits true if a function is needed by vulkan::driver.
933-------------------------------------------------------------------------------
934*/}}
935{{define "driver.IsDriverTableEntry"}}
936 {{AssertType $ "Function"}}
937
938 {{if (Macro "IsFunctionSupported" $)}}
939 {{/* Create functions of dispatchable objects */}}
940 {{ if eq $.Name "vkCreateDevice"}}true
941 {{else if eq $.Name "vkGetDeviceQueue"}}true
942 {{else if eq $.Name "vkAllocateCommandBuffers"}}true
943
944 {{/* Destroy functions of dispatchable objects */}}
945 {{else if eq $.Name "vkDestroyInstance"}}true
946 {{else if eq $.Name "vkDestroyDevice"}}true
947
948 {{/* Enumeration of extensions */}}
949 {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
950
951 {{/* We cache physical devices in loader.cpp */}}
952 {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true
953
954 {{else if eq $.Name "vkGetInstanceProcAddr"}}true
955 {{else if eq $.Name "vkGetDeviceProcAddr"}}true
956
957 {{/* VK_KHR_swapchain->VK_ANDROID_native_buffer translation */}}
958 {{else if eq $.Name "vkCreateImage"}}true
959 {{else if eq $.Name "vkDestroyImage"}}true
960
961 {{end}}
962
963 {{$ext := GetAnnotation $ "extension"}}
964 {{if $ext}}
965 {{$ext_name := index $ext.Arguments 0}}
966 {{ if eq $ext_name "VK_ANDROID_native_buffer"}}true
967 {{else if eq $ext_name "VK_EXT_debug_report"}}true
968 {{end}}
969 {{end}}
970 {{end}}
971{{end}}
972
973
974{{/*
975------------------------------------------------------------------------------
976 Emits true if an instance-dispatched function is needed by vulkan::driver.
977------------------------------------------------------------------------------
978*/}}
979{{define "driver.IsInstanceDriverTableEntry"}}
980 {{AssertType $ "Function"}}
981
982 {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsInstanceDispatched" $)}}
983 true
984 {{end}}
985{{end}}
986
987
988{{/*
989------------------------------------------------------------------------------
990 Emits true if a device-dispatched function is needed by vulkan::driver.
991------------------------------------------------------------------------------
992*/}}
993{{define "driver.IsDeviceDriverTableEntry"}}
994 {{AssertType $ "Function"}}
995
996 {{if and (Macro "driver.IsDriverTableEntry" $) (Macro "IsDeviceDispatched" $)}}
997 true
998 {{end}}
999{{end}}
1000
1001
1002{{/*
1003-------------------------------------------------------------------------------
Chia-I Wu0c203242016-03-15 13:44:51 +08001004 Emits a function/extension name without the "vk"/"VK_" prefix.
1005-------------------------------------------------------------------------------
1006*/}}
1007{{define "BaseName"}}
1008 {{ if IsFunction $}}{{TrimPrefix "vk" $.Name}}
1009 {{else if eq $.Name "extension"}}{{TrimPrefix "VK_" (index $.Arguments 0)}}
1010 {{else}}{{Error "invalid use of BaseName"}}
1011 {{end}}
1012{{end}}
1013
1014
1015{{/*
1016-------------------------------------------------------------------------------
1017 Emits a comma-separated list of C parameter names for the given command.
1018-------------------------------------------------------------------------------
1019*/}}
1020{{define "Arguments"}}
1021 {{AssertType $ "Function"}}
1022
1023 {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}}
1024{{end}}
1025
1026
1027{{/*
1028------------------------------------------------------------------------------
1029------------------------------------------------------------------------------
1030*/}}
1031{{define "IsGloballyDispatched"}}
1032 {{AssertType $ "Function"}}
1033 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Global")}}
1034 true
1035 {{end}}
1036{{end}}
1037
1038
1039{{/*
1040------------------------------------------------------------------------------
1041 Emit "true" for supported functions that undergo table dispatch. Only global
1042 functions and functions handled in the loader top without calling into
1043 lower layers are not dispatched.
1044------------------------------------------------------------------------------
1045*/}}
1046{{define "IsInstanceDispatched"}}
1047 {{AssertType $ "Function"}}
1048 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Instance")}}
1049 true
1050 {{end}}
1051{{end}}
1052
1053
1054{{/*
1055------------------------------------------------------------------------------
1056 Emit "true" for supported functions that can have device-specific dispatch.
1057------------------------------------------------------------------------------
1058*/}}
1059{{define "IsDeviceDispatched"}}
1060 {{AssertType $ "Function"}}
1061 {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Device")}}
1062 true
1063 {{end}}
1064{{end}}
1065
1066
1067{{/*
1068------------------------------------------------------------------------------
1069 Emit "true" if a function is core or from a supportable extension.
1070------------------------------------------------------------------------------
1071*/}}
1072{{define "IsFunctionSupported"}}
1073 {{AssertType $ "Function"}}
1074 {{if not (GetAnnotation $ "pfn")}}
1075 {{$ext := GetAnnotation $ "extension"}}
1076 {{if not $ext}}true
1077 {{else if not (Macro "IsExtensionBlacklisted" $ext)}}true
1078 {{end}}
1079 {{end}}
1080{{end}}
1081
1082
1083{{/*
1084------------------------------------------------------------------------------
1085 Decides whether a function should be exported from the Android Vulkan
1086 library. Functions in the core API and in loader extensions are exported.
1087------------------------------------------------------------------------------
1088*/}}
1089{{define "IsFunctionExported"}}
1090 {{AssertType $ "Function"}}
1091
1092 {{if (Macro "IsFunctionSupported" $)}}
1093 {{$ext := GetAnnotation $ "extension"}}
1094 {{if $ext}}
1095 {{Macro "IsExtensionExported" $ext}}
1096 {{else}}
1097 true
1098 {{end}}
1099 {{end}}
1100{{end}}
1101
1102
1103{{/*
1104------------------------------------------------------------------------------
1105 Emit "true" if an extension is unsupportable on Android.
1106------------------------------------------------------------------------------
1107*/}}
1108{{define "IsExtensionBlacklisted"}}
1109 {{$ext := index $.Arguments 0}}
1110 {{ if eq $ext "VK_KHR_display"}}true
1111 {{else if eq $ext "VK_KHR_display_swapchain"}}true
1112 {{else if eq $ext "VK_KHR_xlib_surface"}}true
1113 {{else if eq $ext "VK_KHR_xcb_surface"}}true
1114 {{else if eq $ext "VK_KHR_wayland_surface"}}true
1115 {{else if eq $ext "VK_KHR_mir_surface"}}true
1116 {{else if eq $ext "VK_KHR_win32_surface"}}true
Jesse Halleb02c472017-02-24 15:13:45 -08001117 {{else if eq $ext "VK_NV_external_memory_win32"}}true
1118 {{else if eq $ext "VK_NV_win32_keyed_mutex"}}true
Chia-I Wu0c203242016-03-15 13:44:51 +08001119 {{end}}
1120{{end}}
1121
1122
1123{{/*
1124------------------------------------------------------------------------------
1125 Reports whether an extension is implemented entirely by the loader,
1126 so drivers should not enumerate it.
1127------------------------------------------------------------------------------
1128*/}}
1129{{define "IsExtensionExported"}}
1130 {{$ext := index $.Arguments 0}}
1131 {{ if eq $ext "VK_KHR_surface"}}true
1132 {{else if eq $ext "VK_KHR_swapchain"}}true
1133 {{else if eq $ext "VK_KHR_android_surface"}}true
1134 {{end}}
1135{{end}}
Chia-I Wueb7db122016-03-24 09:11:06 +08001136
1137
1138{{/*
1139------------------------------------------------------------------------------
1140 Reports whether an extension is internal to the loader and drivers,
1141 so the loader should not enumerate it.
1142------------------------------------------------------------------------------
1143*/}}
1144{{define "IsExtensionInternal"}}
1145 {{$ext := index $.Arguments 0}}
1146 {{ if eq $ext "VK_ANDROID_native_buffer"}}true
1147 {{end}}
1148{{end}}