From: notaz Date: Sun, 22 Feb 2026 23:40:13 +0000 (+0200) Subject: 3ds: use proper stack size for drc thread X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc318b2398b2686509e66ad24dfec13f52684915;p=pcsx_rearmed.git 3ds: use proper stack size for drc thread --- diff --git a/frontend/pcsxr-threads.c b/frontend/pcsxr-threads.c index 1c1ff2e6..78472526 100644 --- a/frontend/pcsxr-threads.c +++ b/frontend/pcsxr-threads.c @@ -6,6 +6,7 @@ #include <3ds/os.h> #include <3ds/services/apt.h> #include +#include "../libpcsxcore/new_dynarec/new_dynarec.h" #endif #include "../deps/libretro-common/rthreads/rthreads.c" @@ -45,6 +46,7 @@ sthread_t *pcsxr_sthread_create(void (*thread_func)(void *), { sthread_t *h = NULL; #ifdef _3DS + size_t stack_size = 64*1024; Thread ctr_thread; int core_id = 0; s32 prio = 0x30; @@ -61,6 +63,8 @@ sthread_t *pcsxr_sthread_create(void (*thread_func)(void *), core_id = 1; break; case PCSXRT_DRC: + stack_size = new_dynarec_estimate_stack_size(); + // fallthrough case PCSXRT_GPU: core_id = is_new_3ds ? 2 : 1; break; @@ -68,18 +72,19 @@ sthread_t *pcsxr_sthread_create(void (*thread_func)(void *), break; } - ctr_thread = threadCreate(thread_func, NULL, STACKSIZE, prio, core_id, false); + ctr_thread = threadCreate(thread_func, NULL, stack_size, prio, core_id, false); if (!ctr_thread) { if (core_id == 1) { SysPrintf("threadCreate pcsxt %d core %d failed\n", type, core_id); core_id = is_new_3ds ? 2 : -1; - ctr_thread = threadCreate(thread_func, NULL, STACKSIZE, + ctr_thread = threadCreate(thread_func, NULL, stack_size, prio, core_id, false); } } + SysPrintf("threadCreate: pcsxt %d core %d stack %zd: %p\n", + type, core_id, stack_size, ctr_thread); if (!ctr_thread) { - SysPrintf("threadCreate pcsxt %d core %d failed\n", type, core_id); free(h); return NULL; } diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 004d0363..ecef746f 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -6715,6 +6715,12 @@ void new_dynarec_print_stats(void) #endif } +int new_dynarec_estimate_stack_size(void) +{ + // see: pass6_clean_registers + return (sizeof(struct compile_state) + (4+4) * MAXBLOCK + 20 * 1024) & ~4095; +} + static void force_intcall(int i) { memset(&dops[i], 0, sizeof(dops[i])); diff --git a/libpcsxcore/new_dynarec/new_dynarec.h b/libpcsxcore/new_dynarec/new_dynarec.h index 0d3a6868..c5978218 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.h +++ b/libpcsxcore/new_dynarec/new_dynarec.h @@ -36,6 +36,7 @@ void new_dynarec_clear_full(void); int new_dynarec_save_blocks(void *save, int size); void new_dynarec_load_blocks(const void *save, int size); void new_dynarec_print_stats(void); +int new_dynarec_estimate_stack_size(void); int new_dynarec_quick_check_range(unsigned int start, unsigned int end); void new_dynarec_invalidate_range(unsigned int start, unsigned int end);