make it single threaded for now...
Hmm don't quite get it idfk
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,3 +23,4 @@ disasm.txt
|
||||
CMakeSettings.json
|
||||
compile_commands.json
|
||||
*.diagsession
|
||||
tests/
|
||||
13
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
13
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
@@ -1,8 +1,7 @@
|
||||
#include <File.hpp>
|
||||
#include <ParallelRDPWrapper.hpp>
|
||||
#include <backend/Core.hpp>
|
||||
#include <memory>
|
||||
#include <rdp_device.hpp>
|
||||
#include <core/mmio/VI.hpp>
|
||||
#include <resources/vert.spv.h>
|
||||
#include <resources/frag.spv.h>
|
||||
#include <KaizenGui.hpp>
|
||||
@@ -159,10 +158,7 @@ void ParallelRDP::DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image,
|
||||
cmd->draw(3, 1);
|
||||
}
|
||||
|
||||
std::mutex coreM;
|
||||
|
||||
void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) const {
|
||||
std::lock_guard<std::mutex> coreLock(coreM);
|
||||
wsi->begin_frame();
|
||||
|
||||
if (!image) {
|
||||
@@ -188,16 +184,15 @@ void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) const {
|
||||
|
||||
cmd->begin_render_pass(wsi->get_device().get_swapchain_render_pass(SwapchainRenderPass::ColorOnly));
|
||||
DrawFullscreenTexturedQuad(image, cmd);
|
||||
auto drawData = ImGui::GetDrawData();
|
||||
if(drawData)
|
||||
ImGui_ImplVulkan_RenderDrawData(drawData, cmd->get_command_buffer());
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->get_command_buffer());
|
||||
cmd->end_render_pass();
|
||||
wsi->get_device().submit(cmd);
|
||||
wsi->end_frame();
|
||||
}
|
||||
|
||||
void ParallelRDP::UpdateScreen(const n64::VI &vi, bool playing) const {
|
||||
void ParallelRDP::UpdateScreen(n64::Core &core, bool playing) const {
|
||||
if(playing) {
|
||||
n64::VI& vi = core.GetVI();
|
||||
command_processor->set_vi_register(VIRegister::Control, vi.status.raw);
|
||||
command_processor->set_vi_register(VIRegister::Origin, vi.origin);
|
||||
command_processor->set_vi_register(VIRegister::Width, vi.width);
|
||||
|
||||
4
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
4
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
@@ -4,7 +4,7 @@
|
||||
#include <common.hpp>
|
||||
|
||||
namespace n64 {
|
||||
struct VI;
|
||||
struct Core;
|
||||
}
|
||||
|
||||
class ParallelRDP {
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
const std::shared_ptr<WindowInfo> &, const u8 *);
|
||||
ParallelRDP() = default;
|
||||
|
||||
void UpdateScreen(const n64::VI &, bool = true) const;
|
||||
void UpdateScreen(n64::Core &, bool = true) const;
|
||||
void EnqueueCommand(int, const u32 *) const;
|
||||
void OnFullSync() const;
|
||||
bool IsFramerateUnlocked() const;
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace n64 {
|
||||
Core::Core() : cpu(std::make_unique<Interpreter>(parallel)) {}
|
||||
|
||||
void Core::Stop() {
|
||||
render = false;
|
||||
pause = true;
|
||||
romLoaded = false;
|
||||
cpu->Reset();
|
||||
@@ -38,7 +37,6 @@ void Core::LoadROM(const std::string &rom_) {
|
||||
cpu->GetMem().LoadSRAM(cpu->GetMem().saveType, rom);
|
||||
cpu->GetMem().mmio.si.pif.Execute();
|
||||
pause = false;
|
||||
render = true;
|
||||
}
|
||||
|
||||
void Core::Run(float volumeL, float volumeR) {
|
||||
|
||||
@@ -19,7 +19,6 @@ struct Core {
|
||||
u32 breakpoint = 0;
|
||||
|
||||
bool pause = true;
|
||||
bool render = false;
|
||||
u32 cycles = 0;
|
||||
bool romLoaded = false;
|
||||
std::string rom;
|
||||
|
||||
@@ -6,8 +6,7 @@ EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, double &fps, Render
|
||||
SettingsWindow &settings) noexcept :
|
||||
renderWidget(renderWidget), core(core), settings(settings), fps(fps) {}
|
||||
|
||||
void EmuThread::start() noexcept {
|
||||
thread = std::thread([&]() {
|
||||
void EmuThread::run() noexcept {
|
||||
isRunning = true;
|
||||
|
||||
auto lastSample = std::chrono::high_resolution_clock::now();
|
||||
@@ -17,7 +16,6 @@ void EmuThread::start() noexcept {
|
||||
|
||||
fps = 1000.0 / avgFps;
|
||||
|
||||
while (!interruptionRequested) {
|
||||
const auto startFrameTime = std::chrono::high_resolution_clock::now();
|
||||
if (!core->pause) {
|
||||
core->Run(settings.getVolumeL(), settings.getVolumeR());
|
||||
@@ -34,7 +32,7 @@ void EmuThread::start() noexcept {
|
||||
elapsedSinceLastSample >= 1.0) {
|
||||
if (!oneSecondPassed) {
|
||||
oneSecondPassed = true;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
lastSample = endFrameTime;
|
||||
avgFps /= sampledFps;
|
||||
@@ -42,11 +40,6 @@ void EmuThread::start() noexcept {
|
||||
fps = 1000.0 / avgFps;
|
||||
}
|
||||
}
|
||||
SetRender(false);
|
||||
Stop();
|
||||
isRunning = false;
|
||||
});
|
||||
}
|
||||
|
||||
void EmuThread::TogglePause() const noexcept {
|
||||
core->TogglePause();
|
||||
@@ -55,8 +48,6 @@ void EmuThread::TogglePause() const noexcept {
|
||||
core->cpu->GetMem().mmio.si.pif.movie.GetFilename());
|
||||
}
|
||||
|
||||
void EmuThread::SetRender(const bool v) const noexcept { core->render = v; }
|
||||
|
||||
void EmuThread::Reset() const noexcept {
|
||||
core->pause = true;
|
||||
core->Stop();
|
||||
|
||||
@@ -14,9 +14,8 @@ class EmuThread final {
|
||||
public:
|
||||
explicit EmuThread(const std::shared_ptr<n64::Core> &, double &, RenderWidget &, SettingsWindow &) noexcept;
|
||||
|
||||
void start() noexcept;
|
||||
void run() noexcept;
|
||||
void TogglePause() const noexcept;
|
||||
void SetRender(bool v) const noexcept;
|
||||
void Reset() const noexcept;
|
||||
void Stop() const noexcept;
|
||||
void requestInterruption() { interruptionRequested = true; }
|
||||
@@ -25,5 +24,4 @@ public:
|
||||
std::shared_ptr<n64::Core> core;
|
||||
SettingsWindow &settings;
|
||||
double& fps;
|
||||
std::thread thread;
|
||||
};
|
||||
|
||||
@@ -150,6 +150,5 @@ namespace gui {
|
||||
}
|
||||
|
||||
inline void EndFrame() {
|
||||
ImGui::Render();
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,12 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
|
||||
{"Open", [&]() {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath path;
|
||||
nfdfilteritem_t filterItem = {"Nintendo 64 roms", "n64,z64,v64,N64,Z64,V64"};
|
||||
static const std::vector<nfdfilteritem_t> filterItems = {
|
||||
{"Nintendo 64 rom archive", "rar,RAR,tar,TAR,zip,ZIP,7z,7Z"},
|
||||
{"Nintendo 64 rom", "n64,z64,v64,N64,Z64,V64"}
|
||||
};
|
||||
|
||||
auto result = NFD::OpenDialog(path, &filterItem, 1);
|
||||
auto result = NFD::OpenDialog(path, filterItems.data(), filterItems.size());
|
||||
if(result == NFD_CANCEL) return;
|
||||
if(result == NFD_ERROR)
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
@@ -88,20 +91,24 @@ void KaizenGui::RenderUI() {
|
||||
menuBar.render();
|
||||
settingsWindow.render();
|
||||
about.render();
|
||||
gui::EndFrame();
|
||||
|
||||
if (core->render) {
|
||||
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi);
|
||||
} else {
|
||||
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi, false);
|
||||
ImGui::Render();
|
||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable){
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
|
||||
if(!core->pause) {
|
||||
core->parallel.UpdateScreen(*core.get());
|
||||
return;
|
||||
}
|
||||
|
||||
core->parallel.UpdateScreen(*core.get(), false);
|
||||
}
|
||||
|
||||
void KaizenGui::LoadROM(const std::string &path) noexcept {
|
||||
actionPause.setEnabled(true);
|
||||
actionReset.setEnabled(true);
|
||||
actionStop.setEnabled(true);
|
||||
emuThread.start();
|
||||
emuThread.core->LoadROM(path);
|
||||
const auto gameNameDB = emuThread.core->cpu->GetMem().rom.gameNameDB;
|
||||
Util::RPC::GetInstance().Update(Util::RPC::Playing, gameNameDB);
|
||||
@@ -114,6 +121,7 @@ int KaizenGui::run() {
|
||||
}
|
||||
|
||||
RenderUI();
|
||||
emuThread.run();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user