blob: 03a3d96b058ad2a430939608e658fe4294167df8 [file] [log] [blame]
Jesse Hall04f4f472015-08-16 19:51:04 -07001{{Include "../api/templates/vulkan_common.tmpl"}}
2{{Global "clang-format" (Strings "clang-format" "-style=file")}}
3{{Macro "DefineGlobals" $}}
4{{$ | Macro "null_driver_gen.cpp" | Format (Global "clang-format") | Write "null_driver_gen.cpp"}}
5
6
7{{/*
8-------------------------------------------------------------------------------
9 Entry point
10-------------------------------------------------------------------------------
11*/}}
12{{define "null_driver_gen.cpp"}}
13/*
14 * Copyright 2015 The Android Open Source Project
15 *
16 * Licensed under the Apache License, Version 2.0 (the "License");
17 * you may not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29// This file is generated. Do not edit manually!
30// To regenerate: $ apic template ../api/vulkan.api null_driver_gen.cpp.tmpl
31// Requires apic from https://android.googlesource.com/platform/tools/gpu/.
32
33#include <algorithm>
34#include "null_driver.h"
35
36using namespace null_driver;
37
38namespace {
39
40struct NameProcEntry {
41 const char* name;
42 PFN_vkVoidFunction proc;
43};
44
45template <size_t N>
46PFN_vkVoidFunction LookupProcAddr(const NameProcEntry (&table)[N], const char* name) {
47 auto entry = std::lower_bound(
48 table, table + N, name,
49 [](const NameProcEntry& e, const char* n) { return strcmp(e.name, n) < 0; });
50 if (entry != (table + N) && strcmp(entry->name, name) == 0)
51 return entry->proc;
52 return nullptr;
53}
54
55const NameProcEntry kInstanceProcTbl[] =
56 // clang-format off
57 {{range $f := SortBy (AllCommands $) "FunctionName"}}
58 {{if eq (Macro "Vtbl" $f) "Instance"}}
59 {"{{Macro "FunctionName" $f}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "FunctionNameNoPrefix" $f}})},
60 {{end}}
61 {{end}}
62 // clang-format on
63»};
64
65const NameProcEntry kDeviceProcTbl[] =
66 // clang-format off
67 {{range $f := SortBy (AllCommands $) "FunctionName"}}
68 {{if eq (Macro "Vtbl" $f) "Device"}}
69 {"{{Macro "FunctionName" $f}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "FunctionNameNoPrefix" $f}})},
70 {{end}}
71 {{end}}
72 // clang-format on
73»};
74
75} // namespace
76
77namespace null_driver {
78
79PFN_vkVoidFunction LookupInstanceProcAddr(const char* name) {
80 return LookupProcAddr(kInstanceProcTbl, name);
81}
82
83PFN_vkVoidFunction LookupDeviceProcAddr(const char* name) {
84 return LookupProcAddr(kDeviceProcTbl, name);
85}
86
87} // namespace null_driver
88
89{{end}}
90
91
92{{/*
93-------------------------------------------------------------------------------
94 Emits the name of a function without the "vk" prefix.
95-------------------------------------------------------------------------------
96*/}}
97{{define "FunctionNameNoPrefix"}}{{AssertType $ "Function"}}{{TrimPrefix "vk" $.Name}}{{end}}