more multi-thread fixes

don't use static on acquire()
don't yield at all
run fillBuf() on thread
fix option tooltip as it introduces some overhead
This commit is contained in:
tildearrow 2023-09-07 00:48:26 -05:00
parent 64669e4d9b
commit 1a520dbf3e
14 changed files with 33 additions and 29 deletions

View file

@ -80,7 +80,7 @@ const char** DivPlatformAmiga::getRegisterSheet() {
}
void DivPlatformAmiga::acquire(short** buf, size_t len) {
static int outL, outR, output;
thread_local int outL, outR, output;
for (size_t h=0; h<len; h++) {
bool hsync=bypassLimits;
outL=0;

View file

@ -52,7 +52,7 @@ const char** DivPlatformArcade::getRegisterSheet() {
}
void DivPlatformArcade::acquire_nuked(short** buf, size_t len) {
static int o[2];
thread_local int o[2];
for (size_t h=0; h<len; h++) {
for (int i=0; i<8; i++) {
@ -92,7 +92,7 @@ void DivPlatformArcade::acquire_nuked(short** buf, size_t len) {
}
void DivPlatformArcade::acquire_ymfm(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2151::fm_engine* fme=fm_ymfm->debug_engine();

View file

@ -132,8 +132,8 @@ void DivPlatformGenesis::processDAC(int iRate) {
}
void DivPlatformGenesis::acquire_nuked(short** buf, size_t len) {
static short o[2];
static int os[2];
thread_local short o[2];
thread_local int os[2];
for (size_t h=0; h<len; h++) {
processDAC(rate);
@ -213,7 +213,7 @@ void DivPlatformGenesis::acquire_nuked(short** buf, size_t len) {
}
void DivPlatformGenesis::acquire_ymfm(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2612::fm_engine* fme=fm_ymfm->debug_engine();

View file

@ -160,9 +160,9 @@ const int orderedOpsL[4]={
#define ADDR_LR_FB_ALG 0xc0
void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
static short o[4];
static int os[4];
static ymfm::ymfm_output<2> aOut;
thread_local short o[4];
thread_local int os[4];
thread_local ymfm::ymfm_output<2> aOut;
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0; os[2]=0; os[3]=0;

View file

@ -43,8 +43,8 @@ const unsigned char visMapOPLL[9]={
};
void DivPlatformOPLL::acquire_nuked(short** buf, size_t len) {
static int o[2];
static int os;
thread_local int o[2];
thread_local int os;
for (size_t h=0; h<len; h++) {
os=0;

View file

@ -27,7 +27,7 @@
#define chWrite(c,a,v) rWrite(((c)<<3)+(a),v)
void DivPlatformSegaPCM::acquire(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {

View file

@ -58,7 +58,7 @@ const char** DivPlatformTX81Z::getRegisterSheet() {
}
void DivPlatformTX81Z::acquire(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2414::fm_engine* fme=fm_ymfm->debug_engine();

View file

@ -165,8 +165,8 @@ void DivPlatformYM2203::acquire(short** buf, size_t len) {
}
void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
static int os;
static short ignored[2];
thread_local int os;
thread_local short ignored[2];
for (size_t h=0; h<len; h++) {
// AY -> OPN
@ -241,7 +241,7 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
}
void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
static int os;
thread_local int os;
ymfm::ym2203::fm_engine* fme=fm->debug_fm_engine();

View file

@ -306,8 +306,8 @@ void DivPlatformYM2608::acquire(short** buf, size_t len) {
}
void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
thread_local int os[2];
thread_local short ignored[2];
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();
ymfm::adpcm_a_engine* aae=fm->debug_adpcm_a_engine();
@ -419,7 +419,7 @@ void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
}
void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2608::fm_engine* fme=fm->debug_fm_engine();
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();

View file

@ -241,8 +241,8 @@ void DivPlatformYM2610::acquire(short** buf, size_t len) {
}
void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
thread_local int os[2];
thread_local short ignored[2];
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();
ymfm::adpcm_a_engine* aae=fm->debug_adpcm_a_engine();
@ -350,7 +350,7 @@ void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
}
void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2610::fm_engine* fme=fm->debug_fm_engine();
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();

View file

@ -305,8 +305,8 @@ void DivPlatformYM2610B::acquire(short** buf, size_t len) {
}
void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
thread_local int os[2];
thread_local short ignored[2];
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();
ymfm::adpcm_a_engine* aae=fm->debug_adpcm_a_engine();
@ -418,7 +418,7 @@ void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
}
void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
static int os[2];
thread_local int os[2];
ymfm::ym2610b::fm_engine* fme=fm->debug_fm_engine();
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();

View file

@ -2115,8 +2115,12 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
logW("%d: size<lastAvail! %d<%d",i,size,disCont[i].lastAvail);
continue;
}
disCont[i].fillBuf(disCont[i].runtotal,disCont[i].lastAvail,size-disCont[i].lastAvail);
renderPool->push([](void* d) {
DivDispatchContainer* dc=(DivDispatchContainer*)d;
dc->fillBuf(dc->runtotal,dc->lastAvail,dc->size-dc->lastAvail);
},&disCont[i]);
}
renderPool->wait();
}
if (metroBufLen<size || metroBuf==NULL) {

View file

@ -41,7 +41,7 @@ void DivWorkThread::run() {
if (setFuckingPromise) {
parent->notify.set_value();
setFuckingPromise=false;
std::this_thread::yield();
//std::this_thread::yield();
}
if (terminate) {
break;
@ -153,7 +153,7 @@ void DivWorkPool::wait() {
}
}
}
std::this_thread::yield();
//std::this_thread::yield();
// wait
future.wait();

View file

@ -902,7 +902,7 @@ void FurnaceGUI::drawSettings() {
}
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("runs chip emulation on separate threads.\nmay increase performance on multi-core CPUs.\n\nwarnings:\n- experimental! currently broken/not working well.\n- only useful on multi-chip songs.");
ImGui::SetTooltip("runs chip emulation on separate threads.\nmay increase performance when using heavy emulation cores.\n\nwarnings:\n- experimental!\n- only useful on multi-chip songs.");
}
if (renderPoolThreadsB) {