From 68f338b1347c27f9052be3fdb084ccb800ba4370 Mon Sep 17 00:00:00 2001 From: drfrag Date: Thu, 9 Jan 2020 13:46:31 +0100 Subject: [PATCH] - Fixed compilation with MinGW and did some cleanup. --- src/CMakeLists.txt | 38 +++++-------------- src/rendering/swrenderer/r_memory.cpp | 2 +- .../thirdparty/vk_mem_alloc/vk_mem_alloc.h | 2 + src/win32/i_xinput.cpp | 12 ------ src/win32/win32polyvideo.cpp | 4 ++ 5 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c675cc69d..d0d76cb67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,36 +70,17 @@ if( WIN32 ) add_definitions( -D_WIN32 ) - if( ( MSVC14 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v140_xp" ) OR # For VS 2015. - ( MSVC15 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v141_xp" ) ) # For VS 2017. + if( MSVC ) # For VS 2017 and later. # for modern Windows SDKs the DirectX headers should be available by default. set( DX_dinput8_LIBRARY dinput8 ) else() - find_path( XINPUT_INCLUDE_DIR xinput.h - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Include ) - if( NOT XINPUT_INCLUDE_DIR ) - # Modern versions of the Windows SDK include xinput.h. Unfortunately, - # CMake cannot find this file via find_path, so we check for it using - # CHECK_INCLUDE_FILES. windows.h must be included before xinput.h. - CHECK_INCLUDE_FILES( "windows.h;xinput.h" XINPUT_H_FOUND ) - if( NOT XINPUT_H_FOUND ) - message( WARNING "Could not find xinput.h. XInput will be disabled." ) - add_definitions( -DNO_XINPUT ) - endif() - else() - include_directories( ${XINPUT_INCLUDE_DIR} ) - endif() - find_library( DX_dinput8_LIBRARY dinput8 PATHS ENV DXSDK_DIR PATH_SUFFIXES Lib Lib/${XBITS} ) - if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) - find_library( DX_dxguid_LIBRARY dxguid - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Lib Lib/${XBITS} ) - endif() + find_library( DX_dxguid_LIBRARY dxguid + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) # Modern versions of the Windows SDK include dinput8.lib. Unfortunately, # CMake cannot find these libraries via find_library. @@ -108,12 +89,10 @@ if( WIN32 ) set( DX_dinput8_LIBRARY dinput8 ) endif() - if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) - # Modern versions of the Windows SDK do NOT include dxguid.lib. Its contents - # were moved to dinput8.lib. - if( NOT DX_dxguid_LIBRARY ) - message( STATUS "Could not find dxguid.lib. Build may fail on old Windows SDKs.") - endif() + # Modern versions of the Windows SDK do NOT include dxguid.lib. Its contents + # were moved to dinput8.lib. + if( NOT DX_dxguid_LIBRARY ) + message( STATUS "Could not find dxguid.lib. Build may fail on old Windows SDKs.") endif() endif() @@ -140,6 +119,7 @@ if( WIN32 ) if( DX_dxguid_LIBRARY ) list( APPEND ZDOOM_LIBS "${DX_dxguid_LIBRARY}" ) endif() + list( APPEND ZDOOM_LIBS d3d9 ) endif() else() if( APPLE ) diff --git a/src/rendering/swrenderer/r_memory.cpp b/src/rendering/swrenderer/r_memory.cpp index 492beb03f..4177e5621 100644 --- a/src/rendering/swrenderer/r_memory.cpp +++ b/src/rendering/swrenderer/r_memory.cpp @@ -78,7 +78,7 @@ void RenderMemory::Clear() static void* Aligned_Alloc(size_t alignment, size_t size) { void* ptr; -#if defined _MSC_VER +#if defined (_MSC_VER) || defined (__MINGW32__) ptr = _aligned_malloc(size, alignment); if (!ptr) throw std::bad_alloc(); diff --git a/src/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h b/src/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h index 6c36ef90e..53ce163bf 100644 --- a/src/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h +++ b/src/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h @@ -2238,6 +2238,7 @@ remove them if not needed. #define VMA_NULL nullptr #endif +#ifndef __MINGW32__ #if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__) || (defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)) #include void *aligned_alloc(size_t alignment, size_t size) @@ -2254,6 +2255,7 @@ void *aligned_alloc(size_t alignment, size_t size) return VMA_NULL; } #endif +#endif // Normal assert to check for programmer's errors, especially in Debug configuration. #ifndef VMA_ASSERT diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index 710d2f295..63cfe294e 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -31,8 +31,6 @@ ** */ -#ifndef NO_XINPUT - // HEADER FILES ------------------------------------------------------------ #define WIN32_LEAN_AND_MEAN @@ -831,13 +829,3 @@ void I_StartupXInput() } } -#else // NO_XINPUT - -#include "i_input.h" - -void I_StartupXInput() -{ - JoyDevices[INPUT_XInput] = NULL; -} - -#endif diff --git a/src/win32/win32polyvideo.cpp b/src/win32/win32polyvideo.cpp index fb9d5612a..a12ea0517 100644 --- a/src/win32/win32polyvideo.cpp +++ b/src/win32/win32polyvideo.cpp @@ -13,6 +13,10 @@ extern HWND Window; #include #pragma comment(lib, "d3d9.lib") +#ifndef D3DPRESENT_FORCEIMMEDIATE +#define D3DPRESENT_FORCEIMMEDIATE 0x00000100L // MinGW +#endif + namespace { int SrcWidth = 0;