2016-08-13 12:57:50 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define VK_NO_PROTOTYPES
|
|
|
|
|
2020-08-19 06:25:57 +00:00
|
|
|
#if defined(_WIN32)
|
2016-08-13 12:57:50 +00:00
|
|
|
#define VK_USE_PLATFORM_WIN32_KHR
|
2018-10-24 04:47:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_X11)
|
2016-08-13 12:57:50 +00:00
|
|
|
#define VK_USE_PLATFORM_XLIB_KHR
|
2018-10-24 04:47:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(ANDROID)
|
2016-08-13 12:57:50 +00:00
|
|
|
#define VK_USE_PLATFORM_ANDROID_KHR
|
2018-10-24 04:47:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
2020-04-07 08:49:40 +00:00
|
|
|
#define VK_USE_PLATFORM_METAL_EXT
|
2016-08-13 12:57:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "vulkan/vulkan.h"
|
|
|
|
|
2023-05-31 22:05:06 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2019-09-30 15:10:08 +00:00
|
|
|
// Currently, exclusive fullscreen is only supported on Windows.
|
|
|
|
#if defined(WIN32)
|
|
|
|
#define SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN 1
|
|
|
|
#endif
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
// We abuse the preprocessor here to only need to specify function names once.
|
|
|
|
#define VULKAN_MODULE_ENTRY_POINT(name, required) extern PFN_##name name;
|
|
|
|
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) extern PFN_##name name;
|
|
|
|
#define VULKAN_DEVICE_ENTRY_POINT(name, required) extern PFN_##name name;
|
|
|
|
#include "VideoBackends/Vulkan/VulkanEntryPoints.inl"
|
|
|
|
#undef VULKAN_DEVICE_ENTRY_POINT
|
|
|
|
#undef VULKAN_INSTANCE_ENTRY_POINT
|
|
|
|
#undef VULKAN_MODULE_ENTRY_POINT
|
|
|
|
|
2022-10-07 21:36:16 +00:00
|
|
|
// Include vma allocator globally since including it before the vulkan headers causes
|
|
|
|
// errors
|
|
|
|
#ifdef _MSVC_LANG
|
|
|
|
#pragma warning(push, 4)
|
|
|
|
#pragma warning(disable : 4189) // local variable is initialized but not referenced
|
2024-06-19 06:18:29 +00:00
|
|
|
#pragma warning(disable : 4505) // function with internal linkage is not referenced
|
2022-10-07 21:36:16 +00:00
|
|
|
|
|
|
|
#endif // #ifdef _MSVC_LANG
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
2024-06-19 06:18:29 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wunused-function"
|
2023-01-29 14:11:51 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wnullability-completeness"
|
2022-10-07 21:36:16 +00:00
|
|
|
#endif // #ifdef __clang__
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
2024-06-19 06:18:29 +00:00
|
|
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
2022-10-07 21:36:16 +00:00
|
|
|
#endif // #ifdef __GNUC__
|
|
|
|
|
|
|
|
#define VMA_VULKAN_VERSION 1001000
|
|
|
|
#define VMA_STATIC_VULKAN_FUNCTIONS 1
|
|
|
|
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
|
|
|
|
#undef VK_NO_PROTOTYPES
|
|
|
|
#include "vk_mem_alloc.h"
|
|
|
|
|
|
|
|
#ifdef _MSVC_LANG
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif // #ifdef _MSVC_LANG
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif // #ifdef __clang__
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif // #ifdef __GNUC__
|
|
|
|
|
2021-10-21 19:11:07 +00:00
|
|
|
#include "Common/Logging/Log.h"
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
namespace Vulkan
|
|
|
|
{
|
2023-05-31 22:05:06 +00:00
|
|
|
bool LoadVulkanLibrary(bool force_system_library = false);
|
2016-08-13 12:57:50 +00:00
|
|
|
bool LoadVulkanInstanceFunctions(VkInstance instance);
|
|
|
|
bool LoadVulkanDeviceFunctions(VkDevice device);
|
|
|
|
void UnloadVulkanLibrary();
|
|
|
|
|
2023-05-31 22:05:06 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
bool SupportsCustomDriver();
|
|
|
|
#endif
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
const char* VkResultToString(VkResult res);
|
2024-08-28 21:42:54 +00:00
|
|
|
void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, const int line,
|
|
|
|
VkResult res, const char* msg);
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2022-10-12 03:10:32 +00:00
|
|
|
#define LOG_VULKAN_ERROR(res, msg) \
|
2024-08-28 21:42:54 +00:00
|
|
|
LogVulkanResult(Common::Log::LogLevel::LERROR, __func__, __LINE__, res, msg)
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
} // namespace Vulkan
|