blob: 4e671e532c318238cecd9cc5d16acc86d98cd8e2 [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 $}}
72 {{if not (GetAnnotation $f "pfn")}}
73 __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
82{{/* Extension functions aren't in the API file yet, so must be special-cased */}}
83__attribute__((visibility("default")))
84VkResult vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, const VkSurfaceDescriptionKHR* pSurfaceDescription, VkBool32* pSupported) {
85 return GetVtbl(physicalDevice).GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, pSurfaceDescription, pSupported);
86}
87
88__attribute__((visibility("default")))
89VkResult vkGetSurfacePropertiesKHR(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, VkSurfacePropertiesKHR* pSurfaceProperties) {
90 return GetVtbl(device).GetSurfacePropertiesKHR(device, pSurfaceDescription, pSurfaceProperties);
91}
92
93__attribute__((visibility("default")))
94VkResult vkGetSurfaceFormatsKHR(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, uint32_t* pCount, VkSurfaceFormatKHR* pSurfaceFormats) {
95 return GetVtbl(device).GetSurfaceFormatsKHR(device, pSurfaceDescription, pCount, pSurfaceFormats);
96}
97
98__attribute__((visibility("default")))
99VkResult vkGetSurfacePresentModesKHR(VkDevice device, const VkSurfaceDescriptionKHR* pSurfaceDescription, uint32_t* pCount, VkPresentModeKHR* pPresentModes) {
100 return GetVtbl(device).GetSurfacePresentModesKHR(device, pSurfaceDescription, pCount, pPresentModes);
101}
102
103__attribute__((visibility("default")))
104VkResult vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, VkSwapchainKHR* pSwapchain) {
105 return GetVtbl(device).CreateSwapchainKHR(device, pCreateInfo, pSwapchain);
106}
107
108__attribute__((visibility("default")))
109VkResult vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain) {
110 return GetVtbl(device).DestroySwapchainKHR(device, swapchain);
111}
112
113__attribute__((visibility("default")))
114VkResult vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pCount, VkImage* pSwapchainImages) {
115 return GetVtbl(device).GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages);
116}
117
118__attribute__((visibility("default")))
119VkResult vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, uint32_t* pImageIndex) {
120 return GetVtbl(device).AcquireNextImageKHR(device, swapchain, timeout, semaphore, pImageIndex);
121}
122
123__attribute__((visibility("default")))
124VkResult vkQueuePresentKHR(VkQueue queue, VkPresentInfoKHR* pPresentInfo) {
125 return GetVtbl(queue).QueuePresentKHR(queue, pPresentInfo);
126}
127
Jesse Hall04f4f472015-08-16 19:51:04 -0700128{{end}}
129
130
131{{/*
132-------------------------------------------------------------------------------
133 Decides whether an entrypoint needs special-case handling. Emits the string
134 "true" if so, nothing otherwise.
135-------------------------------------------------------------------------------
136*/}}
137{{define "IsSpecialEntry"}}
138 {{/* TODO: figure out how to do this in a cleaner or at least multi-line way */}}
Jesse Hallc7a6eb52015-08-31 12:52:03 -0700139 {{if or (eq $ "vkGetInstanceProcAddr") (or (eq $ "vkGetDeviceProcAddr") (or (eq $ "vkGetDeviceQueue") (or (eq $ "vkCreateCommandBuffer") (eq $ "vkDestroyDevice"))))}}
Jesse Hall04f4f472015-08-16 19:51:04 -0700140 true
141 {{end}}
142{{end}}
143
144{{/*
145-------------------------------------------------------------------------------
146 Emits the entrypoint definition for the specified command, which always
147 dispatches statically because the function requires special-case handling.
148-------------------------------------------------------------------------------
149*/}}
150{{define "EmitSpecialEntry"}}
151 {{AssertType $ "Function"}}
152
153 {{Node "Type" $.Return}} {{Macro "FunctionName" $}}({{Macro "Parameters" $}}) {
154 {{if not (IsVoid $.Return.Type)}}return §{{end}}
155 vulkan::{{TrimPrefix "vk" $.Name}}({{Macro "Arguments" $}});
156 }
157
158{{end}}
159
160
161{{/*
162-------------------------------------------------------------------------------
163 Emits the entrypoint definition for the specified command. If the first
164 parameter is a handle to dispatchable object, it dispatches the call through
165 the object's function table. Otherwise, it dispatches statically.
166-------------------------------------------------------------------------------
167*/}}
168{{define "EmitEntry"}}
169 {{AssertType $ "Function"}}
170
171 {{Node "Type" $.Return}} {{Macro "FunctionName" $}}({{Macro "Parameters" $}}) {
172 {{if not (IsVoid $.Return.Type)}}return §{{end}}
173 {{Macro "Dispatch" $}}{{TrimPrefix "vk" $.Name}}({{Macro "Arguments" $}});
174 }
175
176{{end}}
177
178
179{{/*
180-------------------------------------------------------------------------------
181 Emit the dispatch lookup for a function based on its first parameter.
182-------------------------------------------------------------------------------
183*/}}
184{{define "Dispatch#VkInstance" }}GetVtbl({{$.Node.Name}}).{{end}}
185{{define "Dispatch#VkPhysicalDevice"}}GetVtbl({{$.Node.Name}}).{{end}}
186{{define "Dispatch#VkDevice" }}GetVtbl({{$.Node.Name}}).{{end}}
187{{define "Dispatch#VkQueue" }}GetVtbl({{$.Node.Name}}).{{end}}
188{{define "Dispatch#VkCmdBuffer" }}GetVtbl({{$.Node.Name}}).{{end}}
189{{define "Dispatch_Default" }}vulkan::{{end}}
190{{define "Dispatch"}}
191 {{AssertType $ "Function"}}
192
193 {{range $i, $p := $.CallParameters}}
194 {{if not $i}}{{Node "Dispatch" $p}}{{end}}
195 {{end}}
196{{end}}
197
198
199{{/*
200-------------------------------------------------------------------------------
201 Emits a comma-separated list of C parameter names for the given command.
202-------------------------------------------------------------------------------
203*/}}
204{{define "Arguments"}}
205 {{AssertType $ "Function"}}
206
207 {{ForEach $.CallParameters "ParameterName" | JoinWith ", "}}
208{{end}}