1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Disable vulkan in Windows build when HAVE_VULKAN is off and other cmake build fixes. (#11118)

* Make WolfSSL build support multi-config generator.
Fix a build error in Windows when using QT's moc.
Disable vulkan in Windows build when HAVE_VULKAN is off.

* add WIN32_LEAN_AND_MEAN definition to VS project.
add HAVE_VULKAN definition to VS project.
Define NTSTATUS in main.cpp.
This commit is contained in:
陈俊嘉 2021-11-13 23:11:49 +08:00 committed by GitHub
parent 8b3ed7b599
commit 05881ffa62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 26 deletions

View File

@ -27,18 +27,7 @@ else()
add_subdirectory(wolfssl EXCLUDE_FROM_ALL) add_subdirectory(wolfssl EXCLUDE_FROM_ALL)
# TODO(cjj19970505@live.cn) set(WolfSSL_LIBRARY "$<TARGET_FILE:wolfssl>" CACHE INTERNAL "")
# This only works in single-config generator
# For a multi-config generator, we need to provide different wolfssl binaries for different config
if (GENERATOR_IS_MULTI_CONFIG)
message( FATAL_ERROR "RPCS3 can only be configured using single-config generator." )
endif()
if(MSVC)
set(WolfSSL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/wolfssl/${CMAKE_BUILD_TYPE}/wolfssl.lib" CACHE INTERNAL "")
else()
set(WolfSSL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/wolfssl/libwolfssl.a" CACHE INTERNAL "")
endif()
# "${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/wolfssl/" provides openssl headers # "${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/wolfssl/" provides openssl headers
# So that curl can be built on an environment where openssl headers are not provided # So that curl can be built on an environment where openssl headers are not provided

View File

@ -41,7 +41,7 @@
#include "display_sleep_control.h" #include "display_sleep_control.h"
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
#include "Emu/RSX/VK/VulkanAPI.h" #include "Emu/RSX/VK/VulkanAPI.h"
#endif #endif
@ -718,7 +718,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
if (!add_only) if (!add_only)
{ {
// Log some extra info in case of boot // Log some extra info in case of boot
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
if (g_cfg.video.renderer == video_renderer::vulkan) if (g_cfg.video.renderer == video_renderer::vulkan)
{ {
sys_log.notice("Vulkan SDK Revision: %d", VK_HEADER_VERSION); sys_log.notice("Vulkan SDK Revision: %d", VK_HEADER_VERSION);

View File

@ -42,6 +42,8 @@
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>..\3rdparty\wolfssl\wolfssl;..\3rdparty\flatbuffers\include;..\3rdparty\libusb\libusb\libusb;..\3rdparty\yaml-cpp\yaml-cpp\include;..\3rdparty\zlib\zlib;..\llvm\include;..\llvm_build\include;$(VULKAN_SDK)\Include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\3rdparty\wolfssl\wolfssl;..\3rdparty\flatbuffers\include;..\3rdparty\libusb\libusb\libusb;..\3rdparty\yaml-cpp\yaml-cpp\include;..\3rdparty\zlib\zlib;..\llvm\include;..\llvm_build\include;$(VULKAN_SDK)\Include</AdditionalIncludeDirectories>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization> <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">HAVE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">HAVE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<PreBuildEvent> <PreBuildEvent>
<Command>cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command> <Command>cmd.exe /c "$(SolutionDir)\Utilities\git-version-gen.cmd"</Command>

View File

@ -73,7 +73,7 @@ void headless_application::InitializeCallbacks()
break; break;
} }
case video_renderer::opengl: case video_renderer::opengl:
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
case video_renderer::vulkan: case video_renderer::vulkan:
#endif #endif
{ {

View File

@ -26,6 +26,15 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include "util/dyn_lib.hpp" #include "util/dyn_lib.hpp"
// TODO(cjj19970505@live.cn)
// When compiling with WIN32_LEAN_AND_MEAN definition
// NTSTATUS is defined in CMake build but not in VS build
// May be caused by some different header pre-inclusion between CMake and VS configurations.
#if !defined(NTSTATUS)
// Copied from ntdef.h
typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
#endif
DYNAMIC_IMPORT("ntdll.dll", NtQueryTimerResolution, NTSTATUS(PULONG MinimumResolution, PULONG MaximumResolution, PULONG CurrentResolution)); DYNAMIC_IMPORT("ntdll.dll", NtQueryTimerResolution, NTSTATUS(PULONG MinimumResolution, PULONG MaximumResolution, PULONG CurrentResolution));
DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution)); DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution));
#else #else

View File

@ -79,7 +79,7 @@
<DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>_WINDOWS;UNICODE;WIN32;WIN64;WITH_DISCORD_RPC;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;NDEBUG;QT_WINEXTRAS_LIB;QT_CONCURRENT_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_SVG_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_WINDOWS;UNICODE;WIN32;WIN64;WIN32_LEAN_AND_MEAN;HAVE_VULKAN;WITH_DISCORD_RPC;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;NDEBUG;QT_WINEXTRAS_LIB;QT_CONCURRENT_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_SVG_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile> <PreprocessToFile>false</PreprocessToFile>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
@ -130,7 +130,7 @@
<DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WINDOWS;UNICODE;WIN32;WIN64;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_WINEXTRAS_LIB;QT_CONCURRENT_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_SVG_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_WINDOWS;UNICODE;WIN32;WIN64;WIN32_LEAN_AND_MEAN;HAVE_VULKAN;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_WINEXTRAS_LIB;QT_CONCURRENT_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_SVG_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile> <PreprocessToFile>false</PreprocessToFile>
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>

View File

@ -108,6 +108,12 @@ set_target_properties(rpcs3_ui
AUTOUIC ON AUTOUIC ON
AUTORCC ON) AUTORCC ON)
# AUTOMOC brings Windows.h to the sources, which have some definitions conflicting with winsock2.h
# define WIN32_LEAN_AND_MEAN resolve the problem
# https://docs.microsoft.com/en-us/windows/win32/winsock/creating-a-basic-winsock-application
# https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers#faster-builds-with-smaller-header-files
target_compile_definitions(rpcs3_ui PRIVATE WIN32_LEAN_AND_MEAN)
target_link_libraries(rpcs3_ui target_link_libraries(rpcs3_ui
PUBLIC PUBLIC
3rdparty::qt5 3rdparty::yaml-cpp 3rdparty::qt5 3rdparty::yaml-cpp

View File

@ -1,8 +1,3 @@
#ifdef _WIN32
// This is to avoid inclusion of winsock.h from windows.h header which creates conflicts with inclusion of winsock2.h later
#define _WINSOCKAPI_
#endif
#include "gui_application.h" #include "gui_application.h"
#include "qt_utils.h" #include "qt_utils.h"
@ -46,7 +41,7 @@
#include "Emu/RSX/Null/NullGSRender.h" #include "Emu/RSX/Null/NullGSRender.h"
#include "Emu/RSX/GL/GLGSRender.h" #include "Emu/RSX/GL/GLGSRender.h"
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
#include "Emu/RSX/VK/VKGSRender.h" #include "Emu/RSX/VK/VKGSRender.h"
#endif #endif
@ -342,7 +337,7 @@ void gui_application::InitializeCallbacks()
g_fxo->init<rsx::thread, named_thread<GLGSRender>>(); g_fxo->init<rsx::thread, named_thread<GLGSRender>>();
break; break;
} }
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
case video_renderer::vulkan: case video_renderer::vulkan:
{ {
g_fxo->init<rsx::thread, named_thread<VKGSRender>>(); g_fxo->init<rsx::thread, named_thread<VKGSRender>>();

View File

@ -4,7 +4,7 @@
#include "Utilities/Thread.h" #include "Utilities/Thread.h"
#if defined(_WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
#include "Emu/RSX/VK/vkutils/instance.hpp" #include "Emu/RSX/VK/vkutils/instance.hpp"
#endif #endif
@ -20,7 +20,7 @@ constexpr auto qstr = QString::fromStdString;
render_creator::render_creator(QObject *parent) : QObject(parent) render_creator::render_creator(QObject *parent) : QObject(parent)
{ {
#if defined(WIN32) || defined(HAVE_VULKAN) #if defined(HAVE_VULKAN)
// Some drivers can get stuck when checking for vulkan-compatible gpus, f.ex. if they're waiting for one to get // Some drivers can get stuck when checking for vulkan-compatible gpus, f.ex. if they're waiting for one to get
// plugged in. This whole contraption is for showing an error message in case that happens, so that user has // plugged in. This whole contraption is for showing an error message in case that happens, so that user has
// some idea about why the emulator window isn't showing up. // some idea about why the emulator window isn't showing up.