From 13e30958011a67cb6c1d56a9f585b4f5f3ad8cc7 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 1 Sep 2020 12:13:56 +1000 Subject: [PATCH] Core: Don't link to imgui for libretro core --- dep/CMakeLists.txt | 6 ++++-- src/core/CMakeLists.txt | 7 ++++++- src/core/cdrom.cpp | 6 +++++- src/core/core.vcxproj | 16 ++++++++-------- src/core/gpu.cpp | 6 +++++- src/core/gpu_hw.cpp | 6 +++++- src/core/host_interface.cpp | 1 - src/core/mdec.cpp | 6 +++++- src/core/spu.cpp | 6 +++++- src/core/system.cpp | 1 - src/core/timers.cpp | 6 +++++- 11 files changed, 48 insertions(+), 19 deletions(-) diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 13581d697..79acdde2b 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(cubeb) add_subdirectory(glad) add_subdirectory(googletest) -add_subdirectory(imgui) add_subdirectory(libcue) add_subdirectory(simpleini) add_subdirectory(stb) @@ -13,10 +12,13 @@ add_subdirectory(libFLAC) add_subdirectory(libchdr) add_subdirectory(xxhash) add_subdirectory(rapidjson) - add_subdirectory(glslang) add_subdirectory(vulkan-loader) +if(NOT BUILD_LIBRETRO_CORE) + add_subdirectory(imgui) +endif() + if(ENABLE_DISCORD_PRESENCE) add_subdirectory(discord-rpc) endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4d2cbad5f..0517bc810 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -98,7 +98,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 imgui tinyxml2 zlib vulkan-loader simpleini) +target_link_libraries(core PUBLIC Threads::Threads common tinyxml2 zlib vulkan-loader simpleini) target_link_libraries(core PRIVATE glad stb) if(WIN32) @@ -126,3 +126,8 @@ elseif(${CPU_ARCH} STREQUAL "aarch64") else() message("Not building recompiler") endif() + +if(NOT BUILD_LIBRETRO_CORE) + target_link_libraries(core PRIVATE imgui) + target_compile_definitions(core PRIVATE "WITH_IMGUI=1") +endif() diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 0c8c17716..673e186d8 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -4,11 +4,13 @@ #include "common/state_wrapper.h" #include "dma.h" #include "game_list.h" -#include "imgui.h" #include "interrupt_controller.h" #include "settings.h" #include "spu.h" #include "system.h" +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(CDROM); struct CommandInfo @@ -2341,6 +2343,7 @@ void CDROM::ClearSectorBuffers() void CDROM::DrawDebugWindow() { +#ifdef WITH_IMGUI static const ImVec4 active_color{1.0f, 1.0f, 1.0f, 1.0f}; static const ImVec4 inactive_color{0.4f, 0.4f, 0.4f, 1.0f}; const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; @@ -2521,4 +2524,5 @@ void CDROM::DrawDebugWindow() } ImGui::End(); +#endif } diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index bc5aeadf1..85d116da7 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -304,7 +304,7 @@ Level4 Disabled - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true ProgramDatabase $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) @@ -330,7 +330,7 @@ Level4 Disabled - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true ProgramDatabase $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) @@ -356,7 +356,7 @@ Level4 Disabled - WITH_RECOMPILER=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true ProgramDatabase $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) @@ -385,7 +385,7 @@ Level4 Disabled - WITH_RECOMPILER=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true ProgramDatabase $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) @@ -415,7 +415,7 @@ MaxSpeed true - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) true false @@ -442,7 +442,7 @@ MaxSpeed true - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) true true @@ -470,7 +470,7 @@ MaxSpeed true - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) true false @@ -497,7 +497,7 @@ MaxSpeed true - WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WITH_IMGUI=1;WITH_RECOMPILER=1;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories) true true diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index c56657c45..32d36ddcf 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -10,7 +10,9 @@ #include "system.h" #include "timers.h" #include -#include +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(GPU); std::unique_ptr g_gpu; @@ -1341,6 +1343,7 @@ bool GPU::DumpVRAMToFile(const char* filename, u32 width, u32 height, u32 stride void GPU::DrawDebugStateWindow() { +#ifdef WITH_IMGUI const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; ImGui::SetNextWindowSize(ImVec2(450.0f * framebuffer_scale, 550.0f * framebuffer_scale), ImGuiCond_FirstUseEver); @@ -1451,6 +1454,7 @@ void GPU::DrawDebugStateWindow() } ImGui::End(); +#endif } void GPU::DrawRendererStats(bool is_idle_frame) {} diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 7dfe6f432..4741a9263 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -3,13 +3,15 @@ #include "common/log.h" #include "common/state_wrapper.h" #include "cpu_core.h" -#include "imgui.h" #include "pgxp.h" #include "settings.h" #include "system.h" #include #include #include +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(GPU_HW); template @@ -1000,6 +1002,7 @@ void GPU_HW::DrawRendererStats(bool is_idle_frame) m_renderer_stats = {}; } +#ifdef WITH_IMGUI if (ImGui::CollapsingHeader("Renderer Statistics", ImGuiTreeNodeFlags_DefaultOpen)) { static const ImVec4 active_color{1.0f, 1.0f, 1.0f, 1.0f}; @@ -1068,4 +1071,5 @@ void GPU_HW::DrawRendererStats(bool is_idle_frame) ImGui::Columns(1); } +#endif } diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 9322a5f62..340c87715 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include Log_SetChannel(HostInterface); diff --git a/src/core/mdec.cpp b/src/core/mdec.cpp index 1d83e3435..cb1d752eb 100644 --- a/src/core/mdec.cpp +++ b/src/core/mdec.cpp @@ -5,7 +5,9 @@ #include "dma.h" #include "interrupt_controller.h" #include "system.h" -#include +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(MDEC); MDEC g_mdec; @@ -701,6 +703,7 @@ void MDEC::HandleSetScaleCommand() void MDEC::DrawDebugStateWindow() { +#ifdef WITH_IMGUI const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; ImGui::SetNextWindowSize(ImVec2(300.0f * framebuffer_scale, 350.0f * framebuffer_scale), ImGuiCond_FirstUseEver); @@ -738,4 +741,5 @@ void MDEC::DrawDebugStateWindow() } ImGui::End(); +#endif } diff --git a/src/core/spu.cpp b/src/core/spu.cpp index e0d42711f..ecb8b57a6 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -8,7 +8,9 @@ #include "host_interface.h" #include "interrupt_controller.h" #include "system.h" -#include +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(SPU); SPU g_spu; @@ -1747,6 +1749,7 @@ void SPU::ProcessReverb(s16 left_in, s16 right_in, s32* left_out, s32* right_out void SPU::DrawDebugStateWindow() { +#ifdef WITH_IMGUI static const ImVec4 active_color{1.0f, 1.0f, 1.0f, 1.0f}; static const ImVec4 inactive_color{0.4f, 0.4f, 0.4f, 1.0f}; const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; @@ -1924,4 +1927,5 @@ void SPU::DrawDebugStateWindow() } ImGui::End(); +#endif } diff --git a/src/core/system.cpp b/src/core/system.cpp index 50ab3d24d..3f24ea4ea 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -27,7 +27,6 @@ #include "spu.h" #include "timers.h" #include -#include #include Log_SetChannel(System); diff --git a/src/core/timers.cpp b/src/core/timers.cpp index a8c480340..a51b8bd7c 100644 --- a/src/core/timers.cpp +++ b/src/core/timers.cpp @@ -4,7 +4,9 @@ #include "gpu.h" #include "interrupt_controller.h" #include "system.h" -#include +#ifdef WITH_IMGUI +#include "imgui.h" +#endif Log_SetChannel(Timers); Timers g_timers; @@ -369,6 +371,7 @@ void Timers::UpdateSysClkEvent() void Timers::DrawDebugStateWindow() { +#ifdef WITH_IMGUI static constexpr u32 NUM_COLUMNS = 10; static constexpr std::array column_names = { {"#", "Value", "Target", "Sync", "Reset", "IRQ", "IRQRepeat", "IRQToggle", "Clock Source", "Reached"}}; @@ -437,4 +440,5 @@ void Timers::DrawDebugStateWindow() ImGui::Columns(1); ImGui::End(); +#endif }