mirror of
https://gitlab.com/skmp/dca3-game.git
synced 2025-04-28 13:07:59 +03:00
Gave threads default attributes for RAM gainz.
Threads for sampman and the VMU profiler were created just using std::thread from C++11, which doesn't allow for configuration of its stack size or label. Wrote a small wrapper around KOS threads (and std::threads as fallback) which takes arguments for configuring thread label, stack size, and whether to detach it. 1) Added common/thread/thread.h/.c thread abstraction layer. 2) Updated Makefiles 3) VmuProfiler - averages only 10 frames now, which is avg FPS over a second - subclasses dc::Thread and only has a 2KB stack now - got a label for thread dumps 4) Sampman (liberty/miami) - now uses dc::Thread - now only needs 2KB stack size - got a label for thread dumps
This commit is contained in:
parent
2c7335f3f3
commit
9c64ecf8f3
6 changed files with 30 additions and 20 deletions
|
@ -268,6 +268,7 @@ RE3_OBJS = \
|
|||
../src/liberty/extras/screendroplets.o \
|
||||
\
|
||||
../src/common/vmu/vmu.o \
|
||||
../src/common/thread/thread.o \
|
||||
../vendor/miniLZO/minilzo.o \
|
||||
\
|
||||
|
||||
|
|
|
@ -284,7 +284,8 @@ RE3_OBJS = \
|
|||
\
|
||||
../vendor/miniLZO/minilzo.o \
|
||||
\
|
||||
../src/common/vmu/vmu.o
|
||||
../src/common/vmu/vmu.o \
|
||||
../src/common/thread/thread.o
|
||||
|
||||
# Excluded \
|
||||
../src/miami/extras/custompipes.o \
|
||||
|
|
|
@ -24,7 +24,6 @@ VmuProfiler *VmuProfiler::getInstance() {
|
|||
void VmuProfiler::destroyInstance() {
|
||||
if(instance_) {
|
||||
instance_->stopRequest_ = true;
|
||||
instance_->join();
|
||||
instance_.reset();
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +73,15 @@ float VmuProfiler::vertexBufferUtilization() {
|
|||
// ===== INSTANCE METHODS =====
|
||||
|
||||
VmuProfiler::VmuProfiler():
|
||||
std::thread(std::bind_front(&VmuProfiler::run, this))
|
||||
{}
|
||||
|
||||
VmuProfiler::~VmuProfiler() {
|
||||
stopRequest_ = true;
|
||||
}
|
||||
dc::Thread("VMU Profiler",
|
||||
1024 * 2,
|
||||
false,
|
||||
[](void *param) -> void* {
|
||||
static_cast<VmuProfiler*>(param)->run();
|
||||
return nullptr;
|
||||
},
|
||||
this)
|
||||
{}
|
||||
|
||||
void VmuProfiler::run() {
|
||||
while(!stopRequest_) {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "common.h"
|
||||
#include "sampman.h"
|
||||
|
||||
#include "thread/thread.h"
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
@ -40,13 +42,13 @@ public:
|
|||
~RAIIVmuBeeper();
|
||||
};
|
||||
|
||||
class VmuProfiler: public std::thread {
|
||||
class VmuProfiler: public dc::Thread {
|
||||
private:
|
||||
constexpr static auto updateRate_ = std::chrono::milliseconds(100);
|
||||
constexpr static size_t fpsSamples = 20;
|
||||
constexpr static size_t fpsSamples = 10;
|
||||
|
||||
static inline
|
||||
std::unique_ptr<VmuProfiler> instance_ = {};
|
||||
std::unique_ptr<VmuProfiler> instance_ = {};
|
||||
|
||||
mutable std::shared_mutex mtx_ = {};
|
||||
bool updated_ = false;
|
||||
|
@ -74,9 +76,6 @@ public:
|
|||
static VmuProfiler *getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
// Automatically signals thread to exit
|
||||
~VmuProfiler();
|
||||
|
||||
// To be called every frame, so we can update FPS stats too!
|
||||
void updateVertexBufferUsage();
|
||||
};
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "Frontend.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include "thread/thread.h"
|
||||
|
||||
#include <dc/spu.h>
|
||||
#include <dc/g2bus.h>
|
||||
#include <dc/sound/aica_comm.h>
|
||||
|
@ -312,7 +314,8 @@ static struct {
|
|||
// return si->buffer;
|
||||
// }
|
||||
|
||||
std::thread snd_thread;
|
||||
static dc::Thread snd_thread;
|
||||
|
||||
bool8
|
||||
cSampleManager::Initialise(void)
|
||||
{
|
||||
|
@ -345,8 +348,8 @@ cSampleManager::Initialise(void)
|
|||
|
||||
if (!InitialiseSampleBanks())
|
||||
return FALSE;
|
||||
|
||||
snd_thread = std::thread([]() {
|
||||
|
||||
snd_thread.spawn("Audio Streamer", 1024 * 2, true, [](void*) -> void* {
|
||||
for(;;) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(channel_mtx);
|
||||
|
@ -446,6 +449,7 @@ cSampleManager::Initialise(void)
|
|||
}
|
||||
thd_sleep(50);
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
nPedSfxReqNextId = 1;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "crossplatform.h"
|
||||
#include "thread/thread.h"
|
||||
|
||||
#if !defined(AUDIO_OAL) && !defined(AUDIO_MSS)
|
||||
#define verbosef(...) // dbglog(DBG_CRITICAL, __VA_ARGS__)
|
||||
|
@ -318,7 +319,8 @@ static struct {
|
|||
// return si->buffer;
|
||||
// }
|
||||
|
||||
std::thread snd_thread;
|
||||
static dc::Thread snd_thread;
|
||||
|
||||
bool8
|
||||
cSampleManager::Initialise(void)
|
||||
{
|
||||
|
@ -351,8 +353,8 @@ cSampleManager::Initialise(void)
|
|||
|
||||
if (!InitialiseSampleBanks())
|
||||
return FALSE;
|
||||
|
||||
snd_thread = std::thread([]() {
|
||||
|
||||
snd_thread.spawn("Audio Streamer", 1024 * 2, true, [](void*) -> void* {
|
||||
for(;;) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(channel_mtx);
|
||||
|
@ -452,6 +454,7 @@ cSampleManager::Initialise(void)
|
|||
}
|
||||
thd_sleep(50);
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
nPedSfxReqNextId = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue