- restrict Vulkan to 64 bit builds.

This commit is contained in:
Christoph Oelckers 2019-03-24 14:33:04 +01:00
parent d3c02c75ba
commit a0b0467e91
5 changed files with 59 additions and 11 deletions

View file

@ -155,6 +155,7 @@ target_architecture(ZDOOM_TARGET_ARCH)
if( ${ZDOOM_TARGET_ARCH} MATCHES "x86_64" )
set( HAVE_VM_JIT ON )
set( HAVE_VULKAN ON )
endif()
# no, we're not using external asmjit for now, we made too many modifications to our's.
@ -180,7 +181,11 @@ if( MSVC )
# String pooling
# Function-level linking
# Disable run-time type information
if ( HAVE_VULKAN )
set( ALL_C_FLAGS "/GF /Gy /GR- /DHAVE_VULKAN" )
else()
set( ALL_C_FLAGS "/GF /Gy /GR-" )
endif()
# Use SSE 2 as minimum always as the true color drawers needs it for __vectorcall
#set( ALL_C_FLAGS "${ALL_C_FLAGS} /arch:SSE2") # This is already the default
@ -229,7 +234,12 @@ if( MSVC )
string(REPLACE " /GR" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
else()
set( REL_LINKER_FLAGS "" )
if ( HAVE_VULKAN )
set( ALL_C_FLAGS "-ffp-contract=off -DHAVE_VULKAN" )
else()
set( ALL_C_FLAGS "-ffp-contract=off" )
endif()
set( REL_C_FLAGS "" )
set( DEB_C_FLAGS "" )
@ -275,9 +285,11 @@ mark_as_advanced( FORCE_INTERNAL_GME )
option(FORCE_INTERNAL_ASMJIT "Use internal asmjit" ON)
mark_as_advanced( FORCE_INTERNAL_ASMJIT )
add_subdirectory( glslang/glslang)
add_subdirectory( glslang/spirv )
add_subdirectory( glslang/OGLCompilersDLL )
if (HAVE_VULKAN)
add_subdirectory( glslang/glslang)
add_subdirectory( glslang/spirv )
add_subdirectory( glslang/OGLCompilersDLL )
endif()
# Fast math flags, required by some subprojects
set( ZD_FASTMATH_FLAG "" )

View file

@ -460,7 +460,10 @@ add_custom_target( revision_check ALL
# Libraries ZDoom needs
message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" "glslang" "SPIRV" "OGLCompiler" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
if (HAVE_VULKAN)
set( ZDOOM_LIBS ${ZDOOM_LIBS} "glslang" "SPIRV" "OGLCompiler")
endif()
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" )
if( ${HAVE_VM_JIT} )
@ -504,8 +507,12 @@ set( PLAT_WIN32_SOURCES
win32/gl_sysfb.cpp
win32/base_sysfb.cpp
win32/win32basevideo.cpp
win32/win32glvideo.cpp
win32/win32vulkanvideo.cpp )
win32/win32glvideo.cpp)
if (HAVE_VULKAN)
set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} win32/win32vulkanvideo.cpp )
endif()
set( PLAT_POSIX_SOURCES
posix/i_cd.cpp
posix/i_steam.cpp )
@ -892,9 +899,10 @@ set( FASTMATH_SOURCES
sound/opnmidi/opnmidi_midiplay.cpp
sound/opnmidi/opnmidi_opn2.cpp
sound/opnmidi/opnmidi_private.cpp
sound/opnmidi/wopn/wopn_file.c
sound/opnmidi/wopn/wopn_file.c)
#Vulkan stuff must go into a separate list later because it needs to be disabled for some platforms
#Vulkan stuff must go into a separate list later because it needs to be disabled for some platforms
set (VULKAN_SOURCES
rendering/vulkan/system/vk_device.cpp
rendering/vulkan/system/vk_swapchain.cpp
rendering/vulkan/system/vk_builders.cpp
@ -911,6 +919,10 @@ set( FASTMATH_SOURCES
rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp
)
if (HAVE_VULKAN)
set (FASTMATH_SOURCES ${FASTMATH_SOURCES} ${VULKAN_SOURCES})
endif()
set (PCH_SOURCES
am_map.cpp
b_bot.cpp

View file

@ -33,8 +33,10 @@
#include "gl_load/gl_load.h"
#ifdef HAVE_VULKAN
#define VK_USE_PLATFORM_MACOS_MVK
#include "volk/volk.h"
#endif
#include "i_common.h"
@ -811,6 +813,7 @@ void I_SetWindowTitle(const char* title)
}
#ifdef HAVE_VULKAN
void I_GetVulkanDrawableSize(int *width, int *height)
{
NSWindow* const window = CocoaVideo::GetWindow();
@ -872,3 +875,4 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
const VkResult result = vkCreateMacOSSurfaceMVK(instance, &windowCreateInfo, nullptr, surface);
return result == VK_SUCCESS;
}
#endif

View file

@ -53,7 +53,9 @@
#include "gl/system/gl_framebuffer.h"
#include "gl/shaders/gl_shader.h"
#ifdef HAVE_VULKAN
#include "rendering/vulkan/system/vk_framebuffer.h"
#endif
// MACROS ------------------------------------------------------------------
@ -100,9 +102,11 @@ namespace Priv
static TOptProc<library, RESULT(*)(__VA_ARGS__)> NAME("SDL_" #NAME)
SDL2_OPTIONAL_FUNCTION(int, GetWindowBordersSize, SDL_Window *window, int *top, int *left, int *bottom, int *right);
#ifdef HAVE_VULKAN
SDL2_OPTIONAL_FUNCTION(void, Vulkan_GetDrawableSize, SDL_Window *window, int *width, int *height);
SDL2_OPTIONAL_FUNCTION(SDL_bool, Vulkan_GetInstanceExtensions, SDL_Window *window, unsigned int *count, const char **names);
SDL2_OPTIONAL_FUNCTION(SDL_bool, Vulkan_CreateSurface, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface);
#endif
#undef SDL2_OPTIONAL_FUNCTION
@ -191,11 +195,14 @@ public:
DFrameBuffer *CreateFrameBuffer ();
private:
#ifdef HAVE_VULKAN
VulkanDevice *device = nullptr;
#endif
};
// CODE --------------------------------------------------------------------
#ifdef HAVE_VULKAN
void I_GetVulkanDrawableSize(int *width, int *height)
{
assert(Priv::vulkanEnabled);
@ -217,6 +224,7 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
assert(Priv::window != nullptr);
return Priv::Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
}
#endif
SDLVideo::SDLVideo ()
@ -233,6 +241,7 @@ SDLVideo::SDLVideo ()
Priv::library.Load({ "libSDL2.so", "libSDL2-2.0.so" });
}
#ifdef HAVE_VULKAN
Priv::vulkanEnabled = vid_backend == 0
&& Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface;
@ -245,6 +254,7 @@ SDLVideo::SDLVideo ()
Priv::vulkanEnabled = false;
}
}
#endif
}
SDLVideo::~SDLVideo ()
@ -257,6 +267,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
SystemBaseFrameBuffer *fb = nullptr;
// first try Vulkan, if that fails OpenGL
#ifdef HAVE_VULKAN
if (Priv::vulkanEnabled)
{
try
@ -270,6 +281,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
Priv::vulkanEnabled = false;
}
}
#endif
if (fb == nullptr)
{
@ -302,8 +314,10 @@ int SystemBaseFrameBuffer::GetClientWidth()
{
int width = 0;
#ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled);
Priv::Vulkan_GetDrawableSize(Priv::window, &width, nullptr);
#endif
return width;
}
@ -312,8 +326,10 @@ int SystemBaseFrameBuffer::GetClientHeight()
{
int height = 0;
#ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled);
Priv::Vulkan_GetDrawableSize(Priv::window, nullptr, &height);
#endif
return height;
}

View file

@ -44,7 +44,9 @@
#include "m_argv.h"
#include "version.h"
#include "win32glvideo.h"
#ifdef HAVE_VULKAN
#include "win32vulkanvideo.h"
#endif
#include "doomerrors.h"
#include "i_system.h"
#include "swrenderer/r_swrenderer.h"
@ -128,6 +130,7 @@ void I_InitGraphics ()
// are the active app. Huh?
}
#ifdef HAVE_VULKAN
if (vid_backend == 0)
{
// first try Vulkan, if that fails OpenGL
@ -141,6 +144,7 @@ void I_InitGraphics ()
}
}
else
#endif
{
Video = new Win32GLVideo();
}