Skip to content

Commit ff242b3

Browse files
committed
Merge branch 'master' into jit-rs
2 parents 4d1ee0d + 636a1d1 commit ff242b3

21 files changed

+334
-107
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
run: |
6565
mkdir -p tmp
6666
cd tmp
67-
wget https://raw.githubusercontent.com/DragonMinded/libdragon/trunk/tools/chksum64.c
67+
wget https://raw.githubusercontent.com/DragonMinded/libdragon/8c4e8505778a5c84e5477394eddfb127ce44d71b/tools/chksum64.c
6868
gcc chksum64.c -o chksum64
6969
sudo mv chksum64 /bin/
7070
git clone https://github.com/ARM9/bass.git

flake.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
pkgs.bzip2
4242
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
4343
pkgs.darwin.apple_sdk.frameworks.Cocoa
44+
] ++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
45+
pkgs.qt6.qtbase # TODO: Qt should work on Darwin too
46+
pkgs.qt6.wrapQtAppsHook
4447
];
4548
stdenv =
4649
if pkgs.stdenv.isLinux then pkgs.stdenv
@@ -85,6 +88,7 @@
8588
postInstall =
8689
if pkgs.stdenv.isLinux then ''
8790
wrapProgram $out/bin/n64 --set LD_LIBRARY_PATH ${pkgs.vulkan-loader}/lib
91+
wrapProgram $out/bin/n64-qt --set LD_LIBRARY_PATH ${pkgs.vulkan-loader}/lib
8892
'' else if pkgs.stdenv.isDarwin then ''
8993
wrapProgram $out/bin/n64 --set DYLD_FALLBACK_LIBRARY_PATH ${pkgs.darwin.moltenvk}/lib
9094
'' else throw "Unsupported platform";
@@ -96,6 +100,11 @@
96100
program = "${self.packages.${system}.default}/bin/n64";
97101
};
98102

103+
apps.qt = {
104+
type = "app";
105+
program = "${self.packages.${system}.default}/bin/n64-qt";
106+
};
107+
99108
devShells.default = pkgs.mkShell.override { stdenv = stdenv; }
100109
{
101110
buildInputs = devShellTools ++ tools ++ libs;

src/contrib/UPSTREAM.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ https://github.com/btzy/nativefiledialog-extended
2020

2121
https://github.com/Themaister/parallel-rdp-standalone
2222

23-
7e5ad30b8c6e5b863c117997c459441649da9bc7
23+
d1cc912c5c47abaf9b6b155d3cd15255df65cf5b
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fe5becd13638873db90d46e7ba7d48255971f82a
1+
1f69c762be68feb9fcd5276d75acc6e5a6160a19

src/contrib/parallel-rdp/parallel-rdp-standalone/parallel-rdp/rdp_renderer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ bool Renderer::init_caps()
201201
LOGW("Current proprietary Intel Windows driver is tested to perform much better without 8/16-bit integer support.\n");
202202
allow_small_types = false;
203203
}
204+
else if (features.driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY_KHR)
205+
{
206+
LOGW("Current proprietary Qcom driver is known to be buggy with 8/16-bit integer arithmetic, disabling support for time being.\n");
207+
allow_small_types = false;
208+
}
204209

205210
// Intel ANV *must* use small integer arithmetic, or it doesn't pass test suite.
206211
}

src/contrib/parallel-rdp/parallel-rdp-standalone/vulkan/device.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,12 @@ void Device::init_workarounds()
889889
LOGW("Disabling pipeline cache control.\n");
890890
workarounds.broken_pipeline_cache_control = true;
891891
}
892+
else if (ext.driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY_KHR)
893+
{
894+
// Seems broken on this driver too. Compilation stutter galore ...
895+
LOGW("Disabling pipeline cache control.\n");
896+
workarounds.broken_pipeline_cache_control = true;
897+
}
892898

893899
if (sync2_workarounds)
894900
{

src/qt_frontend/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ add_executable(${N64_QT_TARGET}
88
mainwindow.cpp mainwindow.h mainwindow.ui
99
vulkan_pane.cpp vulkan_pane.h
1010
qt_wsi_platform.cpp qt_wsi_platform.h
11-
n64_emulator_thread.cpp n64_emulator_thread.h)
11+
n64_emulator_thread.cpp n64_emulator_thread.h
12+
../frontend/tas_movie.c
13+
../common/perf_map_file.c)
1214
target_link_libraries(${N64_TARGET}-qt Qt6::Widgets Qt6::Gui Qt6::Core common core parallel_rdp_wrapper parallel-rdp)
1315

1416
set_target_properties(${N64_QT_TARGET}
1517
PROPERTIES
1618
RUNTIME_OUTPUT_DIRECTORY "${N64_EXECUTABLE_OUTPUT_PATH}"
17-
)
19+
)
20+
install(TARGETS ${N64_QT_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

src/qt_frontend/mainwindow.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@
44
#include "ui_mainwindow.h"
55
#include "qt_wsi_platform.h"
66

7-
MainWindow::MainWindow(QWidget *parent)
7+
MainWindow::MainWindow(const char* rom_path, bool debug, bool interpreter, QWidget *parent)
88
: QMainWindow(parent) {
99
ui = new Ui::MainWindow();
1010
ui->setupUi(this);
11+
12+
vkPane = new VulkanPane();
13+
setCentralWidget(vkPane);
14+
vkPane->hide();
15+
16+
emulatorThread = std::make_unique<N64EmulatorThread>(vkPane->qtVkInstanceFactory.get(), vkPane->platform.get(), rom_path, debug, interpreter);
1117
}
1218

1319
void MainWindow::showEvent(QShowEvent *event) {
1420
QWidget::showEvent(event);
15-
16-
vkPane = new VulkanPane();
17-
vkPane->setSurfaceType(QSurface::VulkanSurface);
18-
setCentralWidget(QWidget::createWindowContainer(vkPane, this));
1921
}
2022

2123
void MainWindow::resetTriggered() {
22-
vkPane->getEmulatorThread().reset();
24+
emulatorThread->reset();
2325
}
2426

2527
void MainWindow::openFileTriggered() {
2628
auto filename = QFileDialog::getOpenFileName(this, "Load ROM", QString(), "N64 ROM files (*.z64 *.n64 *.v64)");
2729
if (!filename.isEmpty()) {
28-
vkPane->getEmulatorThread().loadRom(filename.toStdString());
30+
vkPane->show();
31+
emulatorThread->loadRom(filename.toStdString());
32+
emulatorThread->start();
2933
}
3034
}

src/qt_frontend/mainwindow.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ class MainWindow : public QMainWindow
2020
Q_OBJECT
2121

2222
public:
23-
explicit MainWindow(QWidget *parent = nullptr);
23+
explicit MainWindow(const char* rom_path = nullptr, bool debug = false, bool interpreter = false, QWidget *parent = nullptr);
2424
virtual ~MainWindow() {};
2525

2626
void showEvent(QShowEvent* event) override;
27+
std::unique_ptr<N64EmulatorThread> emulatorThread;
2728

2829
public slots:
2930
void resetTriggered();

src/qt_frontend/n64_emulator_thread.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <frontend/audio.h>
55
#include <frontend/render.h>
66
#include "n64_emulator_thread.h"
7+
8+
#include <QWindow>
9+
710
#include "qt_wsi_platform.h"
811

912
class QtParallelRdpWindowInfo : public ParallelRdpWindowInfo {
@@ -19,9 +22,9 @@ class QtParallelRdpWindowInfo : public ParallelRdpWindowInfo {
1922
QWindow* pane;
2023
};
2124

22-
N64EmulatorThread::N64EmulatorThread(QtWSIPlatform* wsiPlatform) {
23-
this->wsiPlatform = wsiPlatform;
24-
init_n64system(nullptr, true, false, QT_VULKAN_VIDEO_TYPE, false);
25+
N64EmulatorThread::N64EmulatorThread(Vulkan::InstanceFactory* instanceFactory, QtWSIPlatform* wsiPlatform, const char* rom_path, bool debug, bool interpreter)
26+
: wsiPlatform(wsiPlatform), instanceFactory(instanceFactory) {
27+
init_n64system(rom_path, true, debug, QT_VULKAN_VIDEO_TYPE, interpreter);
2528

2629
if (file_exists(PIF_ROM_PATH)) {
2730
logalways("Found PIF ROM at %s, loading", PIF_ROM_PATH);
@@ -32,32 +35,30 @@ N64EmulatorThread::N64EmulatorThread(QtWSIPlatform* wsiPlatform) {
3235
}
3336
}
3437

35-
void N64EmulatorThread::start() {
38+
void N64EmulatorThread::run() noexcept {
3639
if (n64_should_quit() || running) {
3740
logfatal("Tried to start emulator thread, but it was already running!");
3841
}
3942

40-
QtWSIPlatform* _wsiPlatform = this->wsiPlatform;
41-
QWindow* pane = wsiPlatform->getPane();
4243
running = true;
43-
bool* _game_loaded = &game_loaded;
44-
emuThread = std::thread([_wsiPlatform, pane, _game_loaded]() {
45-
init_vulkan_wsi(_wsiPlatform, std::make_unique<QtParallelRdpWindowInfo>(pane));
4644

47-
init_parallel_rdp();
45+
init_vulkan_wsi(instanceFactory, wsiPlatform, std::make_unique<QtParallelRdpWindowInfo>(wsiPlatform->getWindowHandle()));
4846

49-
while (!(*_game_loaded)) {
50-
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 60));
51-
prdp_update_screen_no_game();
52-
}
47+
init_parallel_rdp();
5348

54-
n64_system_loop();
55-
});
49+
while (!game_loaded) {
50+
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 60));
51+
prdp_update_screen_no_game();
52+
}
53+
54+
n64_system_loop();
5655
}
5756

5857
void N64EmulatorThread::reset() {
59-
if (running) {
60-
n64_queue_reset();
58+
if (game_loaded) {
59+
reset_n64system();
60+
n64_load_rom(n64sys.rom_path);
61+
pif_rom_execute();
6162
}
6263
}
6364

src/qt_frontend/n64_emulator_thread.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33

44
#undef signals
55
#include <wsi.hpp>
6+
#include <QThread>
67

78
class QtWSIPlatform;
8-
class N64EmulatorThread {
9-
public:
10-
explicit N64EmulatorThread(QtWSIPlatform* wsiPlatform);
11-
void start();
12-
void reset();
13-
void loadRom(const std::string& filename);
14-
15-
private:
9+
class N64EmulatorThread : public QThread {
10+
Q_OBJECT
1611
bool running = false;
1712
bool game_loaded = false;
1813
std::thread emuThread;
1914
QtWSIPlatform* wsiPlatform;
15+
Vulkan::InstanceFactory* instanceFactory;
16+
public:
17+
explicit N64EmulatorThread(Vulkan::InstanceFactory* instanceFactory, QtWSIPlatform* wsiPlatform, const char* rom_path = nullptr, bool debug = false, bool interpreter = false);
18+
void run() noexcept override;
19+
void reset();
20+
void loadRom(const std::string& filename);
2021
};
2122

2223

0 commit comments

Comments
 (0)