code-generator.tmpl revision eb7db124e46da9a9210cf868353f5ea79502ffec
10c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "Copyright"}}
20c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu/*
30c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* Copyright 2016 The Android Open Source Project
40c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•*
50c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* Licensed under the Apache License, Version 2.0 (the "License");
60c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* you may not use this file except in compliance with the License.
70c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* You may obtain a copy of the License at
80c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•*
90c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•*      http://www.apache.org/licenses/LICENSE-2.0
100c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•*
110c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* Unless required by applicable law or agreed to in writing, software
120c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* distributed under the License is distributed on an "AS IS" BASIS,
130c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
140c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* See the License for the specific language governing permissions and
150c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•* limitations under the License.
160c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu•*/
170c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu¶{{end}}
180c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
190c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Include "../api/templates/vulkan_common.tmpl"}}
200c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Global "clang-format" (Strings "clang-format" "-style=file")}}
210c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Macro "DefineGlobals" $}}
220c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{$ | Macro "api_gen.h"   | Format (Global "clang-format") | Write "api_gen.h"  }}
230c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{$ | Macro "api_gen.cpp" | Format (Global "clang-format") | Write "api_gen.cpp"}}
24eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{$ | Macro "driver_gen.h" | Format (Global "clang-format") | Write "driver_gen.h"}}
25eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{$ | Macro "driver_gen.cpp" | Format (Global "clang-format") | Write "driver_gen.cpp"}}
260c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
270c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
280c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
290c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  api_gen.h
300c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
310c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
320c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api_gen.h"}}
330c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Macro "Copyright"}}
340c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu350c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu// WARNING: This file is generated. See ../README.md for instructions.
360c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu370c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#ifndef LIBVULKAN_API_GEN_H
380c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#define LIBVULKAN_API_GEN_H
390c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu400c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#include <vulkan/vulkan.h>
410c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu420c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wunamespace vulkan {«
430c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wunamespace api {«
440c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu450c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wustruct InstanceDispatchTable {
460c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format off
470c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{range $f := AllCommands $}}
480c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}}
490c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{Macro "C++.DeclareDispatchTableEntry" $f}};
500c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
510c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
520c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format on
530c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu};
540c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu550c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wustruct DeviceDispatchTable {
560c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format off
570c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{range $f := AllCommands $}}
580c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}}
590c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{Macro "C++.DeclareDispatchTableEntry" $f}};
600c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
610c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
620c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format on
630c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu};
640c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu650c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wubool InitDispatchTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc);
660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wubool InitDispatchTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc);
670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu»} // namespace api
690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu»} // namespace vulkan
700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#endif // LIBVULKAN_API_GEN_H
720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu¶{{end}}
730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  api_gen.cpp
780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api_gen.cpp"}}
810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Macro "Copyright"}}
820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu// WARNING: This file is generated. See ../README.md for instructions.
840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#include <string.h>
860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#include <algorithm>
870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#include <log/log.h>
880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu#include "api.h"
900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wunamespace vulkan {«
920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wunamespace api {«
930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{Macro "C++.DefineInitProcMacros" "dispatch"}}
950c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu960c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wubool InitDispatchTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc) {
970c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    auto& data = GetData(instance);
980c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    bool success = true;
990c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1000c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    // clang-format off
1010c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{range $f := AllCommands $}}
1020c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{if (Macro "api.IsInstanceDispatchTableEntry" $f)}}
1030c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{Macro "C++.InitProc" $f}}
1040c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
1050c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
1060c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    // clang-format on
1070c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1080c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return success;
1090c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu}
1100c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1110c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wubool InitDispatchTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc) {
1120c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    auto& data = GetData(dev);
1130c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    bool success = true;
1140c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1150c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    // clang-format off
1160c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{range $f := AllCommands $}}
1170c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{if (Macro "api.IsDeviceDispatchTableEntry" $f)}}
1180c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{Macro "C++.InitProc" $f}}
1190c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
1200c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
1210c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    // clang-format on
1220c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1230c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return success;
1240c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu}
1250c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1260c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu»} // namespace api
1270c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu»} // namespace vulkan
1280c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1290c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu// clang-format off
1300c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1310c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{range $f := AllCommands $}}
1320c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "IsFunctionExported" $f)}}
1330c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    __attribute__((visibility("default")))
1340c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    VKAPI_ATTR {{Node "Type" $f.Return}} {{$f.Name}}({{Macro "Parameters" $f}}) {
1350c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{     if eq $f.Name "vkGetInstanceProcAddr"}}
1360c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{Macro "api.C++.InterceptInstanceProcAddr" $}}
1370c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{else if eq $f.Name "vkGetDeviceProcAddr"}}
1380c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{Macro "api.C++.InterceptDeviceProcAddr" $}}
1390c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
1400c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
1410c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{Macro "api.C++.Dispatch" $f}}
1420c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    }
1430c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1440c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
1450c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
1460c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu1470c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu// clang-format on
1480c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu¶{{end}}
1490c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
1500c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
1510c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
152eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
153eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  driver_gen.h
154eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
155eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
156eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver_gen.h"}}
157eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{Macro "Copyright"}}
158eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu159eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu// WARNING: This file is generated. See ../README.md for instructions.
160eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu161eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#ifndef LIBVULKAN_DRIVER_GEN_H
162eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#define LIBVULKAN_DRIVER_GEN_H
163eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu164eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include <vulkan/vulkan.h>
165eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include <vulkan/vk_android_native_buffer.h>
166eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu167eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wunamespace vulkan {«
168eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wunamespace driver {«
169eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu170eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{Macro "driver.C++.DefineProcHookType"}}
171eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu172eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wuconst ProcHook* GetProcHook(const char* name);
173eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuProcHook::Extension GetProcHookExtension(const char* name);
174eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu175eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu»} // namespace driver
176eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu»} // namespace vulkan
177eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu178eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#endif // LIBVULKAN_DRIVER_TABLE_H
179eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu¶{{end}}
180eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
181eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
182eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
183eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
184eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  driver_gen.cpp
185eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
186eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
187eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver_gen.cpp"}}
188eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{Macro "Copyright"}}
189eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu190eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu// WARNING: This file is generated. See ../README.md for instructions.
191eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu192eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include <string.h>
193eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include <algorithm>
194eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include <log/log.h>
195eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu196eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include "driver.h"
197eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu#include "loader.h"
198eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu199eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wunamespace vulkan {«
200eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wunamespace driver {«
201eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu202eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wunamespace {«
203eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu204eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu// clang-format off
205eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu206eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{range $f := AllCommands $}}
207eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{Macro "driver.C++.DefineProcHookStubs" $f}}
208eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
209eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu// clang-format on
210eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu211eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wuconst ProcHook g_proc_hooks[] = {
212eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  // clang-format off
213eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{range $f := SortBy (AllCommands $) "FunctionName"}}
214eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if (Macro "driver.IsIntercepted" $f)}}
215eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{     if (Macro "IsGloballyDispatched" $f)}}
216eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{Macro "driver.C++.DefineGlobalProcHook" $f}}
217eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{else if (Macro "IsInstanceDispatched" $f)}}
218eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{Macro "driver.C++.DefineInstanceProcHook" $f}}
219eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{else if (Macro "IsDeviceDispatched" $f)}}
220eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{Macro "driver.C++.DefineDeviceProcHook" $f}}
221eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{end}}
222eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
223eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
224eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  // clang-format on
225eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu};
226eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu227eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu»} // anonymous
228eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu229eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wuconst ProcHook* GetProcHook(const char* name) {
230eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    const auto& begin = g_proc_hooks;
231eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    const auto& end = g_proc_hooks +
232eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]);
233eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    const auto hook = std::lower_bound(begin, end, name,
234eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; });
235eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    return (hook <  end && strcmp(hook->name, name) == 0) ? hook : nullptr;
236eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu}
237eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu238eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuProcHook::Extension GetProcHookExtension(const char* name) {
239eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
240eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  // clang-format off
241eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{range $e := $exts}}
242eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    if (strcmp(name, "{{$e}}") == 0) return ProcHook::{{TrimPrefix "VK_" $e}};
243eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
244eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  // clang-format on
245eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  return ProcHook::EXTENSION_UNKNOWN;
246eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu}
247eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu248eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu»} // namespace driver
249eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu»} // namespace vulkan
250eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu251eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu// clang-format on
252eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu¶{{end}}
253eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
254eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
255eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
2560c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
2570c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits a declaration of a dispatch table entry.
2580c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
2590c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
2600c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "C++.DeclareDispatchTableEntry"}}
2610c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
2620c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2630c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{Macro "FunctionPtrName" $}} {{Macro "BaseName" $}}
2640c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
2650c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
2680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
2690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits macros to help initialize dispatch tables.
2700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
2710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
2720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "C++.DefineInitProcMacros"}}
2730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  #define UNLIKELY(expr) __builtin_expect((expr), 0)
2740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu2750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  #define INIT_PROC(obj, proc) do {                             \
2760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      data.{{$}}.proc = reinterpret_cast<PFN_vk ## proc>(       \
2770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu              get_proc(obj, "vk" # proc));                      \
2780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      if (UNLIKELY(!data.{{$}}.proc)) {                         \
2790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          ALOGE("missing " # obj " proc: vk" # proc);           \
2800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          success = false;                                      \
2810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      }                                                         \
2820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  } while(0)
2830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu2840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // TODO do we want to point to a stub or nullptr when ext is not enabled?
2850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  #define INIT_PROC_EXT(ext, obj, proc) do {                    \
2860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      INIT_PROC(obj, proc);                                     \
2870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  } while(0)
2880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
2890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
2920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
2930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits code to invoke INIT_PROC or INIT_PROC_EXT.
2940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
2950c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
2960c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "C++.InitProc"}}
2970c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
2980c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
2990c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{$ext := GetAnnotation $ "extension"}}
3000c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if $ext}}
3010c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    INIT_PROC_EXT({{Macro "BaseName" $ext}}, §
3020c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else}}
3030c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    INIT_PROC(§
3040c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
3050c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3060c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "IsInstanceDispatched" $)}}
3070c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    instance, §
3080c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else}}
3090c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    dev, §
3100c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
3110c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3120c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{Macro "BaseName" $}});
3130c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
3140c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3150c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3160c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
3170c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3180c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits true if a function is exported and instance-dispatched.
3190c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3200c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
3210c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.IsInstanceDispatchTableEntry"}}
3220c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
3230c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3240c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if and (Macro "IsFunctionExported" $) (Macro "IsInstanceDispatched" $)}}
3250c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    true
3260c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
3270c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
3280c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3290c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3300c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
3310c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3320c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits true if a function is exported and device-dispatched.
3330c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3340c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
3350c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.IsDeviceDispatchTableEntry"}}
3360c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
3370c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3380c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if and (Macro "IsFunctionExported" $) (Macro "IsDeviceDispatched" $)}}
3390c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    true
3400c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
3410c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
3420c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3430c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3440c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
3450c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3460c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits true if a function is intercepted by vulkan::api.
3470c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3480c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
3490c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.IsIntercepted"}}
3500c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
3510c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3520c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "IsFunctionSupported" $)}}
3530c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{/* Global functions cannot be dispatched at all */}}
3540c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{     if (Macro "IsGloballyDispatched" $)}}true
3550c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3560c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{/* VkPhysicalDevice functions that manage device layers */}}
3570c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if eq $.Name "vkCreateDevice"}}true
3580c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if eq $.Name "vkEnumerateDeviceLayerProperties"}}true
3590c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
3600c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3610c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{/* Destroy functions of dispatchable objects */}}
3620c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if eq $.Name "vkDestroyInstance"}}true
3630c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if eq $.Name "vkDestroyDevice"}}true
3640c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3650c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
3660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
3670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
3680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
3710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits code for vkGetInstanceProcAddr for function interception.
3730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
3740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
3750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.C++.InterceptInstanceProcAddr"}}
3760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "API"}}
3770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
3780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // global functions
3790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  if (!instance) {
3800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{range $f := AllCommands $}}
3810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{if (Macro "IsGloballyDispatched" $f)}}
3820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        if (strcmp(pName, "{{$f.Name}}") == 0) return §
3830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          reinterpret_cast<PFN_vkVoidFunction>(§
3840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu            vulkan::api::{{Macro "BaseName" $f}});
3850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
3860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
3870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu3880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    ALOGE("vkGetInstanceProcAddr called with %s without instance",  pName);
3890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return nullptr;
3900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  }
3910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu3920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  static const struct Hook {
3930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    const char* name;
3940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    PFN_vkVoidFunction proc;
3950c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  } hooks[] = {
3960c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{range $f := SortBy (AllCommands $) "FunctionName"}}
3970c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{if (Macro "IsFunctionExported" $f)}}
3980c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{/* hide global functions */}}
3990c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{if (Macro "IsGloballyDispatched" $f)}}
4000c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          { "{{$f.Name}}", nullptr },
4010c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4020c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{/* redirect intercepted functions */}}
4030c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{else if (Macro "api.IsIntercepted" $f)}}
4040c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
4050c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu            vulkan::api::{{Macro "BaseName" $f}}) },
4060c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4070c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{/* redirect vkGetInstanceProcAddr to itself */}}
4080c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{else if eq $f.Name "vkGetInstanceProcAddr"}}
4090c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{$f.Name}}) },
4100c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4110c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{/* redirect device functions to themselves as a workaround for
4120c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu             layers that do not intercept in their vkGetInstanceProcAddr */}}
4130c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{else if (Macro "IsDeviceDispatched" $f)}}
4140c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          { "{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>({{$f.Name}}) },
4150c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4160c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{end}}
4170c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
4180c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
4190c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  };
4200c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format on
4210c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  constexpr size_t count = sizeof(hooks) / sizeof(hooks[0]);
4220c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  auto hook = std::lower_bound(
4230c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    hooks, hooks + count, pName,
4240c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    [](const Hook& h, const char* n) { return strcmp(h.name, n) < 0; });
4250c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  if (hook <  hooks + count && strcmp(hook->name, pName) == 0) {
4260c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    if (!hook->proc)
4270c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      ALOGE("vkGetInstanceProcAddr called with %s with instance",  pName);
4280c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return hook->proc;
4290c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  }
4300c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format off
4310c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu4320c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
4330c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4340c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4350c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
4360c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
4370c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits code for vkGetDeviceProcAddr for function interception.
4380c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
4390c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
4400c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.C++.InterceptDeviceProcAddr"}}
4410c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "API"}}
4420c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4430c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  if (device == VK_NULL_HANDLE) {
4440c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    ALOGE("vkGetDeviceProcAddr called with invalid device");
4450c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return nullptr;
4460c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  }
4470c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu4480c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  static const char* const known_non_device_names[] = {
4490c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{range $f := SortBy (AllCommands $) "FunctionName"}}
4500c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{if (Macro "IsFunctionSupported" $f)}}
4510c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{if not (Macro "IsDeviceDispatched" $f)}}
4520c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu          "{{$f.Name}}",
4530c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        {{end}}
4540c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{end}}
4550c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
4560c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  };
4570c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format on
4580c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  constexpr size_t count = sizeof(known_non_device_names) /
4590c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    sizeof(known_non_device_names[0]);
4600c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  if (!pName ||
4610c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      std::binary_search(
4620c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        known_non_device_names, known_non_device_names + count, pName,
4630c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu        [](const char* a, const char* b) { return (strcmp(a, b) < 0); })) {
4640c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    ALOGE("vkGetDeviceProcAddr called with %s", pName);
4650c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    return nullptr;
4660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  }
4670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  // clang-format off
4680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu4690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
4700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
4730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
4740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits code to dispatch a function.
4750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
4760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
4770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "api.C++.Dispatch"}}
4780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
4790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "api.IsIntercepted" $)}}// call into api.cpp{{end}}
4810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if not (IsVoid $.Return.Type)}}return §{{end}}
4820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "api.IsIntercepted" $)}}
4840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    vulkan::api::§
4850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else}}
4860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{$p0 := index $.CallParameters 0}}
4870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    vulkan::api::GetData({{$p0.Name}}).dispatch.§
4880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
4890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{Macro "BaseName" $}}({{Macro "Arguments" $}});
4910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
4920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
4940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
495eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
496eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits a list of extensions intercepted by vulkan::driver.
497eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
498eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
499eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.InterceptedExtensions"}}
500eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuVK_ANDROID_native_buffer
501eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuVK_EXT_debug_report
502eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuVK_KHR_android_surface
503eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuVK_KHR_surface
504eb7db124e46da9a9210cf868353f5ea79502ffecChia-I WuVK_KHR_swapchain
505eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
506eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
507eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
508eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
509eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
510eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits true if an extension is intercepted by vulkan::driver.
511eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
512eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
513eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.IsExtensionIntercepted"}}
514eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$ext_name := index $.Arguments 0}}
515eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$filters := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
516eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
517eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{range $f := $filters}}
518eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if eq $ext_name $f}}true{{end}}
519eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
520eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
521eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
522eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
523eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
524eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
525eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits true if a function is intercepted by vulkan::driver.
526eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
527eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
528eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.IsIntercepted"}}
529eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
530eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
531eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{if (Macro "IsFunctionSupported" $)}}
532eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{/* Create functions of dispatchable objects */}}
533eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{     if eq $.Name "vkCreateInstance"}}true
534eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkCreateDevice"}}true
535eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkGetDeviceQueue"}}true
536eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkAllocateCommandBuffers"}}true
537eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
538eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{/* Destroy functions of dispatchable objects */}}
539eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkDestroyInstance"}}true
540eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkDestroyDevice"}}true
541eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
542eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{/* Enumeration of extensions */}}
543eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkEnumerateInstanceExtensionProperties"}}true
544eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkEnumerateDeviceExtensionProperties"}}true
545eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
546eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{/* We cache physical devices in loader.cpp */}}
547eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkEnumeratePhysicalDevices"}}true
548eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
549eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkGetInstanceProcAddr"}}true
550eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else if eq $.Name "vkGetDeviceProcAddr"}}true
551eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
552eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
553eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
554eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext := GetAnnotation $ "extension"}}
555eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if $ext}}
556eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{Macro "driver.IsExtensionIntercepted" $ext}}
557eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
558eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
559eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
560eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
561eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
562eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
563eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
564eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
565eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits true if a function needs ProcHook stubs.
566eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
567eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
568eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.NeedProcHookStubs"}}
569eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
570eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
571eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{if (Macro "driver.IsIntercepted" $)}}
572eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext := GetAnnotation $ "extension"}}
573eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if $ext}}
574eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}}
575eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
576eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
577eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
578eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
579eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
580eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
581eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
582eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits definition of struct ProcHook.
583eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
584eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
585eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.C++.DefineProcHookType"}}
586eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  struct ProcHook {
587eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      enum Type {
588eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        GLOBAL,
589eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        INSTANCE,
590eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        DEVICE,
591eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      };
592eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
593eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      enum Extension {
594eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{$exts := Strings (Macro "driver.InterceptedExtensions") | SplitOn "\n"}}
595eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{range $e := $exts}}
596eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu          {{TrimPrefix "VK_" $e}},
597eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{end}}
598eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu599eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        EXTENSION_CORE, // valid bit
600eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        EXTENSION_COUNT,
601eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        EXTENSION_UNKNOWN,
602eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      };
603eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu604eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      const char* name;
605eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      Type type;
606eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      Extension extension;
607eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu608eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      PFN_vkVoidFunction proc;
609eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      PFN_vkVoidFunction disabled_proc; // nullptr for global hooks
610eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      PFN_vkVoidFunction checked_proc;  // nullptr for global/instance hooks
611eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  };
612eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
613eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
614eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
615eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
616eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
617eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits definitions of stub functions for ProcHook.
618eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
619eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
620eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.C++.DefineProcHookStubs"}}
621eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
622eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
623eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{if (Macro "driver.NeedProcHookStubs" $)}}
624eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext := GetAnnotation $ "extension"}}
625eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext_name := index $ext.Arguments 0}}
626eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
627eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$base := (Macro "BaseName" $)}}
628eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$unnamed_params := (ForEach $.CallParameters "ParameterType" | JoinWith ", ")}}
629eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
630eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    VKAPI_ATTR {{Node "Type" $.Return}} disabled{{$base}}({{$unnamed_params}}) {
631eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      ALOGE("{{$ext_name}} not enabled. {{$.Name}} not executed.");
632eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{if not (IsVoid $.Return.Type)}}return VK_SUCCESS;{{end}}
633eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    }
634eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if (Macro "IsDeviceDispatched" $)}}
635eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu636eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
637eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{if not (IsVoid $.Return.Type)}}return §{{end}}
638eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
639eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{$p0 := index $.CallParameters 0}}
640eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}}
641eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) ? §
642eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu          {{$base}}_Bottom({{Macro "Arguments" $}}) : §
643eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu          disabled{{$base}}({{Macro "Arguments" $}});
644eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      }
645eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
646eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu647eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
648eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
649eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
650eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
651eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
652eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
653eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits definition of a global ProcHook.
654eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
655eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
656eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.C++.DefineGlobalProcHook"}}
657eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
658eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
659eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$base := (Macro "BaseName" $)}}
660eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
661eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$ext := GetAnnotation $ "extension"}}
662eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{if $ext}}
663eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{Error "invalid global extension"}}
664eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
665eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
666eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {
667eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    "{{$.Name}}",
668eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    ProcHook::GLOBAL,
669eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    ProcHook::EXTENSION_CORE,
670eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if eq $.Name "vkEnumerateInstanceExtensionProperties"}}
671eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
672eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else}}
673eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      reinterpret_cast<PFN_vkVoidFunction>({{$base}}_Bottom),
674eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
675eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    nullptr,
676eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    nullptr,
677eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  },
678eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
679eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
680eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
681eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
682eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
683eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits definition of an instance ProcHook.
684eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
685eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
686eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.C++.DefineInstanceProcHook"}}
687eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
688eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
689eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$base := (Macro "BaseName" $)}}
690eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
691eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {
692eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    "{{$.Name}}",
693eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    ProcHook::INSTANCE,
694eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
695eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext := GetAnnotation $ "extension"}}
696eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if $ext}}
697eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      ProcHook::{{Macro "BaseName" $ext}},
698eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
699eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{if (Macro "IsExtensionInternal" $ext)}}
700eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
701eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
702eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
703eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{else}}
704eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>({{$base}}_Bottom),
705eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>(disabled{{$base}}),
706eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
707eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{end}}
708eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else}}
709eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      ProcHook::EXTENSION_CORE,
710eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
711eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{if eq $.Name "vkGetInstanceProcAddr"}}
712eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
713eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{else}}
714eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>({{$base}}_Bottom),
715eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{end}}
716eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      nullptr,
717eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      nullptr,
718eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
719eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  },
720eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
721eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
722eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
723eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
724eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
725eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Emits definition of a device ProcHook.
726eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu-------------------------------------------------------------------------------
727eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
728eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "driver.C++.DefineDeviceProcHook"}}
729eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{AssertType $ "Function"}}
730eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
731eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$base := (Macro "BaseName" $)}}
732eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
733eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {
734eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    "{{$.Name}}",
735eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    ProcHook::DEVICE,
736eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
737eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{$ext := GetAnnotation $ "extension"}}
738eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{if $ext}}
739eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      ProcHook::{{Macro "BaseName" $ext}},
740eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
741eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{if (Macro "IsExtensionInternal" $ext)}}
742eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
743eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
744eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
745eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{else}}
746eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>({{$base}}_Bottom),
747eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>(disabled{{$base}}),
748eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
749eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu      {{end}}
750eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{else}}
751eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        ProcHook::EXTENSION_CORE,
752eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
753eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{if eq $.Name "vkGetDeviceProcAddr"}}
754eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu          reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
755eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{else}}
756eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu          reinterpret_cast<PFN_vkVoidFunction>({{$base}}_Bottom),
757eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        {{end}}
758eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
759eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu        nullptr,
760eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu    {{end}}
761eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  },
762eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
763eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
764eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
765eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
7660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
7670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits a function/extension name without the "vk"/"VK_" prefix.
7680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
7690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
7700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "BaseName"}}
7710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{     if IsFunction $}}{{TrimPrefix "vk" $.Name}}
7720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $.Name "extension"}}{{TrimPrefix "VK_" (index $.Arguments 0)}}
7730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else}}{{Error "invalid use of BaseName"}}
7740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
7750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
7760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
7770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
7780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
7790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
7800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emits a comma-separated list of C parameter names for the given command.
7810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu-------------------------------------------------------------------------------
7820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
7830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "Arguments"}}
7840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
7850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
7860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}}
7870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
7880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
7890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
7900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
7910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
7920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
7930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
7940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsGloballyDispatched"}}
7950c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
7960c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Global")}}
7970c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    true
7980c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
7990c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8000c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8010c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8020c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8030c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8040c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emit "true" for supported functions that undergo table dispatch. Only global
8050c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  functions and functions handled in the loader top without calling into
8060c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  lower layers are not dispatched.
8070c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8080c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8090c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsInstanceDispatched"}}
8100c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
8110c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Instance")}}
8120c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    true
8130c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8140c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8150c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8160c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8170c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8180c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8190c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emit "true" for supported functions that can have device-specific dispatch.
8200c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8210c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8220c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsDeviceDispatched"}}
8230c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
8240c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if and (Macro "IsFunctionSupported" $) (eq (Macro "Vtbl" $) "Device")}}
8250c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    true
8260c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8270c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8280c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8290c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8300c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8310c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8320c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emit "true" if a function is core or from a supportable extension.
8330c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8340c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8350c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsFunctionSupported"}}
8360c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
8370c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if not (GetAnnotation $ "pfn")}}
8380c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{$ext := GetAnnotation $ "extension"}}
8390c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{if not $ext}}true
8400c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else if not (Macro "IsExtensionBlacklisted" $ext)}}true
8410c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
8420c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8430c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8440c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8450c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8460c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8470c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8480c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Decides whether a function should be exported from the Android Vulkan
8490c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  library. Functions in the core API and in loader extensions are exported.
8500c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8510c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8520c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsFunctionExported"}}
8530c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{AssertType $ "Function"}}
8540c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8550c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{if (Macro "IsFunctionSupported" $)}}
8560c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{$ext := GetAnnotation $ "extension"}}
8570c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{if $ext}}
8580c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      {{Macro "IsExtensionExported" $ext}}
8590c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{else}}
8600c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu      true
8610c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu    {{end}}
8620c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8630c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8640c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8650c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8660c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8670c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8680c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Emit "true" if an extension is unsupportable on Android.
8690c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8700c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8710c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsExtensionBlacklisted"}}
8720c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{$ext := index $.Arguments 0}}
8730c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{     if eq $ext "VK_KHR_display"}}true
8740c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_display_swapchain"}}true
8750c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_xlib_surface"}}true
8760c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_xcb_surface"}}true
8770c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_wayland_surface"}}true
8780c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_mir_surface"}}true
8790c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_win32_surface"}}true
8800c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8810c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
8820c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8830c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu
8840c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{/*
8850c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8860c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  Reports whether an extension is implemented entirely by the loader,
8870c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  so drivers should not enumerate it.
8880c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu------------------------------------------------------------------------------
8890c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu*/}}
8900c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{define "IsExtensionExported"}}
8910c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{$ext := index $.Arguments 0}}
8920c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{     if eq $ext "VK_KHR_surface"}}true
8930c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_swapchain"}}true
8940c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{else if eq $ext "VK_KHR_android_surface"}}true
8950c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu  {{end}}
8960c2032490b80178ec823bf22a7f5d08398851cc3Chia-I Wu{{end}}
897eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
898eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu
899eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{/*
900eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
901eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  Reports whether an extension is internal to the loader and drivers,
902eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  so the loader should not enumerate it.
903eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu------------------------------------------------------------------------------
904eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu*/}}
905eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{define "IsExtensionInternal"}}
906eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{$ext := index $.Arguments 0}}
907eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{     if eq $ext "VK_ANDROID_native_buffer"}}true
908eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu  {{end}}
909eb7db124e46da9a9210cf868353f5ea79502ffecChia-I Wu{{end}}
910