1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Move Vulkan includes to a central godot_vulkan.h header

Also fixes Vulkan build problem with recent Clang.

(cherry picked from commit 146ba4106f)
This commit is contained in:
Gergely Kis
2024-09-26 21:46:48 +02:00
committed by Rémi Verschelde
parent 369b981a75
commit be302e7957
12 changed files with 60 additions and 57 deletions

View File

@@ -0,0 +1,42 @@
/**************************************************************************/
/* godot_vulkan.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GODOT_VULKAN_H
#define GODOT_VULKAN_H
#ifdef USE_VOLK
#include <volk.h>
#else
#include <stdint.h>
#define VK_NO_STDINT_H
#include <vulkan/vulkan.h>
#endif
#endif // GODOT_VULKAN_H

View File

@@ -31,11 +31,7 @@
#ifndef VULKAN_HOOKS_H #ifndef VULKAN_HOOKS_H
#define VULKAN_HOOKS_H #define VULKAN_HOOKS_H
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
class VulkanHooks { class VulkanHooks {
public: public:

View File

@@ -32,11 +32,7 @@
#ifdef VULKAN_ENABLED #ifdef VULKAN_ENABLED
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
const char *VulkanContextAndroid::_get_platform_surface_extension() const { const char *VulkanContextAndroid::_get_platform_surface_extension() const {
return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME; return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;

View File

@@ -40,11 +40,7 @@
#include "drivers/vulkan/rendering_device_vulkan.h" #include "drivers/vulkan/rendering_device_vulkan.h"
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
#endif // VULKAN_ENABLED #endif // VULKAN_ENABLED
#if defined(GLES3_ENABLED) #if defined(GLES3_ENABLED)

View File

@@ -54,11 +54,7 @@
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#import <QuartzCore/CAMetalLayer.h> #import <QuartzCore/CAMetalLayer.h>
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
#endif #endif
// Initialization order between compilation units is not guaranteed, // Initialization order between compilation units is not guaranteed,

View File

@@ -32,11 +32,7 @@
#include "vulkan_context_x11.h" #include "vulkan_context_x11.h"
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
const char *VulkanContextX11::_get_platform_surface_extension() const { const char *VulkanContextX11::_get_platform_surface_extension() const {
return VK_KHR_XLIB_SURFACE_EXTENSION_NAME; return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;

View File

@@ -32,11 +32,7 @@
#ifdef VULKAN_ENABLED #ifdef VULKAN_ENABLED
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
const char *VulkanContextMacOS::_get_platform_surface_extension() const { const char *VulkanContextMacOS::_get_platform_surface_extension() const {
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME; return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;

View File

@@ -32,11 +32,7 @@
#include "vulkan_context_win.h" #include "vulkan_context_win.h"
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
const char *VulkanContextWindows::_get_platform_surface_extension() const { const char *VulkanContextWindows::_get_platform_surface_extension() const {
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME; return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;

View File

@@ -1,17 +1,16 @@
diff --git a/thirdparty/vulkan/vk_enum_string_helper.h b/thirdparty/vulkan/vk_enum_string_helper.h diff --git a/thirdparty/vulkan/vk_enum_string_helper.h b/thirdparty/vulkan/vk_enum_string_helper.h
index 8c77dd3ee5..be968c091d 100644 index 8c77dd3ee5..74f49a6430 100644
--- a/thirdparty/vulkan/vk_enum_string_helper.h --- a/thirdparty/vulkan/vk_enum_string_helper.h
+++ b/thirdparty/vulkan/vk_enum_string_helper.h +++ b/thirdparty/vulkan/vk_enum_string_helper.h
@@ -23,7 +23,11 @@ @@ -22,8 +22,10 @@
****************************************************************************/
// NOLINTBEGIN // NOLINTBEGIN
#pragma once #pragma once
+#ifdef __cplusplus
#include <string> #include <string>
-#include <vulkan/vulkan.h> -#include <vulkan/vulkan.h>
+#ifdef USE_VOLK
+ #include <volk.h>
+#else
+ #include <vulkan/vulkan.h>
+#endif +#endif
+#include "drivers/vulkan/godot_vulkan.h"
static inline bool IsDuplicatePnext(VkStructureType input_value) { static inline bool IsDuplicatePnext(VkStructureType input_value) {
switch (input_value) { switch (input_value) {

View File

@@ -1,17 +1,13 @@
diff --git a/thirdparty/vulkan/vk_mem_alloc.h b/thirdparty/vulkan/vk_mem_alloc.h diff --git a/thirdparty/vulkan/vk_mem_alloc.h b/thirdparty/vulkan/vk_mem_alloc.h
index fa4298b23c..a29bf6dfb6 100644 index fa4298b23c..146895fd90 100644
--- a/thirdparty/vulkan/vk_mem_alloc.h --- a/thirdparty/vulkan/vk_mem_alloc.h
+++ b/thirdparty/vulkan/vk_mem_alloc.h +++ b/thirdparty/vulkan/vk_mem_alloc.h
@@ -126,7 +126,11 @@ See documentation chapter: \ref statistics. @@ -126,7 +126,7 @@ See documentation chapter: \ref statistics.
extern "C" { extern "C" {
#endif #endif
-#include <vulkan/vulkan.h> -#include <vulkan/vulkan.h>
+#ifdef USE_VOLK +#include "drivers/vulkan/godot_vulkan.h"
+ #include <volk.h>
+#else
+ #include <vulkan/vulkan.h>
+#endif
#if !defined(VMA_VULKAN_VERSION) #if !defined(VMA_VULKAN_VERSION)
#if defined(VK_VERSION_1_3) #if defined(VK_VERSION_1_3)

View File

@@ -22,12 +22,10 @@
****************************************************************************/ ****************************************************************************/
// NOLINTBEGIN // NOLINTBEGIN
#pragma once #pragma once
#ifdef __cplusplus
#include <string> #include <string>
#ifdef USE_VOLK
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif #endif
#include "drivers/vulkan/godot_vulkan.h"
static inline bool IsDuplicatePnext(VkStructureType input_value) { static inline bool IsDuplicatePnext(VkStructureType input_value) {
switch (input_value) { switch (input_value) {

View File

@@ -126,11 +126,7 @@ See documentation chapter: \ref statistics.
extern "C" { extern "C" {
#endif #endif
#ifdef USE_VOLK #include "drivers/vulkan/godot_vulkan.h"
#include <volk.h>
#else
#include <vulkan/vulkan.h>
#endif
#if !defined(VMA_VULKAN_VERSION) #if !defined(VMA_VULKAN_VERSION)
#if defined(VK_VERSION_1_3) #if defined(VK_VERSION_1_3)