mirror of
https://github.com/SysRay/psOff_public.git
synced 2025-02-11 17:38:06 +00:00
boost as seperate prj, sdl polling on vblank
This commit is contained in:
parent
1797018783
commit
85897bfd95
@ -27,12 +27,12 @@ add_library(core SHARED
|
|||||||
$<TARGET_OBJECTS:dmem>
|
$<TARGET_OBJECTS:dmem>
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(core logging)
|
add_dependencies(core logging boost)
|
||||||
target_link_libraries(core PRIVATE
|
target_link_libraries(core PRIVATE
|
||||||
libboost_thread
|
libboost_thread
|
||||||
libboost_chrono
|
libboost_chrono
|
||||||
libboost_program_options
|
libboost_program_options
|
||||||
sdl2
|
sdl2
|
||||||
OptickCore
|
OptickCore
|
||||||
psOff_utility
|
psOff_utility
|
||||||
${Vulkan_LIBRARIES}
|
${Vulkan_LIBRARIES}
|
||||||
|
@ -7,4 +7,4 @@ add_library(kernel OBJECT
|
|||||||
semaphore.cpp
|
semaphore.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(kernel third_party)
|
add_dependencies(kernel third_party boost)
|
@ -545,7 +545,7 @@ std::pair<VkQueue, uint32_t> VideoOut::getQueue(vulkan::QueueType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cbWindow_close(SDL_Window* window) {
|
void cbWindow_close(SDL_Window* window) {
|
||||||
// SDL_DestroyWindow(window.window);
|
// SDL_DestroyWindow(window.window);
|
||||||
// Todo submit close event, cleanup
|
// Todo submit close event, cleanup
|
||||||
// m_stop = true;
|
// m_stop = true;
|
||||||
// lock.unlock();
|
// lock.unlock();
|
||||||
@ -567,7 +567,30 @@ std::thread VideoOut::createSDLThread() {
|
|||||||
LOG_USE_MODULE(VideoOut);
|
LOG_USE_MODULE(VideoOut);
|
||||||
LOG_DEBUG(L"Init SDL2 video");
|
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) {
|
while (!m_stop) {
|
||||||
std::unique_lock lock(m_mutexInt);
|
std::unique_lock lock(m_mutexInt);
|
||||||
@ -578,6 +601,8 @@ std::thread VideoOut::createSDLThread() {
|
|||||||
if (m_messages.empty()) {
|
if (m_messages.empty()) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
func_pollSDL(m_windows[0].window); // check only main for now
|
||||||
|
|
||||||
auto& timer = accessTimer();
|
auto& timer = accessTimer();
|
||||||
auto const curTime = (uint64_t)(1e6 * timer.getTimeS());
|
auto const curTime = (uint64_t)(1e6 * timer.getTimeS());
|
||||||
auto const procTime = timer.queryPerformance();
|
auto const procTime = timer.queryPerformance();
|
||||||
@ -598,12 +623,10 @@ std::thread VideoOut::createSDLThread() {
|
|||||||
|
|
||||||
auto const title = getTitle(index, 0, 0, window.fliprate);
|
auto const title = getTitle(index, 0, 0, window.fliprate);
|
||||||
|
|
||||||
window.window = SDL_CreateWindow(
|
window.window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_widthTotal, m_heightTotal,
|
||||||
title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN);
|
||||||
m_widthTotal, m_heightTotal, SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN
|
|
||||||
);
|
SDL_GetWindowSize(window.window, (int*)(&window.config.resolution.paneWidth), (int*)(&window.config.resolution.paneHeight));
|
||||||
|
|
||||||
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);
|
LOG_INFO(L"--> VideoOut Open(%S)| %d:%d", title.c_str(), window.config.resolution.paneWidth, window.config.resolution.paneHeight);
|
||||||
if (m_vulkanObj == nullptr) {
|
if (m_vulkanObj == nullptr) {
|
||||||
@ -619,7 +642,7 @@ std::thread VideoOut::createSDLThread() {
|
|||||||
m_condDone.notify_one();
|
m_condDone.notify_one();
|
||||||
} break;
|
} break;
|
||||||
case MessageType::close: {
|
case MessageType::close: {
|
||||||
SDL_DestroyWindow(window.window);
|
SDL_DestroyWindow(window.window);
|
||||||
*item.done = true;
|
*item.done = true;
|
||||||
m_condDone.notify_one();
|
m_condDone.notify_one();
|
||||||
} break;
|
} break;
|
||||||
@ -659,35 +682,15 @@ std::thread VideoOut::createSDLThread() {
|
|||||||
|
|
||||||
window.config.fps = fps;
|
window.config.fps = fps;
|
||||||
|
|
||||||
SDL_SetWindowTitle(window.window, title.c_str());
|
SDL_SetWindowTitle(window.window, title.c_str());
|
||||||
SDL_Event event;
|
func_pollSDL(window.window);
|
||||||
while (SDL_PollEvent(&event)) {
|
|
||||||
switch (event.type) {
|
|
||||||
case SDL_WINDOWEVENT:
|
|
||||||
switch (event.window.event) {
|
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
|
||||||
cbWindow_close(window.window);
|
|
||||||
break;
|
|
||||||
|
|
||||||
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);
|
LOG_TRACE(L"<- flip(%d) set:%u buffer:%u", index, item.index, window.config.flipStatus.currentBuffer);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
m_messages.pop();
|
m_messages.pop();
|
||||||
}
|
}
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ add_library(${libName} SHARED
|
|||||||
entry.cpp
|
entry.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} third_party)
|
add_dependencies(${libName} third_party boost)
|
||||||
|
|
||||||
target_compile_definitions(${libName} PRIVATE BOOST_ALL_NO_LIB)
|
target_compile_definitions(${libName} PRIVATE BOOST_ALL_NO_LIB)
|
||||||
target_link_libraries(${libName} PRIVATE libboost_thread psOff_utility)
|
target_link_libraries(${libName} PRIVATE libboost_thread psOff_utility)
|
||||||
|
@ -11,7 +11,7 @@ add_library(${libName} SHARED
|
|||||||
pthread.cpp
|
pthread.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
@ -6,7 +6,7 @@ project(${libName})
|
|||||||
|
|
||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
|
|
||||||
add_dependencies(${libName} third_party)
|
add_dependencies(${libName} third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
libboost_chrono
|
libboost_chrono
|
||||||
)
|
)
|
||||||
|
@ -15,7 +15,7 @@ add_library(${libName} SHARED
|
|||||||
pthread.cpp
|
pthread.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
@ -6,7 +6,7 @@ project(${libName})
|
|||||||
|
|
||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
19
third_party/CMakeLists.txt
vendored
19
third_party/CMakeLists.txt
vendored
@ -19,29 +19,12 @@ set_target_properties(OptickCore
|
|||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(SDL2
|
set_target_properties(SDL2
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
||||||
LIBRARY_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"
|
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(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
||||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
||||||
|
17
third_party/third_party.cmake
vendored
17
third_party/third_party.cmake
vendored
@ -9,4 +9,21 @@ ExternalProject_Add(third_party
|
|||||||
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
|
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
|
||||||
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
|
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
|
||||||
-DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}
|
-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}
|
||||||
)
|
)
|
@ -15,5 +15,5 @@ target_link_directories(dll2Nids PRIVATE
|
|||||||
${CMAKE_BINARY_DIR}/third_party/install/lib
|
${CMAKE_BINARY_DIR}/third_party/install/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(dll2Nids third_party)
|
add_dependencies(dll2Nids third_party boost)
|
||||||
target_link_libraries(dll2Nids libboost_container)
|
target_link_libraries(dll2Nids libboost_container)
|
Loading…
x
Reference in New Issue
Block a user