Merge per-chunk water surfaces, restore incremental tile finalization, and pin main thread CPU affinity

Water deduplication: merge per-chunk water surfaces into per-tile surfaces
to reduce Vulkan descriptor set usage from ~8900 to ~100-200. Uses hybrid
approach — groups with ≤4 chunks stay per-chunk (preserving shore detail),
larger groups merge into 128×128 tile-wide surfaces.

Re-add incremental tile finalization state machine (reverted in 9b90ab0)
to spread GPU uploads across frames and prevent city stuttering.

Pin main thread to CPU core 0 and exclude worker threads from core 0
to reduce scheduling jitter on the render/game loop.
This commit is contained in:
Kelsi 2026-02-25 03:39:45 -08:00
parent 7ca9caa212
commit 86505ad377
5 changed files with 629 additions and 314 deletions

View file

@ -55,6 +55,12 @@
#include <set>
#include <filesystem>
#include <thread>
#ifdef __linux__
#include <sched.h>
#include <pthread.h>
#endif
namespace wowee {
namespace core {
@ -230,6 +236,26 @@ bool Application::initialize() {
void Application::run() {
LOG_INFO("Starting main loop");
// Pin main thread to a dedicated CPU core to reduce scheduling jitter
#ifdef __linux__
{
int numCores = static_cast<int>(std::thread::hardware_concurrency());
if (numCores >= 2) {
// Use core 0 for the main thread (typically the highest-clocked core)
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (rc == 0) {
LOG_INFO("Main thread pinned to CPU core 0 (", numCores, " cores available)");
} else {
LOG_WARNING("Failed to pin main thread to CPU core 0 (error ", rc, ")");
}
}
}
#endif
const bool frameProfileEnabled = envFlagEnabled("WOWEE_FRAME_PROFILE", false);
if (frameProfileEnabled) {
LOG_INFO("Frame timing profile enabled (WOWEE_FRAME_PROFILE=1)");