diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 4cc48b7..8f5ebbc 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -27,12 +27,12 @@ add_library(core SHARED $ ) -add_dependencies(core logging) +add_dependencies(core logging boost) target_link_libraries(core PRIVATE libboost_thread libboost_chrono libboost_program_options - sdl2 + sdl2 OptickCore psOff_utility ${Vulkan_LIBRARIES} diff --git a/core/kernel/CMakeLists.txt b/core/kernel/CMakeLists.txt index a249e71..a4669c8 100644 --- a/core/kernel/CMakeLists.txt +++ b/core/kernel/CMakeLists.txt @@ -7,4 +7,4 @@ add_library(kernel OBJECT semaphore.cpp ) -add_dependencies(kernel third_party) \ No newline at end of file +add_dependencies(kernel third_party boost) \ No newline at end of file diff --git a/core/videoout/videoout.cpp b/core/videoout/videoout.cpp index a84b8a8..5df7fca 100644 --- a/core/videoout/videoout.cpp +++ b/core/videoout/videoout.cpp @@ -545,7 +545,7 @@ std::pair VideoOut::getQueue(vulkan::QueueType type) { } void cbWindow_close(SDL_Window* window) { - // SDL_DestroyWindow(window.window); + // SDL_DestroyWindow(window.window); // Todo submit close event, cleanup // m_stop = true; // lock.unlock(); @@ -567,7 +567,30 @@ std::thread VideoOut::createSDLThread() { LOG_USE_MODULE(VideoOut); LOG_DEBUG(L"Init SDL2 video"); - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); + + // SDL polling helper + auto func_pollSDL = [](auto& window) { + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_WINDOWEVENT: + switch (event.window.event) { + case SDL_WINDOWEVENT_CLOSE: cbWindow_close(window); break; + + default: break; + } + + case SDL_KEYUP: + if (event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { + cbWindow_close(window); + } + + default: break; + } + } + }; + // - while (!m_stop) { std::unique_lock lock(m_mutexInt); @@ -578,6 +601,8 @@ std::thread VideoOut::createSDLThread() { if (m_messages.empty()) { using namespace std::chrono; + func_pollSDL(m_windows[0].window); // check only main for now + auto& timer = accessTimer(); auto const curTime = (uint64_t)(1e6 * timer.getTimeS()); auto const procTime = timer.queryPerformance(); @@ -598,12 +623,10 @@ std::thread VideoOut::createSDLThread() { auto const title = getTitle(index, 0, 0, window.fliprate); - window.window = SDL_CreateWindow( - title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - m_widthTotal, m_heightTotal, SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN - ); - - SDL_GetWindowSize(window.window, (int*)(&window.config.resolution.paneWidth), (int*)(&window.config.resolution.paneHeight)); + window.window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_widthTotal, m_heightTotal, + SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN); + + SDL_GetWindowSize(window.window, (int*)(&window.config.resolution.paneWidth), (int*)(&window.config.resolution.paneHeight)); LOG_INFO(L"--> VideoOut Open(%S)| %d:%d", title.c_str(), window.config.resolution.paneWidth, window.config.resolution.paneHeight); if (m_vulkanObj == nullptr) { @@ -619,7 +642,7 @@ std::thread VideoOut::createSDLThread() { m_condDone.notify_one(); } break; case MessageType::close: { - SDL_DestroyWindow(window.window); + SDL_DestroyWindow(window.window); *item.done = true; m_condDone.notify_one(); } break; @@ -659,35 +682,15 @@ std::thread VideoOut::createSDLThread() { window.config.fps = fps; - SDL_SetWindowTitle(window.window, title.c_str()); - SDL_Event event; - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_WINDOWEVENT: - switch (event.window.event) { - case SDL_WINDOWEVENT_CLOSE: - cbWindow_close(window.window); - break; + SDL_SetWindowTitle(window.window, title.c_str()); + func_pollSDL(window.window); - default: - break; - } - - case SDL_KEYUP: - if (event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { - cbWindow_close(window.window); - } - - default: - break; - } - } LOG_TRACE(L"<- flip(%d) set:%u buffer:%u", index, item.index, window.config.flipStatus.currentBuffer); } break; } m_messages.pop(); } - SDL_Quit(); + SDL_Quit(); }); } diff --git a/modules/libSceCoredump/CMakeLists.txt b/modules/libSceCoredump/CMakeLists.txt index 29fc553..9c09ee3 100644 --- a/modules/libSceCoredump/CMakeLists.txt +++ b/modules/libSceCoredump/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(${libName} SHARED entry.cpp ) -add_dependencies(${libName} third_party) +add_dependencies(${libName} third_party boost) target_compile_definitions(${libName} PRIVATE BOOST_ALL_NO_LIB) target_link_libraries(${libName} PRIVATE libboost_thread psOff_utility) diff --git a/modules/libScePosix/CMakeLists.txt b/modules/libScePosix/CMakeLists.txt index 2e4e085..709db32 100644 --- a/modules/libScePosix/CMakeLists.txt +++ b/modules/libScePosix/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(${libName} SHARED pthread.cpp ) -add_dependencies(${libName} core third_party) +add_dependencies(${libName} core third_party boost) target_link_libraries(${libName} PRIVATE core.lib libboost_thread diff --git a/modules/libSceRtc/CMakeLists.txt b/modules/libSceRtc/CMakeLists.txt index 80adb3d..b48f3e2 100644 --- a/modules/libSceRtc/CMakeLists.txt +++ b/modules/libSceRtc/CMakeLists.txt @@ -6,7 +6,7 @@ project(${libName}) add_library(${libName} SHARED entry.cpp) -add_dependencies(${libName} third_party) +add_dependencies(${libName} third_party boost) target_link_libraries(${libName} PRIVATE libboost_chrono ) diff --git a/modules/libkernel/CMakeLists.txt b/modules/libkernel/CMakeLists.txt index 45a262f..a7b41b3 100644 --- a/modules/libkernel/CMakeLists.txt +++ b/modules/libkernel/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(${libName} SHARED pthread.cpp ) -add_dependencies(${libName} core third_party) +add_dependencies(${libName} core third_party boost) target_link_libraries(${libName} PRIVATE core.lib libboost_thread diff --git a/modules/libkernel_unity/CMakeLists.txt b/modules/libkernel_unity/CMakeLists.txt index 0199a61..0e0c531 100644 --- a/modules/libkernel_unity/CMakeLists.txt +++ b/modules/libkernel_unity/CMakeLists.txt @@ -6,7 +6,7 @@ project(${libName}) add_library(${libName} SHARED entry.cpp) -add_dependencies(${libName} core third_party) +add_dependencies(${libName} core third_party boost) target_link_libraries(${libName} PRIVATE core.lib libboost_thread diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index d4dd32c..bcd3fb9 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -19,29 +19,12 @@ set_target_properties(OptickCore ) set_target_properties(SDL2 - PROPERTIES + PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/bin" ) -# Boost -set(BOOST_INCLUDE_LIBRARIES "program_options;date_time;interprocess;stacktrace;uuid;beast;signals2;thread") -ExternalProject_Add(boost_thirdParty - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost - CMAKE_ARGS - -DCMAKE_BUILD_TYPE:STRING=Release - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install - -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} - -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} - -DBoost_USE_STATIC_LIBS=ON - -DBoost_USE_MULTITHREADED=ON - -DBUILD_TESTING=OFF - -DBOOST_INSTALL_LAYOUT=system - CMAKE_CACHE_ARGS -DBOOST_INCLUDE_LIBRARIES:STRING=${BOOST_INCLUDE_LIBRARIES} -) - option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF) option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF) diff --git a/third_party/third_party.cmake b/third_party/third_party.cmake index 6465173..b0a0ace 100644 --- a/third_party/third_party.cmake +++ b/third_party/third_party.cmake @@ -9,4 +9,21 @@ ExternalProject_Add(third_party -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS} +) + +set(BOOST_INCLUDE_LIBRARIES "program_options;date_time;interprocess;stacktrace;uuid;beast;signals2;thread") +ExternalProject_Add(boost + SOURCE_DIR ${PRJ_SRC_DIR}/third_party/boost + BINARY_DIR ${CMAKE_BINARY_DIR}/third_party/boost + CMAKE_ARGS + -DCMAKE_BUILD_TYPE:STRING=Release + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/third_party/install + -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} + -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} + -DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS} + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_MULTITHREADED=ON + -DBUILD_TESTING=OFF + -DBOOST_INSTALL_LAYOUT=system + CMAKE_CACHE_ARGS -DBOOST_INCLUDE_LIBRARIES:STRING=${BOOST_INCLUDE_LIBRARIES} ) \ No newline at end of file diff --git a/tools/dll2nids/CMakeLists.txt b/tools/dll2nids/CMakeLists.txt index d5f8522..1b6104c 100644 --- a/tools/dll2nids/CMakeLists.txt +++ b/tools/dll2nids/CMakeLists.txt @@ -15,5 +15,5 @@ target_link_directories(dll2Nids PRIVATE ${CMAKE_BINARY_DIR}/third_party/install/lib ) -add_dependencies(dll2Nids third_party) +add_dependencies(dll2Nids third_party boost) target_link_libraries(dll2Nids libboost_container) \ No newline at end of file