blob: d0e665fbd85f6d153df7138083793879430a08a2 [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{{Macro "DefineGlobals" $}}
19{{$ | Macro "entry.cpp" | Reflow 4 | Write "entry.cpp"}}
20
21
22{{/*
23-------------------------------------------------------------------------------
24 Entry point
25-------------------------------------------------------------------------------
26*/}}
27{{define "entry.cpp"}}
28/*
29 * Copyright 2015 The Android Open Source Project
30 *
31 * Licensed under the Apache License, Version 2.0 (the "License");
32 * you may not use this file except in compliance with the License.
33 * You may obtain a copy of the License at
34 *
35 * http://www.apache.org/licenses/LICENSE-2.0
36 *
37 * Unless required by applicable law or agreed to in writing, software
38 * distributed under the License is distributed on an "AS IS" BASIS,
39 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40 * See the License for the specific language governing permissions and
41 * limitations under the License.
42 */
43
44// This file is generated. Do not edit manually!
45// To regenerate: $ apic template ../api/vulkan.api entry.cpp.tmpl
46// Requires apic from https://android.googlesource.com/platform/tools/gpu/.
47
48#include "loader.h"
49using namespace vulkan;
50
51// clang-format off
52
53namespace {
54 inline const InstanceVtbl& GetVtbl(VkInstance instance) {
55 return **reinterpret_cast<InstanceVtbl**>(instance);
56 }
57 inline const InstanceVtbl& GetVtbl(VkPhysicalDevice physicalDevice) {
58 return **reinterpret_cast<InstanceVtbl**>(physicalDevice);
59 }
60 inline const DeviceVtbl& GetVtbl(VkDevice device) {
61 return **reinterpret_cast<DeviceVtbl**>(device);
62 }
63 inline const DeviceVtbl& GetVtbl(VkQueue queue) {
64 return **reinterpret_cast<DeviceVtbl**>(queue);
65 }
66 inline const DeviceVtbl& GetVtbl(VkCmdBuffer cmdBuffer) {
67 return **reinterpret_cast<DeviceVtbl**>(cmdBuffer);
68 }
69} // namespace
70
71 {{range $f := AllCommands $}}
Jesse Hall1356b0d2015-11-23 17:24:58 -080072 {{if and (not (GetAnnotation $f "pfn")) (Macro "IsExportedEntry" $f)}}
Jesse Hall04f4f472015-08-16 19:51:04 -070073 __attribute__((visibility("default")))
74 {{if eq (Macro "IsSpecialEntry" $f.Name) "true"}}
75 {{Macro "EmitSpecialEntry" $f}}
76 {{else}}
77 {{Macro "EmitEntry" $f}}
78 {{end}}
79 {{end}}
80 {{end}}
Jesse Hallb1352bc2015-09-04 16:12:33 -070081
Jesse Hall04f4f472015-08-16 19:51:04 -070082{{end}}
83
84
85{{/*
86-------------------------------------------------------------------------------
Jesse Hall1356b0d2015-11-23 17:24:58 -080087 Decides whether an entrypoint should be exported from the Android Vulkan
88 library. Entrypoints in the core API and in mandatory extensions are
89 exported.
90-------------------------------------------------------------------------------
91*/}}
92{{define "IsExportedEntry"}}
93 {{AssertType $ "Function"}}
94 {{$ext := GetAnnotation $ "extension"}}
95 {{if $ext}}
96 {{$extval := index $ext.Arguments 0}}
97 {{if eq $extval "VK_EXT_KHR_surface"}}true
98 {{else if eq $extval "VK_EXT_KHR_swapchain"}}true
99 {{else if eq $extval "VK_EXT_KHR_android_surface"}}true{{end}}
100 {{else}}true{{end}}
101{{end}}
102
103
104{{/*
105-------------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -0700106 Decides whether an entrypoint needs special-case handling. Emits the string
107 "true" if so, nothing otherwise.
108-------------------------------------------------------------------------------
109*/}}
110{{define "IsSpecialEntry"}}
111 {{/* TODO: figure out how to do this in a cleaner or at least multi-line way */}}
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700112 {{if or (eq $ "vkGetInstanceProcAddr") (or (eq $ "vkGetDeviceProcAddr") (or (eq $ "vkGetDeviceQueue") (or (eq $ "vkCreateCommandBuffer") (eq $ "vkDestroyDevice"))))}}
Jesse Hall04f4f472015-08-16 19:51:04 -0700113 true
114 {{end}}
115{{end}}
116
Jesse Hall1356b0d2015-11-23 17:24:58 -0800117
Jesse Hall04f4f472015-08-16 19:51:04 -0700118{{/*
119-------------------------------------------------------------------------------
120 Emits the entrypoint definition for the specified command, which always
121 dispatches statically because the function requires special-case handling.
122-------------------------------------------------------------------------------
123*/}}
124{{define "EmitSpecialEntry"}}
125 {{AssertType $ "Function"}}
126
127 {{Node "Type" $.Return}} {{Macro "FunctionName" $}}({{Macro "Parameters" $}}) {
128 {{if not (IsVoid $.Return.Type)}}return §{{end}}
129 vulkan::{{TrimPrefix "vk" $.Name}}({{Macro "Arguments" $}});
130 }
131
132{{end}}
133
134
135{{/*
136-------------------------------------------------------------------------------
137 Emits the entrypoint definition for the specified command. If the first
138 parameter is a handle to dispatchable object, it dispatches the call through
139 the object's function table. Otherwise, it dispatches statically.
140-------------------------------------------------------------------------------
141*/}}
142{{define "EmitEntry"}}
143 {{AssertType $ "Function"}}
144
145 {{Node "Type" $.Return}} {{Macro "FunctionName" $}}({{Macro "Parameters" $}}) {
146 {{if not (IsVoid $.Return.Type)}}return §{{end}}
147 {{Macro "Dispatch" $}}{{TrimPrefix "vk" $.Name}}({{Macro "Arguments" $}});
148 }
149
150{{end}}
151
152
153{{/*
154-------------------------------------------------------------------------------
155 Emit the dispatch lookup for a function based on its first parameter.
156-------------------------------------------------------------------------------
157*/}}
158{{define "Dispatch#VkInstance" }}GetVtbl({{$.Node.Name}}).{{end}}
159{{define "Dispatch#VkPhysicalDevice"}}GetVtbl({{$.Node.Name}}).{{end}}
160{{define "Dispatch#VkDevice" }}GetVtbl({{$.Node.Name}}).{{end}}
161{{define "Dispatch#VkQueue" }}GetVtbl({{$.Node.Name}}).{{end}}
162{{define "Dispatch#VkCmdBuffer" }}GetVtbl({{$.Node.Name}}).{{end}}
163{{define "Dispatch_Default" }}vulkan::{{end}}
164{{define "Dispatch"}}
165 {{AssertType $ "Function"}}
166
167 {{range $i, $p := $.CallParameters}}
168 {{if not $i}}{{Node "Dispatch" $p}}{{end}}
169 {{end}}
170{{end}}
171
172
173{{/*
174-------------------------------------------------------------------------------
175 Emits a comma-separated list of C parameter names for the given command.
176-------------------------------------------------------------------------------
177*/}}
178{{define "Arguments"}}
179 {{AssertType $ "Function"}}
180
181 {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}}
182{{end}}