Skip to content

Commit

Permalink
vulkan: Initial Vulkan support!
Browse files Browse the repository at this point in the history
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
  • Loading branch information
icculus committed Aug 28, 2017
1 parent 8e7998e commit 25e3a1e
Show file tree
Hide file tree
Showing 60 changed files with 5,456 additions and 80 deletions.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckCCompilerFlag)
include(CheckTypeSize)
Expand Down Expand Up @@ -324,9 +325,14 @@ set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
dep_option(VIDEO_VULKAN "Enable Vulkan surface creation" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
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")
Expand Down Expand Up @@ -855,6 +861,22 @@ if(ANDROID)
find_library(OpenGLES2_LIBRARY GLESv2)
list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
endif()

CHECK_C_SOURCE_COMPILES("
#if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
#error Vulkan doesn't work on this configuration
#endif
int main()
{
return 0;
}
" VULKAN_PASSED_ANDROID_CHECKS)
if(NOT VULKAN_PASSED_ANDROID_CHECKS)
set(VIDEO_VULKAN OFF)
message(STATUS "Vulkan doesn't work on this configuration")
else()
CheckVulkanHeaders()
endif()
endif()

CheckPTHREAD()
Expand Down Expand Up @@ -1020,6 +1042,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)

check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)

CheckVulkanHeaders()
endif()

if(INPUT_TSLIB)
Expand Down Expand Up @@ -1278,6 +1301,8 @@ elseif(WINDOWS)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
set(HAVE_VIDEO_OPENGLES TRUE)
endif()

CheckVulkanHeaders()
endif()

if(SDL_JOYSTICK)
Expand Down Expand Up @@ -1419,6 +1444,13 @@ elseif(APPLE)
endif()

# 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})
Expand Down Expand Up @@ -1498,6 +1530,10 @@ elseif(HAIKU)
CheckPTHREAD()
endif()

if(VIDEO_VULKAN AND HAVE_VULKAN_H AND (NOT APPLE OR QUARTZCORE))
set(SDL_VIDEO_VULKAN_SURFACE 1)
endif()

# Dummies
# configure.in does it differently:
# if not have X
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Expand Up @@ -112,6 +112,7 @@ HDRS = \
SDL_types.h \
SDL_version.h \
SDL_video.h \
SDL_vulkan.h \
begin_code.h \
close_code.h

Expand Down
44 changes: 40 additions & 4 deletions VisualC/SDL/SDL_VS2008.vcproj
Expand Up @@ -52,7 +52,7 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SolutionDir)/../include"
AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="_DEBUG;_WINDOWS"
RuntimeLibrary="2"
Expand Down Expand Up @@ -135,7 +135,7 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SolutionDir)/../include"
AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="_DEBUG;_WINDOWS"
RuntimeLibrary="2"
Expand Down Expand Up @@ -216,7 +216,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SolutionDir)/../include"
AdditionalIncludeDirectories="&quot;$(SolutionDir)/../include&quot;;&quot;$(VULKAN_SDK)/include&quot;"
AdditionalUsingDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS"
RuntimeLibrary="2"
Expand Down Expand Up @@ -299,7 +299,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SolutionDir)/../include"
AdditionalIncludeDirectories="&quot;$(SolutionDir)/../include&quot;;&quot;$(VULKAN_SDK)/include&quot;"
AdditionalUsingDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS"
RuntimeLibrary="2"
Expand Down Expand Up @@ -644,6 +644,10 @@
RelativePath="..\..\include\SDL_video.h"
>
</File>
<File
RelativePath="..\..\include\SDL_vulkan.h"
>
</File>
</Filter>
<File
RelativePath="..\..\src\events\blank_cursor.h"
Expand Down Expand Up @@ -877,6 +881,14 @@
RelativePath="..\..\src\SDL_dataqueue.h"
>
</File>
<File
RelativePath="..\..\src\SDL_dataqueue.c"
>
</File>
<File
RelativePath="..\..\src\SDL_dataqueue.h"
>
</File>
<File
RelativePath="..\..\src\haptic\windows\SDL_dinputhaptic.c"
>
Expand Down Expand Up @@ -1313,6 +1325,22 @@
RelativePath="..\..\src\audio\wasapi\SDL_wasapi.h"
>
</File>
<File
RelativePath="..\..\src\video\SDL_vulkan_internal.h"
>
</File>
<File
RelativePath="..\..\src\video\SDL_vulkan_utils.c"
>
</File>
<File
RelativePath="..\..\src\audio\wasapi\SDL_wasapi.c"
>
</File>
<File
RelativePath="..\..\src\audio\wasapi\SDL_wasapi.h"
>
</File>
<File
RelativePath="..\..\src\audio\SDL_wave.c"
>
Expand Down Expand Up @@ -1437,6 +1465,14 @@
RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowsvulkan.c"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowsvulkan.h"
>
</File>
<File
RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
>
Expand Down
11 changes: 11 additions & 0 deletions VisualC/SDL_VS2008.sln
Expand Up @@ -48,6 +48,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "controllermap", "tests\cont
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D69D5741-611F-4E14-8541-1FEE94F50B5A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvulkan", "tests\testvulkan\testvulkan_VS2008.vcproj", "{0D604DFD-AAB6-442C-9368-F91A344146AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -240,6 +242,14 @@ Global
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|Win32.Build.0 = Release|Win32
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.ActiveCfg = Release|x64
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.Build.0 = Release|x64
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.ActiveCfg = Debug|Win32
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.Build.0 = Debug|Win32
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|x64.ActiveCfg = Debug|x64
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|x64.Build.0 = Debug|x64
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|Win32.ActiveCfg = Release|Win32
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|Win32.Build.0 = Release|Win32
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.ActiveCfg = Release|x64
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -265,5 +275,6 @@ Global
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{55812185-D13C-4022-9C81-32E0F4A08306} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{26828762-C95D-4637-9CB1-7F0979523813} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{0D604DFD-AAB6-442C-9368-F91A344146AB} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
EndGlobalSection
EndGlobal

0 comments on commit 25e3a1e

Please sign in to comment.