Forráskód Böngészése

Move Vulkan includes to a central godot_vulkan.h header

Also fixes Vulkan build problem with recent Clang.

(cherry picked from commit 146ba4106f459fd37d130a34da02ef737ac166e4)
Gergely Kis 11 hónapja
szülő
commit
01b7292495

+ 42 - 0
drivers/vulkan/godot_vulkan.h

@@ -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

+ 1 - 5
drivers/vulkan/rendering_device_vulkan.h

@@ -45,11 +45,7 @@
 #endif
 #include "vk_mem_alloc.h"
 
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
 
 class VulkanContext;
 

+ 1 - 5
drivers/vulkan/vulkan_context.h

@@ -40,11 +40,7 @@
 #include "servers/display_server.h"
 #include "servers/rendering/rendering_device.h"
 
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
 
 #include "vulkan_hooks.h"
 

+ 1 - 5
drivers/vulkan/vulkan_hooks.h

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

+ 1 - 5
platform/android/vulkan_context_android.cpp

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

+ 1 - 5
platform/ios/display_server_ios.h

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

+ 1 - 5
platform/ios/os_ios.mm

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

+ 1 - 5
platform/linuxbsd/x11/vulkan_context_x11.cpp

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

+ 1 - 5
platform/macos/vulkan_context_macos.mm

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

+ 1 - 5
platform/windows/vulkan_context_win.cpp

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

+ 5 - 6
thirdparty/vulkan/patches/VKEnumStringHelper-use-volk.patch → thirdparty/vulkan/patches/VKEnumStringHelper-use-godot-vulkan.patch

@@ -1,17 +1,16 @@
 diff --git a/thirdparty/vulkan/vk_enum_string_helper.h b/thirdparty/vulkan/vk_enum_string_helper.h
-index 65b3322c07..e8c61aaf15 100644
+index 062c3d9915..10df8e8115 100644
 --- a/thirdparty/vulkan/vk_enum_string_helper.h
 +++ b/thirdparty/vulkan/vk_enum_string_helper.h
-@@ -37,7 +37,11 @@
+@@ -28,8 +28,10 @@
+ #pragma warning( disable : 4065 )
  #endif
  
++#ifdef __cplusplus
  #include <string>
 -#include <vulkan/vulkan.h>
-+#ifdef USE_VOLK
-+    #include <volk.h>
-+#else
-+    #include <vulkan/vulkan.h>
 +#endif
++#include "drivers/vulkan/godot_vulkan.h"
  
  
  static inline const char* string_VkResult(VkResult input_value)

+ 7 - 9
thirdparty/vulkan/patches/VMA-use-volk.patch → thirdparty/vulkan/patches/VMA-use-godot-vulkan.patch

@@ -1,17 +1,15 @@
 diff --git a/thirdparty/vulkan/vk_mem_alloc.h b/thirdparty/vulkan/vk_mem_alloc.h
-index 44affc5ca4..d96f2dacc0 100644
+index 1add7278b0..1e03339ecf 100644
 --- a/thirdparty/vulkan/vk_mem_alloc.h
 +++ b/thirdparty/vulkan/vk_mem_alloc.h
-@@ -127,7 +127,11 @@ extern "C" {
+@@ -126,9 +126,7 @@ See documentation chapter: \ref statistics.
+ extern "C" {
  #endif
  
- #ifndef VULKAN_H_
+-#ifndef VULKAN_H_
 -    #include <vulkan/vulkan.h>
-+    #ifdef USE_VOLK
-+        #include <volk.h>
-+    #else
-+        #include <vulkan/vulkan.h>
-+    #endif
- #endif
+-#endif
++#include "drivers/vulkan/godot_vulkan.h"
  
  // Define this macro to declare maximum supported Vulkan version in format AAABBBCCC,
+ // where AAA = major, BBB = minor, CCC = patch.

+ 2 - 4
thirdparty/vulkan/vk_enum_string_helper.h

@@ -28,12 +28,10 @@
 #pragma warning( disable : 4065 )
 #endif
 
+#ifdef __cplusplus
 #include <string>
-#ifdef USE_VOLK
-    #include <volk.h>
-#else
-    #include <vulkan/vulkan.h>
 #endif
+#include "drivers/vulkan/godot_vulkan.h"
 
 
 static inline const char* string_VkResult(VkResult input_value)

+ 1 - 7
thirdparty/vulkan/vk_mem_alloc.h

@@ -126,13 +126,7 @@ See documentation chapter: \ref statistics.
 extern "C" {
 #endif
 
-#ifndef VULKAN_H_
-    #ifdef USE_VOLK
-        #include <volk.h>
-    #else
-        #include <vulkan/vulkan.h>
-    #endif
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
 
 // Define this macro to declare maximum supported Vulkan version in format AAABBBCCC,
 // where AAA = major, BBB = minor, CCC = patch.