From cfd148ac367d82135ec893dfe660c09dcc99f193 Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Tue, 2 Jun 2026 19:05:04 +0100 Subject: [PATCH] Move camera code to `CemuInput` Compiling the precompiled headers for `CemuCamera` took longer than compiling `CemuCamera` itself, so it just ends up being noticeably faster to just add it to one of the existing sublibs. It probably wasn't a problem for MSVC because precompiled header reuse works there, but I'm not using MSVC --- src/CMakeLists.txt | 2 -- src/Cafe/CMakeLists.txt | 1 - src/Cafe/OS/libs/camera/camera.cpp | 16 ++++++++-------- src/camera/CMakeLists.txt | 19 ------------------- src/gui/wxgui/CMakeLists.txt | 1 - src/gui/wxgui/CameraSettingsWindow.cpp | 2 +- src/input/CMakeLists.txt | 5 +++++ src/{ => input}/camera/CameraManager.cpp | 6 +++--- src/{ => input}/camera/CameraManager.h | 0 src/{ => input}/camera/Rgb2Nv12.cpp | 0 src/{ => input}/camera/Rgb2Nv12.h | 0 11 files changed, 17 insertions(+), 35 deletions(-) delete mode 100644 src/camera/CMakeLists.txt rename src/{ => input}/camera/CameraManager.cpp (96%) rename src/{ => input}/camera/CameraManager.h (100%) rename src/{ => input}/camera/Rgb2Nv12.cpp (100%) rename src/{ => input}/camera/Rgb2Nv12.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab853c59..977f48b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,6 @@ add_subdirectory(Cemu) add_subdirectory(config) add_subdirectory(input) add_subdirectory(audio) -add_subdirectory(camera) add_subdirectory(util) add_subdirectory(imgui) add_subdirectory(resource) @@ -215,7 +214,6 @@ set_target_properties(CemuBin PROPERTIES target_link_libraries(CemuBin PRIVATE CemuAudio CemuCafe - CemuCamera CemuCommon CemuComponents CemuConfig diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index d26409f4..b509e722 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -647,7 +647,6 @@ endif() target_link_libraries(CemuCafe PRIVATE CemuCommon - CemuCamera CemuGui ZArchive::zarchive imguiImpl diff --git a/src/Cafe/OS/libs/camera/camera.cpp b/src/Cafe/OS/libs/camera/camera.cpp index a47c7072..5a07d4f2 100644 --- a/src/Cafe/OS/libs/camera/camera.cpp +++ b/src/Cafe/OS/libs/camera/camera.cpp @@ -5,7 +5,7 @@ #include "Cafe/OS/libs/coreinit/coreinit_Alarm.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h" #include "Cafe/HW/Espresso/PPCCallback.h" -#include "camera/CameraManager.h" +#include "input/camera/CameraManager.h" #include "Common/CafeString.h" #include "OS/common/OSUtil.h" #include "util/helpers/ringbuffer.h" @@ -277,13 +277,13 @@ namespace camera void RPLMapped() override { - cafeExportRegister("camera", CAMGetMemReq, LogType::Placeholder); - cafeExportRegister("camera", CAMCheckMemSegmentation, LogType::Placeholder); - cafeExportRegister("camera", CAMInit, LogType::Placeholder); - cafeExportRegister("camera", CAMExit, LogType::Placeholder); - cafeExportRegister("camera", CAMOpen, LogType::Placeholder); - cafeExportRegister("camera", CAMClose, LogType::Placeholder); - cafeExportRegister("camera", CAMSubmitTargetSurface, LogType::Placeholder); + cafeExportRegister("camera", CAMGetMemReq, LogType::InputAPI); + cafeExportRegister("camera", CAMCheckMemSegmentation, LogType::InputAPI); + cafeExportRegister("camera", CAMInit, LogType::InputAPI); + cafeExportRegister("camera", CAMExit, LogType::InputAPI); + cafeExportRegister("camera", CAMOpen, LogType::InputAPI); + cafeExportRegister("camera", CAMClose, LogType::InputAPI); + cafeExportRegister("camera", CAMSubmitTargetSurface, LogType::InputAPI); }; void rpl_entry(uint32 moduleHandle, coreinit::RplEntryReason reason) override diff --git a/src/camera/CMakeLists.txt b/src/camera/CMakeLists.txt deleted file mode 100644 index 6fbe1764..00000000 --- a/src/camera/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -add_library(CemuCamera - CameraManager.cpp - CameraManager.h - Rgb2Nv12.cpp - Rgb2Nv12.h -) - -cemu_use_precompiled_header(CemuCamera) - -set_property(TARGET CemuCamera PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - -target_include_directories(CemuCamera PUBLIC "../") -target_link_libraries(CemuCamera - PRIVATE - CemuCommon - CemuConfig - CemuUtil - glm::glm - openpnp-capture) diff --git a/src/gui/wxgui/CMakeLists.txt b/src/gui/wxgui/CMakeLists.txt index c4beb415..bd74faf9 100644 --- a/src/gui/wxgui/CMakeLists.txt +++ b/src/gui/wxgui/CMakeLists.txt @@ -161,7 +161,6 @@ target_link_libraries(CemuWxGui PRIVATE CemuComponents pugixml::pugixml CemuCafe - CemuCamera PUBLIC CURL::libcurl ) diff --git a/src/gui/wxgui/CameraSettingsWindow.cpp b/src/gui/wxgui/CameraSettingsWindow.cpp index b4e6061e..b7f00df3 100644 --- a/src/gui/wxgui/CameraSettingsWindow.cpp +++ b/src/gui/wxgui/CameraSettingsWindow.cpp @@ -1,6 +1,6 @@ #include "CameraSettingsWindow.h" -#include "camera/CameraManager.h" +#include "input/camera/CameraManager.h" #include #include diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index 4978ef0a..fad146a2 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -19,6 +19,10 @@ add_library(CemuInput api/Keyboard/KeyboardControllerProvider.cpp api/Keyboard/KeyboardController.cpp api/Keyboard/KeyboardController.h + camera/CameraManager.cpp + camera/CameraManager.h + camera/Rgb2Nv12.cpp + camera/Rgb2Nv12.h emulated/ProController.cpp emulated/EmulatedController.h emulated/EmulatedController.cpp @@ -103,6 +107,7 @@ target_include_directories(CemuInput PUBLIC "../") target_link_libraries(CemuInput PRIVATE CemuCommon CemuGui + openpnp-capture ) if (ENABLE_BLUEZ) diff --git a/src/camera/CameraManager.cpp b/src/input/camera/CameraManager.cpp similarity index 96% rename from src/camera/CameraManager.cpp rename to src/input/camera/CameraManager.cpp index a8aa3da0..ffe30530 100644 --- a/src/camera/CameraManager.cpp +++ b/src/input/camera/CameraManager.cpp @@ -51,15 +51,15 @@ namespace CameraManager CapFormatInfo formatInfo; if (Cap_getFormatInfo(s_ctx, device, formatId, &formatInfo) != CAPRESULT_OK) continue; - cemuLog_log(LogType::Force, "{}: {} {}x{} @ {} fps, {} bpp", formatId, FourCC(formatInfo.fourcc), + cemuLog_log(LogType::InputAPI, "{}: {} {}x{} @ {} fps, {} bpp", formatId, FourCC(formatInfo.fourcc), formatInfo.width, formatInfo.height, formatInfo.fps, formatInfo.bpp); if (formatInfo.width == CAMERA_WIDTH && formatInfo.height == CAMERA_HEIGHT) { - cemuLog_log(LogType::Force, "Selected video format {}", formatId); + cemuLog_log(LogType::InputAPI, "Selected video format {}", formatId); return formatId; } } - cemuLog_log(LogType::Force, "Failed to find suitable video format"); + cemuLog_log(LogType::InputAPI, "Failed to find suitable video format"); return std::nullopt; } diff --git a/src/camera/CameraManager.h b/src/input/camera/CameraManager.h similarity index 100% rename from src/camera/CameraManager.h rename to src/input/camera/CameraManager.h diff --git a/src/camera/Rgb2Nv12.cpp b/src/input/camera/Rgb2Nv12.cpp similarity index 100% rename from src/camera/Rgb2Nv12.cpp rename to src/input/camera/Rgb2Nv12.cpp diff --git a/src/camera/Rgb2Nv12.h b/src/input/camera/Rgb2Nv12.h similarity index 100% rename from src/camera/Rgb2Nv12.h rename to src/input/camera/Rgb2Nv12.h