diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6aa822264..a62abd865 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,8 @@ if(NOT ANDROID)
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" ON)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
+ option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
+ option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON)
option(ENABLE_CHEEVOS "Build with RetroAchievements support" ON)
option(USE_SDL2 "Link with SDL2 for controller support" ON)
diff --git a/duckstation.sln b/duckstation.sln
index 681f4a1fa..6af2b7b93 100644
--- a/duckstation.sln
+++ b/duckstation.sln
@@ -130,13 +130,11 @@ Global
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43540154-9E1E-409C-834F-B84BE5621388}.Debug|ARM64.ActiveCfg = Debug|ARM64
- {43540154-9E1E-409C-834F-B84BE5621388}.Debug|ARM64.Build.0 = Debug|ARM64
{43540154-9E1E-409C-834F-B84BE5621388}.Debug|x64.ActiveCfg = Debug|x64
{43540154-9E1E-409C-834F-B84BE5621388}.Debug|x64.Build.0 = Debug|x64
{43540154-9E1E-409C-834F-B84BE5621388}.Debug|x86.ActiveCfg = Debug|Win32
{43540154-9E1E-409C-834F-B84BE5621388}.Debug|x86.Build.0 = Debug|Win32
{43540154-9E1E-409C-834F-B84BE5621388}.DebugFast|ARM64.ActiveCfg = DebugFast|ARM64
- {43540154-9E1E-409C-834F-B84BE5621388}.DebugFast|ARM64.Build.0 = DebugFast|ARM64
{43540154-9E1E-409C-834F-B84BE5621388}.DebugFast|x64.ActiveCfg = DebugFast|x64
{43540154-9E1E-409C-834F-B84BE5621388}.DebugFast|x64.Build.0 = DebugFast|x64
{43540154-9E1E-409C-834F-B84BE5621388}.DebugFast|x86.ActiveCfg = DebugFast|Win32
@@ -145,13 +143,11 @@ Global
{43540154-9E1E-409C-834F-B84BE5621388}.DebugUWP|x64.ActiveCfg = DebugUWP|x64
{43540154-9E1E-409C-834F-B84BE5621388}.DebugUWP|x86.ActiveCfg = DebugUWP|Win32
{43540154-9E1E-409C-834F-B84BE5621388}.Release|ARM64.ActiveCfg = Release|ARM64
- {43540154-9E1E-409C-834F-B84BE5621388}.Release|ARM64.Build.0 = Release|ARM64
{43540154-9E1E-409C-834F-B84BE5621388}.Release|x64.ActiveCfg = Release|x64
{43540154-9E1E-409C-834F-B84BE5621388}.Release|x64.Build.0 = Release|x64
{43540154-9E1E-409C-834F-B84BE5621388}.Release|x86.ActiveCfg = Release|Win32
{43540154-9E1E-409C-834F-B84BE5621388}.Release|x86.Build.0 = Release|Win32
{43540154-9E1E-409C-834F-B84BE5621388}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64
- {43540154-9E1E-409C-834F-B84BE5621388}.ReleaseLTCG|ARM64.Build.0 = ReleaseLTCG|ARM64
{43540154-9E1E-409C-834F-B84BE5621388}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64
{43540154-9E1E-409C-834F-B84BE5621388}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
{43540154-9E1E-409C-834F-B84BE5621388}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32
@@ -700,13 +696,11 @@ Global
{4266505B-DBAF-484B-AB31-B53B9C8235B3}.ReleaseUWP|x64.ActiveCfg = ReleaseUWP|x64
{4266505B-DBAF-484B-AB31-B53B9C8235B3}.ReleaseUWP|x86.ActiveCfg = ReleaseUWP|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|ARM64.ActiveCfg = Debug|ARM64
- {7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|ARM64.Build.0 = Debug|ARM64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|x64.ActiveCfg = Debug|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|x64.Build.0 = Debug|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|x86.ActiveCfg = Debug|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Debug|x86.Build.0 = Debug|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugFast|ARM64.ActiveCfg = DebugFast|ARM64
- {7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugFast|ARM64.Build.0 = DebugFast|ARM64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugFast|x64.ActiveCfg = DebugFast|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugFast|x64.Build.0 = DebugFast|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugFast|x86.ActiveCfg = DebugFast|Win32
@@ -715,13 +709,11 @@ Global
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugUWP|x64.ActiveCfg = DebugUWP|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.DebugUWP|x86.ActiveCfg = DebugUWP|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|ARM64.ActiveCfg = Release|ARM64
- {7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|ARM64.Build.0 = Release|ARM64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|x64.ActiveCfg = Release|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|x64.Build.0 = Release|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|x86.ActiveCfg = Release|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.Release|x86.Build.0 = Release|Win32
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64
- {7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.ReleaseLTCG|ARM64.Build.0 = ReleaseLTCG|ARM64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
{7F909E29-4808-4BD9-A60C-56C51A3AAEC2}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 69b23b505..d46f2f204 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -16,16 +16,6 @@ add_library(common
file_system.h
image.cpp
image.h
- gl/context.cpp
- gl/context.h
- gl/program.cpp
- gl/program.h
- gl/shader_cache.cpp
- gl/shader_cache.h
- gl/stream_buffer.cpp
- gl/stream_buffer.h
- gl/texture.cpp
- gl/texture.h
hash_combine.h
heap_array.h
heterogeneous_containers.h
@@ -58,28 +48,6 @@ add_library(common
timer.cpp
timer.h
types.h
- vulkan/builders.cpp
- vulkan/builders.h
- vulkan/context.cpp
- vulkan/context.h
- vulkan/loader.h
- vulkan/loader.cpp
- vulkan/shader_cache.cpp
- vulkan/shader_cache.h
- vulkan/shader_compiler.cpp
- vulkan/shader_compiler.h
- vulkan/staging_buffer.cpp
- vulkan/staging_buffer.h
- vulkan/staging_texture.cpp
- vulkan/staging_texture.h
- vulkan/stream_buffer.cpp
- vulkan/stream_buffer.h
- vulkan/swap_chain.cpp
- vulkan/swap_chain.h
- vulkan/texture.cpp
- vulkan/texture.h
- vulkan/util.cpp
- vulkan/util.h
window_info.cpp
window_info.h
)
@@ -87,7 +55,7 @@ add_library(common
target_include_directories(common PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(common PUBLIC fmt Threads::Threads vulkan-headers)
-target_link_libraries(common PRIVATE glad stb libchdr glslang zlib minizip "${CMAKE_DL_LIBS}")
+target_link_libraries(common PRIVATE stb libchdr zlib minizip "${CMAKE_DL_LIBS}")
if(WIN32)
target_sources(common PRIVATE
@@ -115,8 +83,6 @@ if(WIN32)
d3d11/stream_buffer.h
d3d11/texture.cpp
d3d11/texture.h
- gl/context_wgl.cpp
- gl/context_wgl.h
thirdparty/StackWalker.cpp
thirdparty/StackWalker.h
win32_progress_callback.cpp
@@ -132,14 +98,18 @@ endif()
if(USE_X11)
target_sources(common PRIVATE
- gl/x11_window.cpp
- gl/x11_window.h
+ gl/x11_window.cpp
+ gl/x11_window.h
)
target_compile_definitions(common PRIVATE "-DUSE_X11=1")
target_include_directories(common PRIVATE "${X11_INCLUDE_DIR}" "${X11_Xrandr_INCLUDE_PATH}")
target_link_libraries(common PRIVATE "${X11_LIBRARIES}" "${X11_Xrandr_LIB}")
endif()
+if(USE_WAYLAND)
+ target_compile_definitions(common PRIVATE "-DUSE_WAYLAND=1")
+endif()
+
if(USE_DRMKMS)
target_sources(common PRIVATE
drm_display.cpp
@@ -148,71 +118,128 @@ if(USE_DRMKMS)
target_link_libraries(common PUBLIC Libdrm::Libdrm)
endif()
-if(USE_EGL)
+if(ENABLE_OPENGL)
target_sources(common PRIVATE
- gl/context_egl.cpp
- gl/context_egl.h
+ gl/context.cpp
+ gl/context.h
+ gl/program.cpp
+ gl/program.h
+ gl/shader_cache.cpp
+ gl/shader_cache.h
+ gl/stream_buffer.cpp
+ gl/stream_buffer.h
+ gl/texture.cpp
+ gl/texture.h
)
- target_compile_definitions(common PRIVATE "-DUSE_EGL=1")
+ target_compile_definitions(common PUBLIC "WITH_OPENGL=1")
+ target_link_libraries(common PRIVATE glad)
+
+ if(WIN32)
+ target_sources(common PRIVATE
+ gl/context_wgl.cpp
+ gl/context_wgl.h
+ )
+ endif()
+
+ if(USE_EGL)
+ target_sources(common PRIVATE
+ gl/context_egl.cpp
+ gl/context_egl.h
+ )
+ target_compile_definitions(common PRIVATE "-DUSE_EGL=1")
+
+ if(USE_X11)
+ target_sources(common PRIVATE
+ gl/context_egl_x11.cpp
+ gl/context_egl_x11.h
+ )
+
+ # We set EGL_NO_X11 because otherwise X comes in with its macros and breaks
+ # a bunch of files from compiling, if we include the EGL headers. This just
+ # makes the data types opaque, we can still use it with X11 if needed.
+ target_compile_definitions(common PRIVATE "-DEGL_NO_X11=1")
+ endif()
+ if(ANDROID AND USE_EGL)
+ target_sources(common PRIVATE
+ gl/context_egl_android.cpp
+ gl/context_egl_android.h
+ )
+ endif()
+ if(USE_DRMKMS)
+ target_compile_definitions(common PRIVATE "-DUSE_GBM=1")
+ target_sources(common PRIVATE
+ gl/context_egl_gbm.cpp
+ gl/context_egl_gbm.h
+ )
+ target_link_libraries(common PUBLIC GBM::GBM)
+ endif()
+ if(USE_FBDEV)
+ target_compile_definitions(common PRIVATE "-DUSE_FBDEV=1")
+ target_sources(common PRIVATE
+ gl/context_egl_fbdev.cpp
+ gl/context_egl_fbdev.h
+ )
+ endif()
+ endif()
if(USE_X11)
target_sources(common PRIVATE
- gl/context_egl_x11.cpp
- gl/context_egl_x11.h
+ gl/context_glx.cpp
+ gl/context_glx.h
)
-
- # We set EGL_NO_X11 because otherwise X comes in with its macros and breaks
- # a bunch of files from compiling, if we include the EGL headers. This just
- # makes the data types opaque, we can still use it with X11 if needed.
- target_compile_definitions(common PRIVATE "-DEGL_NO_X11=1")
+ target_compile_definitions(common PRIVATE "-DUSE_GLX=1")
endif()
- if(ANDROID AND USE_EGL)
+
+ if(USE_WAYLAND)
target_sources(common PRIVATE
- gl/context_egl_android.cpp
- gl/context_egl_android.h
+ gl/context_egl_wayland.cpp
+ gl/context_egl_wayland.h
)
endif()
- if(USE_DRMKMS)
- target_compile_definitions(common PRIVATE "-DUSE_GBM=1")
+
+ if(APPLE)
target_sources(common PRIVATE
- gl/context_egl_gbm.cpp
- gl/context_egl_gbm.h
- )
- target_link_libraries(common PUBLIC GBM::GBM)
- endif()
- if(USE_FBDEV)
- target_compile_definitions(common PRIVATE "-DUSE_FBDEV=1")
- target_sources(common PRIVATE
- gl/context_egl_fbdev.cpp
- gl/context_egl_fbdev.h
+ gl/context_agl.mm
+ gl/context_agl.h
)
endif()
endif()
-if(USE_X11)
+if(ENABLE_VULKAN)
target_sources(common PRIVATE
- gl/context_glx.cpp
- gl/context_glx.h
+ vulkan/builders.cpp
+ vulkan/builders.h
+ vulkan/context.cpp
+ vulkan/context.h
+ vulkan/loader.h
+ vulkan/loader.cpp
+ vulkan/shader_cache.cpp
+ vulkan/shader_cache.h
+ vulkan/shader_compiler.cpp
+ vulkan/shader_compiler.h
+ vulkan/staging_buffer.cpp
+ vulkan/staging_buffer.h
+ vulkan/staging_texture.cpp
+ vulkan/staging_texture.h
+ vulkan/stream_buffer.cpp
+ vulkan/stream_buffer.h
+ vulkan/swap_chain.cpp
+ vulkan/swap_chain.h
+ vulkan/texture.cpp
+ vulkan/texture.h
+ vulkan/util.cpp
+ vulkan/util.h
)
- target_compile_definitions(common PRIVATE "-DUSE_GLX=1")
+ target_compile_definitions(common PUBLIC "WITH_VULKAN=1")
+ target_link_libraries(common PRIVATE glslang)
+
+ if(APPLE)
+ # Needed for Vulkan Swap Chain.
+ target_link_libraries(common PRIVATE "objc")
+ endif()
endif()
-if(USE_WAYLAND)
- target_sources(common PRIVATE
- gl/context_egl_wayland.cpp
- gl/context_egl_wayland.h
- )
- target_compile_definitions(common PRIVATE "-DUSE_WAYLAND=1")
-endif()
-if(APPLE)
- # Needed for Vulkan Swap Chain.
- target_link_libraries(common PRIVATE "objc")
- target_sources(common PRIVATE
- gl/context_agl.mm
- gl/context_agl.h
- )
-endif()
if(ENABLE_CHEEVOS)
target_sources(common PRIVATE
diff --git a/src/common/common.props b/src/common/common.props
index 2c7caeb1c..be2e123f0 100644
--- a/src/common/common.props
+++ b/src/common/common.props
@@ -2,13 +2,16 @@
- $(SolutionDir)dep\fmt\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\glslang;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ WITH_OPENGL=1;WITH_VULKAN=1;%(PreprocessorDefinitions)
+ $(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan\include;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\fmt\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\glslang;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
- $(RootBuildDir)fmt\fmt.lib;$(RootBuildDir)glad\glad.lib;$(RootBuildDir)glslang\glslang.lib;$(RootBuildDir)zlib\zlib.lib;$(RootBuildDir)minizip\minizip.lib;$(RootBuildDir)lzma\lzma.lib;d3dcompiler.lib;d3d11.lib;%(AdditionalDependencies)
+ $(RootBuildDir)glad\glad.lib;$(RootBuildDir)glslang\glslang.lib;%(AdditionalDependencies)
+ $(RootBuildDir)fmt\fmt.lib;$(RootBuildDir)zlib\zlib.lib;$(RootBuildDir)minizip\minizip.lib;$(RootBuildDir)lzma\lzma.lib;d3dcompiler.lib;d3d11.lib;%(AdditionalDependencies)
diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj
index 04d3b8dea..0def3363e 100644
--- a/src/common/common.vcxproj
+++ b/src/common/common.vcxproj
@@ -25,15 +25,27 @@
-
-
- true
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
-
-
-
-
-
@@ -67,18 +79,42 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
true
@@ -103,14 +139,24 @@
-
-
- true
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
-
-
-
-
true
@@ -132,17 +178,39 @@
-
-
-
-
-
-
-
-
-
-
-
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
true
@@ -152,7 +220,9 @@
-
+
+ true
+
{EE054E08-3799-4A59-A422-18259C105FFD}
diff --git a/src/common/gl/context.cpp b/src/common/gl/context.cpp
index 47f629584..ca29c2f4b 100644
--- a/src/common/gl/context.cpp
+++ b/src/common/gl/context.cpp
@@ -11,7 +11,7 @@ Log_SetChannel(GL::Context);
#if defined(_WIN32) && !defined(_M_ARM64)
#include "context_wgl.h"
-#elif defined(__APPLE__) && !defined(LIBERTRO)
+#elif defined(__APPLE__)
#include "context_agl.h"
#endif
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index f6239e687..6def85e45 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -40,12 +40,8 @@ add_library(core
gpu_commands.cpp
gpu_hw.cpp
gpu_hw.h
- gpu_hw_opengl.cpp
- gpu_hw_opengl.h
gpu_hw_shadergen.cpp
gpu_hw_shadergen.h
- gpu_hw_vulkan.cpp
- gpu_hw_vulkan.h
gpu_sw.cpp
gpu_sw.h
gpu_sw_backend.cpp
@@ -121,7 +117,7 @@ set(RECOMPILER_SRCS
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(core PUBLIC Threads::Threads common util zlib)
-target_link_libraries(core PRIVATE glad stb xxhash imgui rapidjson tinyxml2)
+target_link_libraries(core PRIVATE stb xxhash imgui rapidjson tinyxml2)
if(WIN32)
target_sources(core PRIVATE
@@ -133,6 +129,21 @@ if(WIN32)
target_link_libraries(core PRIVATE winmm.lib)
endif()
+if(ENABLE_OPENGL)
+ target_sources(core PRIVATE
+ gpu_hw_opengl.cpp
+ gpu_hw_opengl.h
+ )
+ target_link_libraries(core PRIVATE glad)
+endif()
+
+if(ENABLE_VULKAN)
+ target_sources(core PRIVATE
+ gpu_hw_vulkan.cpp
+ gpu_hw_vulkan.h
+ )
+endif()
+
if(${CPU_ARCH} STREQUAL "x64")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../dep/xbyak/xbyak")
target_compile_definitions(core PUBLIC "WITH_RECOMPILER=1" "WITH_MMAP_FASTMEM=1")
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index d7c939a56..e7165b3a3 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -38,7 +38,9 @@
-
+
+ true
+
@@ -46,7 +48,9 @@
-
+
+ true
+
@@ -104,7 +108,9 @@
-
+
+ true
+
@@ -114,7 +120,9 @@
-
+
+ true
+
diff --git a/src/core/gpu.h b/src/core/gpu.h
index 3b1849778..db90f3080 100644
--- a/src/core/gpu.h
+++ b/src/core/gpu.h
@@ -150,17 +150,23 @@ public:
float ComputeVerticalFrequency() const;
float GetDisplayAspectRatio() const;
+#ifdef _WIN32
// gpu_hw_d3d11.cpp
static std::unique_ptr CreateHardwareD3D11Renderer();
// gpu_hw_d3d12.cpp
static std::unique_ptr CreateHardwareD3D12Renderer();
+#endif
+#ifdef WITH_OPENGL
// gpu_hw_opengl.cpp
static std::unique_ptr CreateHardwareOpenGLRenderer();
+#endif
+#ifdef WITH_VULKAN
// gpu_hw_vulkan.cpp
static std::unique_ptr CreateHardwareVulkanRenderer();
+#endif
// gpu_sw.cpp
static std::unique_ptr CreateSoftwareRenderer();
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index 236bb0216..c688b655b 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -805,12 +805,23 @@ static constexpr auto s_gpu_renderer_names = make_array(
#ifdef _WIN32
"D3D11", "D3D12",
#endif
- "Vulkan", "OpenGL", "Software");
+#ifdef WITH_VULKAN
+ "Vulkan",
+#endif
+#ifdef WITH_OPENGL
+ "OpenGL",
+#endif
+ "Software");
static constexpr auto s_gpu_renderer_display_names = make_array(
#ifdef _WIN32
TRANSLATABLE("GPURenderer", "Hardware (D3D11)"), TRANSLATABLE("GPURenderer", "Hardware (D3D12)"),
#endif
- TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"), TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),
+#ifdef WITH_VULKAN
+ TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"),
+#endif
+#ifdef WITH_OPENGL
+ TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),
+#endif
TRANSLATABLE("GPURenderer", "Software"));
std::optional Settings::ParseRendererName(const char* str)
diff --git a/src/core/settings.h b/src/core/settings.h
index 1e79d9c6d..4f89f1d71 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -358,10 +358,16 @@ struct Settings
static const char* GetMultitapModeDisplayName(MultitapMode mode);
// Default to D3D11 on Windows as it's more performant and at this point, less buggy.
-#ifdef _WIN32
+#if defined(_WIN32) && defined(_M_ARM64)
+ static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareD3D12;
+#elif defined(_WIN32)
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareD3D11;
-#else
+#elif defined(WITH_OPENGL)
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareOpenGL;
+#elif defined(WITH_VULKAN)
+ static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::HardwareVulkan;
+#else
+ static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::Software;
#endif
static constexpr GPUTextureFilter DEFAULT_GPU_TEXTURE_FILTER = GPUTextureFilter::Nearest;
static constexpr GPUDownsampleMode DEFAULT_GPU_DOWNSAMPLE_MODE = GPUDownsampleMode::Disabled;
diff --git a/src/core/shadergen.cpp b/src/core/shadergen.cpp
index d4cad4d82..6d59653ea 100644
--- a/src/core/shadergen.cpp
+++ b/src/core/shadergen.cpp
@@ -1,9 +1,13 @@
#include "shadergen.h"
#include "common/assert.h"
-#include "common/gl/loader.h"
#include "common/log.h"
#include
#include
+
+#ifdef WITH_OPENGL
+#include "common/gl/loader.h"
+#endif
+
Log_SetChannel(ShaderGen);
ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_source_blend)
@@ -11,14 +15,16 @@ ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_sourc
m_glsl(render_api != HostDisplay::RenderAPI::D3D11 && render_api != HostDisplay::RenderAPI::D3D12),
m_supports_dual_source_blend(supports_dual_source_blend), m_use_glsl_interface_blocks(false)
{
+#if defined(WITH_OPENGL) || defined(WITH_VULKAN)
if (m_glsl)
{
+#ifdef WITH_OPENGL
if (m_render_api == HostDisplay::RenderAPI::OpenGL || m_render_api == HostDisplay::RenderAPI::OpenGLES)
SetGLSLVersionString();
m_use_glsl_interface_blocks = (IsVulkan() || GLAD_GL_ES_VERSION_3_2 || GLAD_GL_VERSION_3_2);
m_use_glsl_binding_layout = (IsVulkan() || UseGLSLBindingLayout());
-
+
if (m_render_api == HostDisplay::RenderAPI::OpenGL)
{
// SSAA with interface blocks is broken on AMD's OpenGL driver.
@@ -26,16 +32,25 @@ ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_sourc
if (std::strcmp(gl_vendor, "ATI Technologies Inc.") == 0)
m_use_glsl_interface_blocks = false;
}
+#else
+ m_use_glsl_interface_blocks = true;
+ m_use_glsl_binding_layout = true;
+#endif
}
+#endif
}
ShaderGen::~ShaderGen() = default;
bool ShaderGen::UseGLSLBindingLayout()
{
+#ifdef WITH_OPENGL
return (GLAD_GL_ES_VERSION_3_1 || GLAD_GL_VERSION_4_3 ||
(GLAD_GL_ARB_explicit_attrib_location && GLAD_GL_ARB_explicit_uniform_location &&
GLAD_GL_ARB_shading_language_420pack));
+#else
+ return true;
+#endif
}
void ShaderGen::DefineMacro(std::stringstream& ss, const char* name, bool enabled)
@@ -43,6 +58,7 @@ void ShaderGen::DefineMacro(std::stringstream& ss, const char* name, bool enable
ss << "#define " << name << " " << BoolToUInt32(enabled) << "\n";
}
+#ifdef WITH_OPENGL
void ShaderGen::SetGLSLVersionString()
{
const char* glsl_version = reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION));
@@ -85,6 +101,7 @@ void ShaderGen::SetGLSLVersionString()
(glsl_es && major_version >= 3) ? " es" : "");
m_glsl_version_string = buf;
}
+#endif
void ShaderGen::WriteHeader(std::stringstream& ss)
{
@@ -93,6 +110,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
else if (m_render_api == HostDisplay::RenderAPI::Vulkan)
ss << "#version 450 core\n\n";
+#ifdef WITH_OPENGL
// Extension enabling for OpenGL.
if (m_render_api == HostDisplay::RenderAPI::OpenGLES)
{
@@ -130,6 +148,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
if (!GLAD_GL_VERSION_4_3 && !GLAD_GL_ES_VERSION_3_1 && GLAD_GL_ARB_shader_storage_buffer_object)
ss << "#extension GL_ARB_shader_storage_buffer_object : require\n";
}
+#endif
DefineMacro(ss, "API_OPENGL", m_render_api == HostDisplay::RenderAPI::OpenGL);
DefineMacro(ss, "API_OPENGL_ES", m_render_api == HostDisplay::RenderAPI::OpenGLES);
@@ -137,6 +156,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
DefineMacro(ss, "API_D3D12", m_render_api == HostDisplay::RenderAPI::D3D12);
DefineMacro(ss, "API_VULKAN", m_render_api == HostDisplay::RenderAPI::Vulkan);
+#ifdef WITH_OPENGL
if (m_render_api == HostDisplay::RenderAPI::OpenGLES)
{
ss << "precision highp float;\n";
@@ -151,6 +171,7 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
ss << "\n";
}
+#endif
if (m_glsl)
{
@@ -315,7 +336,12 @@ void ShaderGen::DeclareTextureBuffer(std::stringstream& ss, const char* name, u3
const char* ShaderGen::GetInterpolationQualifier(bool interface_block, bool centroid_interpolation,
bool sample_interpolation, bool is_out) const
{
- if (m_glsl && interface_block && (!IsVulkan() && !GLAD_GL_ARB_shading_language_420pack))
+#ifdef WITH_OPENGL
+ const bool shading_language_420pack = GLAD_GL_ARB_shading_language_420pack;
+#else
+ const bool shading_language_420pack = false;
+#endif
+ if (m_glsl && interface_block && (!IsVulkan() && !shading_language_420pack))
{
return (sample_interpolation ? (is_out ? "sample out " : "sample in ") :
(centroid_interpolation ? (is_out ? "centroid out " : "centroid in ") : ""));
diff --git a/src/core/shadergen.h b/src/core/shadergen.h
index f3a9196c9..669919fe5 100644
--- a/src/core/shadergen.h
+++ b/src/core/shadergen.h
@@ -24,7 +24,10 @@ protected:
const char* GetInterpolationQualifier(bool interface_block, bool centroid_interpolation, bool sample_interpolation,
bool is_out) const;
+#ifdef WITH_OPENGL
void SetGLSLVersionString();
+#endif
+
void DefineMacro(std::stringstream& ss, const char* name, bool enabled);
void WriteHeader(std::stringstream& ss);
void WriteUniformBufferDeclaration(std::stringstream& ss, bool push_constant_on_vulkan);
diff --git a/src/core/system.cpp b/src/core/system.cpp
index 3304de665..e6e73c0f4 100644
--- a/src/core/system.cpp
+++ b/src/core/system.cpp
@@ -1457,13 +1457,17 @@ bool System::CreateGPU(GPURenderer renderer)
{
switch (renderer)
{
+#ifdef WITH_OPENGL
case GPURenderer::HardwareOpenGL:
g_gpu = GPU::CreateHardwareOpenGLRenderer();
break;
+#endif
+#ifdef WITH_VULKAN
case GPURenderer::HardwareVulkan:
g_gpu = GPU::CreateHardwareVulkanRenderer();
break;
+#endif
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
diff --git a/src/core/types.h b/src/core/types.h
index 340a07aef..a3b701e9e 100644
--- a/src/core/types.h
+++ b/src/core/types.h
@@ -58,8 +58,12 @@ enum class GPURenderer : u8
HardwareD3D11,
HardwareD3D12,
#endif
+#ifdef WITH_VULKAN
HardwareVulkan,
+#endif
+#ifdef WITH_OPENGL
HardwareOpenGL,
+#endif
Software,
Count
};
diff --git a/src/duckstation-qt/displaysettingswidget.cpp b/src/duckstation-qt/displaysettingswidget.cpp
index 7723f9054..1e4479f9d 100644
--- a/src/duckstation-qt/displaysettingswidget.cpp
+++ b/src/duckstation-qt/displaysettingswidget.cpp
@@ -8,11 +8,13 @@
#include
// For enumerating adapters.
-#include "frontend-common/vulkan_host_display.h"
#ifdef _WIN32
#include "frontend-common/d3d11_host_display.h"
#include "frontend-common/d3d12_host_display.h"
#endif
+#ifdef WITH_VULKAN
+#include "frontend-common/vulkan_host_display.h"
+#endif
DisplaySettingsWidget::DisplaySettingsWidget(SettingsDialog* dialog, QWidget* parent)
: QWidget(parent), m_dialog(dialog)
@@ -206,11 +208,12 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
aml = FrontendCommon::D3D12HostDisplay::StaticGetAdapterAndModeList();
break;
#endif
-
+#ifdef WITH_VULKAN
case GPURenderer::HardwareVulkan:
aml = FrontendCommon::VulkanHostDisplay::StaticGetAdapterAndModeList(nullptr);
threaded_presentation_supported = true;
break;
+#endif
case GPURenderer::Software:
thread_supported = true;
diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp
index c2eca1595..771366b97 100644
--- a/src/duckstation-qt/qthost.cpp
+++ b/src/duckstation-qt/qthost.cpp
@@ -21,9 +21,7 @@
#include "frontend-common/imgui_manager.h"
#include "frontend-common/imgui_overlays.h"
#include "frontend-common/input_manager.h"
-#include "frontend-common/opengl_host_display.h"
#include "frontend-common/sdl_audio_stream.h"
-#include "frontend-common/vulkan_host_display.h"
#include "imgui.h"
#include "mainwindow.h"
#include "qtprogresscallback.h"
@@ -58,6 +56,14 @@ Log_SetChannel(EmuThread);
#include
#endif
+#ifdef WITH_OPENGL
+#include "frontend-common/opengl_host_display.h"
+#endif
+
+#ifdef WITH_VULKAN
+#include "frontend-common/vulkan_host_display.h"
+#endif
+
#ifdef WITH_CHEEVOS
#include "frontend-common/achievements.h"
#endif
@@ -824,17 +830,18 @@ bool EmuThread::acquireHostDisplay(HostDisplay::RenderAPI api)
switch (api)
{
+#ifdef WITH_VULKAN
case HostDisplay::RenderAPI::Vulkan:
g_host_display = std::make_unique();
break;
+#endif
+#ifdef WITH_OPENGL
case HostDisplay::RenderAPI::OpenGL:
case HostDisplay::RenderAPI::OpenGLES:
-#ifndef _WIN32
- default:
-#endif
g_host_display = std::make_unique();
break;
+#endif
#ifdef _WIN32
case HostDisplay::RenderAPI::D3D12:
@@ -842,10 +849,21 @@ bool EmuThread::acquireHostDisplay(HostDisplay::RenderAPI api)
break;
case HostDisplay::RenderAPI::D3D11:
- default:
g_host_display = std::make_unique();
break;
#endif
+
+ default:
+#if defined(_WIN32) && defined(_M_ARM64)
+ g_host_display = std::make_unique();
+#elif defined(_WIN32)
+ g_host_display = std::make_unique();
+#elif defined(WITH_OPENGL)
+ g_host_display = std::make_unique();
+#elif defined(WITH_VULKAN)
+ g_host_display = std::make_unique();
+#endif
+ break;
}
if (!createDisplayRequested(m_is_fullscreen, m_is_rendering_to_main))
diff --git a/src/frontend-common/CMakeLists.txt b/src/frontend-common/CMakeLists.txt
index 91c12cf8d..cd065717a 100644
--- a/src/frontend-common/CMakeLists.txt
+++ b/src/frontend-common/CMakeLists.txt
@@ -20,27 +20,19 @@ add_library(frontend-common
input_source.h
imgui_fullscreen.cpp
imgui_fullscreen.h
- imgui_impl_opengl3.cpp
- imgui_impl_opengl3.h
- imgui_impl_vulkan.cpp
- imgui_impl_vulkan.h
imgui_manager.cpp
imgui_manager.h
imgui_overlays.cpp
imgui_overlays.h
- opengl_host_display.cpp
- opengl_host_display.h
postprocessing_chain.cpp
postprocessing_chain.h
postprocessing_shader.cpp
postprocessing_shader.h
postprocessing_shadergen.cpp
postprocessing_shadergen.h
- vulkan_host_display.cpp
- vulkan_host_display.h
)
-target_link_libraries(frontend-common PUBLIC core common glad cubeb imgui tinyxml2 rapidjson scmversion)
+target_link_libraries(frontend-common PUBLIC core common cubeb imgui tinyxml2 rapidjson scmversion)
if(WIN32)
target_sources(frontend-common PRIVATE
@@ -64,6 +56,25 @@ if(WIN32)
target_link_libraries(frontend-common PRIVATE d3d11.lib dxgi.lib)
endif()
+if(ENABLE_OPENGL)
+ target_sources(frontend-common PRIVATE
+ opengl_host_display.cpp
+ opengl_host_display.h
+ imgui_impl_opengl3.cpp
+ imgui_impl_opengl3.h
+ )
+ target_link_libraries(frontend-common PRIVATE glad)
+endif()
+
+if(ENABLE_VULKAN)
+ target_sources(frontend-common PRIVATE
+ imgui_impl_vulkan.cpp
+ imgui_impl_vulkan.h
+ vulkan_host_display.cpp
+ vulkan_host_display.h
+ )
+endif()
+
if(APPLE)
find_library(IOK_LIBRARY IOKit REQUIRED)
target_link_libraries(frontend-common PRIVATE "${IOK_LIBRARY}")
diff --git a/src/frontend-common/frontend-common.vcxproj b/src/frontend-common/frontend-common.vcxproj
index 2c8f80c30..899de59f3 100644
--- a/src/frontend-common/frontend-common.vcxproj
+++ b/src/frontend-common/frontend-common.vcxproj
@@ -17,14 +17,20 @@
-
-
+
+ true
+
+
+ true
+
-
+
+ true
+
@@ -35,7 +41,9 @@
true
-
+
+ true
+
@@ -55,14 +63,20 @@
-
-
+
+ true
+
+
+ true
+
-
+
+ true
+
@@ -73,7 +87,9 @@
true
-
+
+ true
+
diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp
index abb102139..b781bb268 100644
--- a/src/frontend-common/fullscreen_ui.cpp
+++ b/src/frontend-common/fullscreen_ui.cpp
@@ -2949,6 +2949,7 @@ void FullscreenUI::DrawDisplaySettingsPage()
break;
#endif
+#ifdef WITH_VULKAN
case GPURenderer::HardwareVulkan:
{
DrawToggleSetting("Threaded Presentation",
@@ -2956,6 +2957,7 @@ void FullscreenUI::DrawDisplaySettingsPage()
"ThreadedPresentation", true);
}
break;
+#endif
case GPURenderer::Software:
{