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