mirror of https://github.com/encounter/SDL.git
vulkan: Include a copy of vulkan.h and vk_platform.h.
Now we can provide Vulkan support in the build even if the build box doesn't have a Vulkan SDK, since we dynamically link to the library anyhow.
This commit is contained in:
parent
803fd6d526
commit
c722e58d1f
|
@ -329,10 +329,6 @@ dep_option(VIDEO_VULKAN "Enable Vulkan surface creation" ON "ANDROID OR A
|
|||
set_option(VIDEO_KMSDRM "Use KMS DRM video driver" ${UNIX_SYS})
|
||||
dep_option(KMSDRM_SHARED "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
|
||||
|
||||
if(VIDEO_VULKAN)
|
||||
set(VULKAN_SDK $ENV{VULKAN_SDK} CACHE PATH "Location of Vulkan headers' grandparent, e.g. /foo when headers are in /foo/include/vulkan.")
|
||||
endif()
|
||||
|
||||
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
|
||||
# The options below are for compatibility to configure's default behaviour.
|
||||
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
||||
|
@ -874,8 +870,6 @@ if(ANDROID)
|
|||
if(NOT VULKAN_PASSED_ANDROID_CHECKS)
|
||||
set(VIDEO_VULKAN OFF)
|
||||
message(STATUS "Vulkan doesn't work on this configuration")
|
||||
else()
|
||||
CheckVulkanHeaders()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -1041,8 +1035,6 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
|
|||
endif()
|
||||
|
||||
check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
|
||||
|
||||
CheckVulkanHeaders()
|
||||
endif()
|
||||
|
||||
if(INPUT_TSLIB)
|
||||
|
@ -1301,8 +1293,6 @@ elseif(WINDOWS)
|
|||
set(SDL_VIDEO_RENDER_OGL_ES2 1)
|
||||
set(HAVE_VIDEO_OPENGLES TRUE)
|
||||
endif()
|
||||
|
||||
CheckVulkanHeaders()
|
||||
endif()
|
||||
|
||||
if(SDL_JOYSTICK)
|
||||
|
@ -1445,12 +1435,9 @@ elseif(APPLE)
|
|||
|
||||
# Actually load the frameworks at the end so we don't duplicate include.
|
||||
if (VIDEO_VULKAN)
|
||||
CheckVulkanHeaders()
|
||||
if(HAVE_VULKAN_H)
|
||||
find_library(QUARTZCORE QuartzCore)
|
||||
list(APPEND EXTRA_LIBS ${QUARTZCORE})
|
||||
endif()
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREVIDEO)
|
||||
find_library(COREVIDEO CoreVideo)
|
||||
list(APPEND EXTRA_LIBS ${COREVIDEO})
|
||||
|
@ -1530,7 +1517,7 @@ elseif(HAIKU)
|
|||
CheckPTHREAD()
|
||||
endif()
|
||||
|
||||
if(VIDEO_VULKAN AND HAVE_VULKAN_H AND (NOT APPLE OR QUARTZCORE))
|
||||
if(VIDEO_VULKAN AND (NOT APPLE OR QUARTZCORE))
|
||||
set(SDL_VIDEO_VULKAN_SURFACE 1)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -1153,25 +1153,6 @@ macro(CheckRPI)
|
|||
endif(VIDEO_RPI)
|
||||
endmacro(CheckRPI)
|
||||
|
||||
macro(CheckVulkanHeaders)
|
||||
if(VIDEO_VULKAN)
|
||||
# ${VULKAN_SDK} could be unset during the first configure run with
|
||||
# cmake-gui resulting in vulkan.h not being found. If it's been
|
||||
# subsequently changed, unset is necessary to ensure check is run again.
|
||||
unset(HAVE_VULKAN_H CACHE)
|
||||
# Prefer ${VULKAN_SDK} header
|
||||
set(CMAKE_REQUIRED_INCLUDES "${VULKAN_SDK}/include")
|
||||
check_include_file("vulkan/vulkan.h" HAVE_VULKAN_H)
|
||||
if(HAVE_VULKAN_H)
|
||||
list(APPEND EXTRA_CFLAGS "-I${VULKAN_SDK}/include")
|
||||
else()
|
||||
# Check system includes.
|
||||
unset(HAVE_VULKAN_H CACHE)
|
||||
check_include_file("vulkan/vulkan.h" HAVE_VULKAN_H)
|
||||
endif()
|
||||
endif()
|
||||
endmacro(CheckVulkanHeaders)
|
||||
|
||||
# Requires:
|
||||
# - EGL
|
||||
# - PkgCheckModules
|
||||
|
|
|
@ -21915,7 +21915,6 @@ fi
|
|||
|
||||
CheckVulkan()
|
||||
{
|
||||
have_vulkan_hdr=no
|
||||
if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
|
||||
case "$host" in
|
||||
*-*-androideabi*)
|
||||
|
@ -21955,30 +21954,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Sorry, Vulkan does not work on this configuration." >&5
|
||||
$as_echo "$as_me: WARNING: Sorry, Vulkan does not work on this configuration." >&2;}
|
||||
fi
|
||||
fi
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
vsdk_include_dir="${VULKAN_SDK}/include"
|
||||
vulkan_header="vulkan/vulkan.h"
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
|
||||
as_ac_Header=`$as_echo "ac_cv_header_$vulkan_header" | $as_tr_sh`
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "$vulkan_header" "$as_ac_Header" "$ac_includes_default"
|
||||
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
|
||||
have_vulkan_hdr=yes
|
||||
else
|
||||
have_vulkan_hdr=no
|
||||
fi
|
||||
|
||||
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
fi
|
||||
fi
|
||||
if test x$have_vulkan_hdr = xyes; then
|
||||
# vulkan.h has been found in either $VULKAN_SDK/include or along the
|
||||
# the standard include path. Unfortunately there seems no easy
|
||||
# way to find out which, so...
|
||||
if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$vsdk_include_dir"
|
||||
fi
|
||||
|
||||
$as_echo "#define SDL_VIDEO_VULKAN_SURFACE 1" >>confdefs.h
|
||||
|
||||
|
@ -24272,7 +24249,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
|
|||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
|
||||
if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
fi
|
||||
;;
|
||||
|
@ -24362,7 +24339,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
|
|||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
|
||||
if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
fi
|
||||
;;
|
||||
|
|
23
configure.in
23
configure.in
|
@ -2409,7 +2409,6 @@ AC_HELP_STRING([--enable-video-vulkan], [include Vulkan surface support [[defaul
|
|||
dnl Find Vulkan Header
|
||||
CheckVulkan()
|
||||
{
|
||||
have_vulkan_hdr=no
|
||||
if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
|
||||
case "$host" in
|
||||
*-*-androideabi*)
|
||||
|
@ -2434,24 +2433,8 @@ CheckVulkan()
|
|||
# I put this in the AC_TRY_COMPILE.
|
||||
AC_MSG_WARN([Sorry, Vulkan does not work on this configuration.])
|
||||
fi
|
||||
fi
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
vsdk_include_dir="${VULKAN_SDK}/include"
|
||||
vulkan_header="vulkan/vulkan.h"
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
|
||||
AC_CHECK_HEADER($vulkan_header,
|
||||
have_vulkan_hdr=yes,
|
||||
have_vulkan_hdr=no)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
fi
|
||||
fi
|
||||
if test x$have_vulkan_hdr = xyes; then
|
||||
# vulkan.h has been found in either $VULKAN_SDK/include or along the
|
||||
# the standard include path. Unfortunately there seems no easy
|
||||
# way to find out which, so...
|
||||
if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$vsdk_include_dir"
|
||||
fi
|
||||
AC_DEFINE(SDL_VIDEO_VULKAN_SURFACE, 1, [ ])
|
||||
SUMMARY_video="${SUMMARY_video} vulkan"
|
||||
fi
|
||||
|
@ -3680,7 +3663,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
|
|||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
|
||||
if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
fi
|
||||
;;
|
||||
|
@ -3758,7 +3741,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
|
|||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
|
||||
if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
|
||||
if test x$enable_video_vulkan = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
|
||||
fi
|
||||
;;
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
* inclusion of vulkan has the appropriate USE_PLATFORM defined, hence
|
||||
* the above. */
|
||||
#define VK_NO_PROTOTYPES
|
||||
#include "vulkan/vulkan.h"
|
||||
#include "./khronos/vulkan/vulkan.h"
|
||||
|
||||
extern const char *SDL_Vulkan_GetResultString(VkResult result);
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
* how to add a CAMetalLayer backed view.
|
||||
*/
|
||||
|
||||
/* this is (currently) only used with Vulkan. Remove this #if when that changes! */
|
||||
#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#import "SDL_cocoametalview.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
|
@ -118,7 +115,5 @@ Cocoa_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2017 The Khronos Group Inc.
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
|
||||
// calling convention, i.e. float parameters are passed in registers. This
|
||||
// is true even if the rest of the application passes floats on the stack,
|
||||
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
// Platform-specific headers required by platform window system extensions.
|
||||
// These are enabled prior to #including "vulkan.h". The same enable then
|
||||
// controls inclusion of the extension interfaces in vulkan.h.
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <android/native_window.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MIR_KHR
|
||||
#include <mir_toolkit/client_types.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[])
|
|||
#else
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
#include "vulkan/vulkan.h"
|
||||
#include "../src/video/khronos/vulkan/vulkan.h"
|
||||
|
||||
#define VULKAN_FUNCTIONS() \
|
||||
VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR) \
|
||||
|
|
Loading…
Reference in New Issue