Files
Thomas MartinandClaude Opus 5.5 95b7378f98 Texture workers at the lowest priority; no upscale while a replacement loads
The upscaler's and the replacements' worker threads now run at the
lowest thread priority (Windows THREAD_PRIORITY_LOWEST, nice 10
elsewhere), so making a level's copies never takes a core from the game
or the present thread. A texture whose replacement is being read no
longer gets an upscaled copy too (with a full pack every texture was
made twice at a level's start). PS2X_TEXTURE_STATS also counts the
uploads since its last line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-10 16:53:31 +01:00

29 lines
717 B
C++

// SPDX-License-Identifier: MIT
// Copyright (c) 2026 The Bozos (boubou666 and Arzaroth). MIT licence (see LICENSE at the repository root).
//
// bozo/render/worker_priority.h.
#include "bozo/render/worker_priority.h"
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#else
#include <sys/resource.h>
#include <sys/syscall.h>
#include <unistd.h>
#endif
namespace bozo::render
{
void lowerWorkerPriority()
{
#if defined(_WIN32)
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
#elif defined(SYS_gettid)
setpriority(PRIO_PROCESS, static_cast<id_t>(syscall(SYS_gettid)), 10); // Linux: a thread's own nice value
#endif
}
}