mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 11:18:36 +12:00
Rewrite LLVM compilation progress dialog
Use a single dialog
This commit is contained in:
parent
a2253e840f
commit
b0ee369135
2 changed files with 169 additions and 89 deletions
|
@ -48,7 +48,6 @@
|
|||
#include "define_new_memleakdetect.h"
|
||||
|
||||
#include "PPUTranslator.h"
|
||||
#include "Modules/cellMsgDialog.h"
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
|
@ -67,7 +66,9 @@ const bool s_use_ssse3 =
|
|||
|
||||
extern u64 get_system_time();
|
||||
|
||||
|
||||
extern atomic_t<const char*> g_progr;
|
||||
extern atomic_t<u64> g_progr_ptotal;
|
||||
extern atomic_t<u64> g_progr_pdone;
|
||||
|
||||
enum class join_status : u32
|
||||
{
|
||||
|
@ -164,7 +165,7 @@ extern const ppu_decoder<ppu_interpreter_fast> g_ppu_interpreter_fast([](auto& t
|
|||
|
||||
extern void ppu_initialize();
|
||||
extern void ppu_initialize(const ppu_module& info);
|
||||
static void ppu_initialize2(class jit_compiler& jit, const ppu_module& module_part, const std::string& cache_path, const std::string& obj_name, u32 fragment_index, const std::shared_ptr<atomic_t<u32>>&);
|
||||
static void ppu_initialize2(class jit_compiler& jit, const ppu_module& module_part, const std::string& cache_path, const std::string& obj_name);
|
||||
extern void ppu_execute_syscall(ppu_thread& ppu, u64 code);
|
||||
|
||||
// Get pointer to executable cache
|
||||
|
@ -1337,6 +1338,9 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
}
|
||||
|
||||
#ifdef LLVM_AVAILABLE
|
||||
// Initialize progress dialog
|
||||
g_progr = "Compiling PPU modules...";
|
||||
|
||||
// Compiled PPU module info
|
||||
struct jit_module
|
||||
{
|
||||
|
@ -1380,10 +1384,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
// Difference between function name and current location
|
||||
const u32 reloc = info.name.empty() ? 0 : info.segs.at(0).addr;
|
||||
|
||||
std::shared_ptr<atomic_t<u32>> fragment_sync = std::make_shared<atomic_t<u32>>(0);
|
||||
|
||||
u32 fragment_count{0};
|
||||
|
||||
while (jit_mod.vars.empty() && fpos < info.funcs.size())
|
||||
{
|
||||
// Initialize compiler instance
|
||||
|
@ -1546,8 +1546,11 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
continue;
|
||||
}
|
||||
|
||||
// Update progress dialog
|
||||
g_progr_ptotal++;
|
||||
|
||||
// Create worker thread for compilation
|
||||
jthreads.emplace_back([&jit, obj_name = obj_name, part = std::move(part), &cache_path, fragment_sync, jcores, findex = ::size32(jthreads)]()
|
||||
jthreads.emplace_back([&jit, obj_name = obj_name, part = std::move(part), &cache_path, jcores]()
|
||||
{
|
||||
// Set low priority
|
||||
thread_ctrl::set_native_priority(-1);
|
||||
|
@ -1556,14 +1559,14 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
{
|
||||
semaphore_lock jlock(jcores->sem);
|
||||
|
||||
if (Emu.IsStopped())
|
||||
if (!Emu.IsStopped())
|
||||
{
|
||||
return;
|
||||
// Use another JIT instance
|
||||
jit_compiler jit2({}, g_cfg.core.llvm_cpu);
|
||||
ppu_initialize2(jit2, part, cache_path, obj_name);
|
||||
}
|
||||
|
||||
// Use another JIT instance
|
||||
jit_compiler jit2({}, g_cfg.core.llvm_cpu);
|
||||
ppu_initialize2(jit2, part, cache_path, obj_name, findex, fragment_sync);
|
||||
g_progr_pdone++;
|
||||
}
|
||||
|
||||
if (Emu.IsStopped() || !jit || !fs::is_file(cache_path + obj_name))
|
||||
|
@ -1577,9 +1580,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
});
|
||||
}
|
||||
|
||||
// Initialize fragment count sync var
|
||||
fragment_sync->exchange(::size32(jthreads));
|
||||
|
||||
// Join worker threads
|
||||
for (auto& thread : jthreads)
|
||||
{
|
||||
|
@ -1663,7 +1663,7 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, const std::string& cache_path, const std::string& obj_name, u32 fragment_index, const std::shared_ptr<atomic_t<u32>>& fragment_sync)
|
||||
static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, const std::string& cache_path, const std::string& obj_name)
|
||||
{
|
||||
#ifdef LLVM_AVAILABLE
|
||||
using namespace llvm;
|
||||
|
@ -1691,8 +1691,6 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<MsgDialogBase> dlg;
|
||||
|
||||
{
|
||||
legacy::FunctionPassManager pm(module.get());
|
||||
|
||||
|
@ -1716,25 +1714,6 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
|||
//pm.add(createCFGSimplificationPass());
|
||||
//pm.add(createLintPass()); // Check
|
||||
|
||||
// Initialize message dialog
|
||||
dlg = Emu.GetCallbacks().get_msg_dialog();
|
||||
dlg->type.se_normal = true;
|
||||
dlg->type.bg_invisible = true;
|
||||
dlg->type.progress_bar_count = 1;
|
||||
dlg->on_close = [](s32 status)
|
||||
{
|
||||
Emu.CallAfter([]()
|
||||
{
|
||||
// Abort everything
|
||||
Emu.Stop();
|
||||
});
|
||||
};
|
||||
|
||||
Emu.CallAfter([=]()
|
||||
{
|
||||
dlg->Create("Compiling PPU module:\n" + obj_name + "\nPlease wait...");
|
||||
});
|
||||
|
||||
// Translate functions
|
||||
for (size_t fi = 0, fmax = module_part.funcs.size(); fi < fmax; fi++)
|
||||
{
|
||||
|
@ -1746,18 +1725,6 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
|||
|
||||
if (module_part.funcs[fi].size)
|
||||
{
|
||||
// Update dialog
|
||||
Emu.CallAfter([=, max = module_part.funcs.size()]()
|
||||
{
|
||||
dlg->ProgressBarSetMsg(0, fmt::format("Compiling %u of %u", fi + 1, fmax));
|
||||
|
||||
if (fi * 100 / fmax != (fi + 1) * 100 / fmax)
|
||||
dlg->ProgressBarInc(0, 1);
|
||||
|
||||
if (u32 fragment_count = fragment_sync->load())
|
||||
dlg->SetMsg(fmt::format("Compiling PPU module (%u of %u):\n%s\nPlease wait...", fragment_index + 1, fragment_count, obj_name));
|
||||
});
|
||||
|
||||
// Translate
|
||||
if (const auto func = translator.Translate(module_part.funcs[fi]))
|
||||
{
|
||||
|
@ -1780,16 +1747,6 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
|||
//mpm.add(createDeadInstEliminationPass());
|
||||
//mpm.run(*module);
|
||||
|
||||
// Update dialog
|
||||
Emu.CallAfter([=]()
|
||||
{
|
||||
dlg->ProgressBarSetMsg(0, "Generating code, this may take a long time...");
|
||||
dlg->ProgressBarInc(0, 100);
|
||||
|
||||
if (u32 fragment_count = fragment_sync->load())
|
||||
dlg->SetMsg(fmt::format("Compiling PPU module (%u of %u):\n%s\nPlease wait...", fragment_index + 1, fragment_count, obj_name));
|
||||
});
|
||||
|
||||
std::string result;
|
||||
raw_string_ostream out(result);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue