Debug: Apply SPU Profiling data if debug enabled

This commit is contained in:
Elad 2025-10-12 10:00:13 +03:00
parent f3f6186a75
commit 149455aad1
4 changed files with 13 additions and 9 deletions

View file

@ -659,7 +659,7 @@ void cpu_thread::operator()()
}
case thread_class::spu:
{
if (g_cfg.core.spu_prof)
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
g_fxo->get<cpu_profiler>().registered.push(id);
}
@ -1546,7 +1546,7 @@ void cpu_thread::flush_profilers() noexcept
return;
}
if (g_cfg.core.spu_prof)
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
g_fxo->get<cpu_profiler>().registered.push(0);
}

View file

@ -186,7 +186,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
c->cmp(SPU_OFF_32(state), 0);
c->jnz(label_stop);
if (g_cfg.core.spu_prof && g_cfg.core.spu_verification)
if ((g_cfg.core.spu_prof || g_cfg.core.spu_debug) && g_cfg.core.spu_verification)
{
c->mov(x86::rax, m_hash_start & -0xffff);
c->mov(SPU_OFF_64(block_hash), x86::rax);
@ -755,7 +755,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
c->add(SPU_OFF_64(block_counter), ::size32(words) / (words_align / 4));
// Set block hash for profiling (if enabled)
if (g_cfg.core.spu_prof)
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
c->mov(x86::rax, m_hash_start | 0xffff);
c->mov(SPU_OFF_64(block_hash), x86::rax);
@ -1199,7 +1199,7 @@ void spu_recompiler::branch_set_link(u32 target)
c->movdqa(x86::dqword_ptr(*cpu, *qw1, 0, ::offset32(&spu_thread::stack_mirror)), x86::xmm0);
// Set block hash for profiling (if enabled)
if (g_cfg.core.spu_prof)
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
c->mov(x86::rax, m_hash_start | 0xffff);
c->mov(SPU_OFF_64(block_hash), x86::rax);

View file

@ -1632,7 +1632,7 @@ public:
m_ir->SetInsertPoint(label_test);
// Set block hash for profiling (if enabled)
if (g_cfg.core.spu_prof && g_cfg.core.spu_verification)
if ((g_cfg.core.spu_prof || g_cfg.core.spu_debug) && g_cfg.core.spu_verification)
m_ir->CreateStore(m_ir->getInt64((m_hash_start & -65536)), spu_ptr(&spu_thread::block_hash));
if (!g_cfg.core.spu_verification)
@ -1989,7 +1989,7 @@ public:
set_function(m_functions[m_entry].chunk);
// Set block hash for profiling (if enabled)
if (g_cfg.core.spu_prof)
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
m_ir->CreateStore(m_ir->getInt64((m_hash_start & -65536) | (m_entry >> 2)), spu_ptr(&spu_thread::block_hash));
m_finfo = &m_functions[m_entry];

View file

@ -1612,10 +1612,14 @@ std::string spu_thread::dump_misc() const
fmt::append(ret, "Block Weight: %u (Retreats: %u)", block_counter, block_failure);
if (g_cfg.core.spu_prof)
if (u64 hash = atomic_storage<u64>::load(block_hash))
{
// Get short function hash and position in chunk
fmt::append(ret, "\nCurrent block: %s", spu_block_hash{atomic_storage<u64>::load(block_hash)});
fmt::append(ret, "\nCurrent block: %s", spu_block_hash{hash});
}
else if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
fmt::append(ret, "\nCurrent block: N/A");
}
const u32 offset = group ? SPU_FAKE_BASE_ADDR + (id & 0xffffff) * SPU_LS_SIZE : RAW_SPU_BASE_ADDR + index * RAW_SPU_OFFSET;