build: Add flags to toggle specific renderer backends. (#7375)
This commit is contained in:
@@ -8,25 +8,42 @@ add_executable(citra
|
||||
default_ini.h
|
||||
emu_window/emu_window_sdl2.cpp
|
||||
emu_window/emu_window_sdl2.h
|
||||
emu_window/emu_window_sdl2_gl.cpp
|
||||
emu_window/emu_window_sdl2_gl.h
|
||||
emu_window/emu_window_sdl2_sw.cpp
|
||||
emu_window/emu_window_sdl2_sw.h
|
||||
emu_window/emu_window_sdl2_vk.cpp
|
||||
emu_window/emu_window_sdl2_vk.h
|
||||
precompiled_headers.h
|
||||
resource.h
|
||||
)
|
||||
|
||||
if (ENABLE_SOFTWARE_RENDERER)
|
||||
target_sources(citra PRIVATE
|
||||
emu_window/emu_window_sdl2_sw.cpp
|
||||
emu_window/emu_window_sdl2_sw.h
|
||||
)
|
||||
endif()
|
||||
if (ENABLE_OPENGL)
|
||||
target_sources(citra PRIVATE
|
||||
emu_window/emu_window_sdl2_gl.cpp
|
||||
emu_window/emu_window_sdl2_gl.h
|
||||
)
|
||||
endif()
|
||||
if (ENABLE_VULKAN)
|
||||
target_sources(citra PRIVATE
|
||||
emu_window/emu_window_sdl2_vk.cpp
|
||||
emu_window/emu_window_sdl2_vk.h
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(citra)
|
||||
|
||||
target_link_libraries(citra PRIVATE citra_common citra_core input_common network)
|
||||
target_link_libraries(citra PRIVATE inih glad)
|
||||
target_link_libraries(citra PRIVATE inih)
|
||||
if (MSVC)
|
||||
target_link_libraries(citra PRIVATE getopt)
|
||||
endif()
|
||||
target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} SDL2::SDL2 Threads::Threads)
|
||||
|
||||
if (ENABLE_OPENGL)
|
||||
target_link_libraries(citra PRIVATE glad)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
||||
endif()
|
||||
|
||||
@@ -13,9 +13,15 @@
|
||||
|
||||
#include "citra/config.h"
|
||||
#include "citra/emu_window/emu_window_sdl2.h"
|
||||
#ifdef ENABLE_OPENGL
|
||||
#include "citra/emu_window/emu_window_sdl2_gl.h"
|
||||
#endif
|
||||
#ifdef ENABLE_SOFTWARE_RENDERER
|
||||
#include "citra/emu_window/emu_window_sdl2_sw.h"
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "citra/emu_window/emu_window_sdl2_vk.h"
|
||||
#endif
|
||||
#include "common/common_paths.h"
|
||||
#include "common/detached_tasks.h"
|
||||
#include "common/file_util.h"
|
||||
@@ -354,16 +360,36 @@ int main(int argc, char** argv) {
|
||||
|
||||
const auto create_emu_window = [&](bool fullscreen,
|
||||
bool is_secondary) -> std::unique_ptr<EmuWindow_SDL2> {
|
||||
switch (Settings::values.graphics_api.GetValue()) {
|
||||
const auto graphics_api = Settings::values.graphics_api.GetValue();
|
||||
switch (graphics_api) {
|
||||
#ifdef ENABLE_OPENGL
|
||||
case Settings::GraphicsAPI::OpenGL:
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, is_secondary);
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
case Settings::GraphicsAPI::Vulkan:
|
||||
return std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen, is_secondary);
|
||||
#endif
|
||||
#ifdef ENABLE_SOFTWARE_RENDERER
|
||||
case Settings::GraphicsAPI::Software:
|
||||
return std::make_unique<EmuWindow_SDL2_SW>(system, fullscreen, is_secondary);
|
||||
#endif
|
||||
default:
|
||||
LOG_CRITICAL(
|
||||
Frontend,
|
||||
"Unknown or unsupported graphics API {}, falling back to available default",
|
||||
graphics_api);
|
||||
#ifdef ENABLE_OPENGL
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, is_secondary);
|
||||
#elif ENABLE_VULKAN
|
||||
return std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen, is_secondary);
|
||||
#elif ENABLE_SOFTWARE_RENDERER
|
||||
return std::make_unique<EmuWindow_SDL2_SW>(system, fullscreen, is_secondary);
|
||||
#else
|
||||
// TODO: Add a null renderer backend for this, perhaps.
|
||||
#error "At least one renderer must be enabled."
|
||||
#endif
|
||||
}
|
||||
LOG_ERROR(Frontend, "Invalid Graphics API, using OpenGL");
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, is_secondary);
|
||||
};
|
||||
|
||||
const auto emu_window{create_emu_window(fullscreen, false)};
|
||||
|
||||
Reference in New Issue
Block a user