Easier solution: only run the actual emulation logic in the child thread; call Parallel-RDP in main thread. Still needs sync with RDRAM buffer (the GPU crashes now LMAO)

This commit is contained in:
SimoZ64
2025-05-22 23:18:39 +02:00
parent 326b4b43cd
commit ca21e57835
7 changed files with 95 additions and 77 deletions

View File

@@ -5,15 +5,9 @@
#include <ImGuiImpl/GUI.hpp>
KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_shared<n64::Core>()), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
while(!emuThread.parallelRDPInitialized);
gui::Initialize(core->parallel.wsi, window.getHandle());
emuExitFunc = [&]() {
quit = true;
if (emuThread.isRunning) {
emuThread.requestInterruption();
while (emuThread.isRunning) {}
}
};
about.setFunc([&]() {
@@ -28,7 +22,7 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
statusBar.setFunc([&]() {
ImGui::Text("GUI FPS: %.2f, Emulation FPS: %s", ImGui::GetIO().Framerate,
fmt::format(fpsCounter > 0 ? fmt::runtime("{:.2f{0}}") : fmt::runtime("{1}"), fpsCounter, "Not playing").c_str());
fmt::format(fpsCounter > 0 ? fmt::runtime("{0:.2f}") : fmt::runtime("{1}"), fpsCounter, "Not playing").c_str());
});
menuBar.addMenu({"File",
@@ -68,14 +62,16 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
void KaizenGui::RenderUI() {
gui::StartFrame();
menuBar.render();
about.render();
statusBar.render();
gui::EndFrame();
if (core->render) {
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi);
} else {
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi, false);
}
}
void KaizenGui::LoadROM(const std::string &path) noexcept {
@@ -91,7 +87,6 @@ void KaizenGui::LoadROM(const std::string &path) noexcept {
void KaizenGui::handleEvents() {
SDL_Event e;
while(SDL_PollEvent(&e)) {
ImGui_ImplSDL3_ProcessEvent(&e);
switch(e.type) {
case SDL_EVENT_QUIT:
emuExitFunc();
@@ -102,7 +97,13 @@ void KaizenGui::handleEvents() {
int KaizenGui::run() {
while(!quit) {
handleEvents();
if(vulkanWidget.wsiPlatform->quitRequested) {
quit = true;
if (emuThread.isRunning) {
emuThread.requestInterruption();
while (emuThread.isRunning) {}
}
}
RenderUI();
}