blob: ce155172e9098e578b9d5c4863321d16415fad2f [file] [log] [blame]
{{/*
* Copyright 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/}}
{{Include "../api/templates/vulkan_common.tmpl"}}
{{Global "clang-format" (Strings "clang-format" "-style=file")}}
{{Macro "DefineGlobals" $}}
{{$ | Macro "null_driver_gen.h" | Format (Global "clang-format") | Write "null_driver_gen.h" }}
{{$ | Macro "null_driver_gen.cpp" | Format (Global "clang-format") | Write "null_driver_gen.cpp"}}
{{/*
-------------------------------------------------------------------------------
null_driver_gen.h
-------------------------------------------------------------------------------
*/}}
{{define "null_driver_gen.h"}}
/*
•* Copyright 2015 The Android Open Source Project
•*
•* Licensed under the Apache License, Version 2.0 (the "License");
•* you may not use this file except in compliance with the License.
•* You may obtain a copy of the License at
•*
•* http://www.apache.org/licenses/LICENSE-2.0
•*
•* Unless required by applicable law or agreed to in writing, software
•* distributed under the License is distributed on an "AS IS" BASIS,
•* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
•* See the License for the specific language governing permissions and
•* limitations under the License.
•*/
// WARNING: This file is generated. See ../README.md for instructions.
#ifndef NULLDRV_NULL_DRIVER_H
#define NULLDRV_NULL_DRIVER_H 1
#include <vulkan/vk_android_native_buffer.h>
#include <vulkan/vulkan.h>
namespace null_driver
PFN_vkVoidFunction GetGlobalProcAddr(const char* name);
PFN_vkVoidFunction GetInstanceProcAddr(const char* name);
// clang-format off
{{range $f := AllCommands $}}
{{if (Macro "IsDriverFunction" $f)}}
VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}});
{{end}}
{{end}}
VKAPI_ATTR VkResult GetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
VKAPI_ATTR VkResult AcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
VKAPI_ATTR VkResult QueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
// clang-format on
»} // namespace null_driver
#endif // NULLDRV_NULL_DRIVER_H
¶{{end}}
{{/*
-------------------------------------------------------------------------------
null_driver_gen.cpp
-------------------------------------------------------------------------------
*/}}
{{define "null_driver_gen.cpp"}}
/*
•* Copyright 2015 The Android Open Source Project
•*
•* Licensed under the Apache License, Version 2.0 (the "License");
•* you may not use this file except in compliance with the License.
•* You may obtain a copy of the License at
•*
•* http://www.apache.org/licenses/LICENSE-2.0
•*
•* Unless required by applicable law or agreed to in writing, software
•* distributed under the License is distributed on an "AS IS" BASIS,
•* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
•* See the License for the specific language governing permissions and
•* limitations under the License.
•*/
// WARNING: This file is generated. See ../README.md for instructions.
#include "null_driver_gen.h"
#include <algorithm>
using namespace null_driver;
namespace {
struct NameProc {
const char* name;
PFN_vkVoidFunction proc;
};
PFN_vkVoidFunction Lookup(const char* name,
const NameProc* begin,
const NameProc* end) {
const auto& entry = std::lower_bound(
begin, end, name,
[](const NameProc& e, const char* n) { return strcmp(e.name, n) < 0; });
if (entry == end || strcmp(entry->name, name) != 0)
return nullptr;
return entry->proc;
}
template <size_t N>
PFN_vkVoidFunction Lookup(const char* name, const NameProc (&procs)[N]) {
return Lookup(name, procs, procs + N);
}
const NameProc kGlobalProcs[] =
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
{{if and (Macro "IsDriverFunction" $f) (eq (Macro "Vtbl" $f) "Global")}}
{"{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
static_cast<{{Macro "FunctionPtrName" $f}}>(§
{{Macro "BaseName" $f}}))},
{{end}}
{{end}}
// clang-format on
»};
const NameProc kInstanceProcs[] =
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
{{if (Macro "IsDriverFunction" $f)}}
{"{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
static_cast<{{Macro "FunctionPtrName" $f}}>(§
{{Macro "BaseName" $f}}))},
{{end}}
{{end}}
// clang-format on
»};
} // namespace
namespace null_driver {
PFN_vkVoidFunction GetGlobalProcAddr(const char* name) {
return Lookup(name, kGlobalProcs);
}
PFN_vkVoidFunction GetInstanceProcAddr(const char* name)
return Lookup(name, kInstanceProcs);
»}
} // namespace null_driver
{{end}}
{{/*
-------------------------------------------------------------------------------
Emits a function name without the "vk" prefix.
-------------------------------------------------------------------------------
*/}}
{{define "BaseName"}}
{{AssertType $ "Function"}}
{{TrimPrefix "vk" $.Name}}
{{end}}
{{/*
------------------------------------------------------------------------------
Emits 'true' if the API function is implemented by the driver.
------------------------------------------------------------------------------
*/}}
{{define "IsDriverFunction"}}
{{AssertType $ "Function"}}
{{if not (GetAnnotation $ "pfn")}}
{{$ext := GetAnnotation $ "extension"}}
{{if $ext}}
{{Macro "IsDriverExtension" $ext}}
{{else}}
true
{{end}}
{{end}}
{{end}}
{{/*
------------------------------------------------------------------------------
Reports whether an extension is implemented by the driver.
------------------------------------------------------------------------------
*/}}
{{define "IsDriverExtension"}}
{{$ext := index $.Arguments 0}}
{{ if eq $ext "VK_ANDROID_native_buffer"}}true
{{else if eq $ext "VK_EXT_debug_report"}}true
{{else if eq $ext "VK_KHR_get_physical_device_properties2"}}true
{{end}}
{{end}}