mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Fix EmulatorConfig
initialization order
`config` was being consumed much too early before it has a chance to call `load`. This caused GPU to read weird uninitialized data, and then `load` called, and then further initialization to occur based on default data and the data inside of `config.toml`. `EmulatorConfig` needs to be loaded in first before any sort of initialization happens, by adding a new constructor so that it can be initialized sooner.
This commit is contained in:
parent
ceff20f57f
commit
2c57936c50
4 changed files with 7 additions and 2 deletions
|
@ -8,6 +8,7 @@ struct EmulatorConfig {
|
||||||
bool shaderJitEnabled = false;
|
bool shaderJitEnabled = false;
|
||||||
RendererType rendererType = RendererType::OpenGL;
|
RendererType rendererType = RendererType::OpenGL;
|
||||||
|
|
||||||
|
EmulatorConfig(const std::filesystem::path& path);
|
||||||
void load(const std::filesystem::path& path);
|
void load(const std::filesystem::path& path);
|
||||||
void save(const std::filesystem::path& path);
|
void save(const std::filesystem::path& path);
|
||||||
};
|
};
|
|
@ -25,13 +25,13 @@ enum class ROMType {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Emulator {
|
class Emulator {
|
||||||
|
EmulatorConfig config;
|
||||||
CPU cpu;
|
CPU cpu;
|
||||||
GPU gpu;
|
GPU gpu;
|
||||||
Memory memory;
|
Memory memory;
|
||||||
Kernel kernel;
|
Kernel kernel;
|
||||||
Crypto::AESEngine aesEngine;
|
Crypto::AESEngine aesEngine;
|
||||||
|
|
||||||
EmulatorConfig config;
|
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_OPENGL
|
#ifdef PANDA3DS_ENABLE_OPENGL
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
// We are legally allowed, as per the author's wish, to use the above code without any licensing restrictions
|
// We are legally allowed, as per the author's wish, to use the above code without any licensing restrictions
|
||||||
// However we still want to follow the license as closely as possible and offer the proper attributions.
|
// However we still want to follow the license as closely as possible and offer the proper attributions.
|
||||||
|
|
||||||
|
EmulatorConfig::EmulatorConfig(const std::filesystem::path& path) { load(path); }
|
||||||
|
|
||||||
void EmulatorConfig::load(const std::filesystem::path& path) {
|
void EmulatorConfig::load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
|
|
|
@ -14,7 +14,9 @@ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, config), memory(cpu.getTicksRef()) {
|
Emulator::Emulator()
|
||||||
|
: config(std::filesystem::current_path() / "config.toml"), kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, config),
|
||||||
|
memory(cpu.getTicksRef()) {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
||||||
Helpers::panic("Failed to initialize SDL2");
|
Helpers::panic("Failed to initialize SDL2");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue