mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 23:55:40 +12:00
Hook shader JIT to config file
This commit is contained in:
parent
bc3377ac78
commit
1037f93f61
3 changed files with 13 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
@ -16,6 +18,7 @@ class GPU {
|
||||||
using Registers = std::array<u32, regNum>;
|
using Registers = std::array<u32, regNum>;
|
||||||
|
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
|
EmulatorConfig& config;
|
||||||
ShaderUnit shaderUnit;
|
ShaderUnit shaderUnit;
|
||||||
ShaderJIT shaderJIT; // Doesn't do anything if JIT is disabled or not supported
|
ShaderJIT shaderJIT; // Doesn't do anything if JIT is disabled or not supported
|
||||||
|
|
||||||
|
@ -81,7 +84,7 @@ class GPU {
|
||||||
// Set to false by the renderer when the lighting_lut is uploaded ot the GPU
|
// Set to false by the renderer when the lighting_lut is uploaded ot the GPU
|
||||||
bool lightingLUTDirty = false;
|
bool lightingLUTDirty = false;
|
||||||
|
|
||||||
GPU(Memory& mem, GLStateManager& gl);
|
GPU(Memory& mem, GLStateManager& gl, EmulatorConfig& config);
|
||||||
void initGraphicsContext() { renderer.initGraphicsContext(); }
|
void initGraphicsContext() { renderer.initGraphicsContext(); }
|
||||||
void getGraphicsContext() { renderer.getGraphicsContext(); }
|
void getGraphicsContext() { renderer.getGraphicsContext(); }
|
||||||
void display() { renderer.display(); }
|
void display() { renderer.display(); }
|
||||||
|
|
|
@ -12,7 +12,7 @@ using namespace Floats;
|
||||||
|
|
||||||
// Note: For when we have multiple backends, the GL state manager can stay here and have the constructor for the Vulkan-or-whatever renderer ignore it
|
// Note: For when we have multiple backends, the GL state manager can stay here and have the constructor for the Vulkan-or-whatever renderer ignore it
|
||||||
// Thus, our GLStateManager being here does not negatively impact renderer-agnosticness
|
// Thus, our GLStateManager being here does not negatively impact renderer-agnosticness
|
||||||
GPU::GPU(Memory& mem, GLStateManager& gl) : mem(mem), renderer(*this, gl, regs) {
|
GPU::GPU(Memory& mem, GLStateManager& gl, EmulatorConfig& config) : mem(mem), renderer(*this, gl, regs), config(config) {
|
||||||
vram = new u8[vramSize];
|
vram = new u8[vramSize];
|
||||||
mem.setVRAM(vram); // Give the bus a pointer to our VRAM
|
mem.setVRAM(vram); // Give the bus a pointer to our VRAM
|
||||||
}
|
}
|
||||||
|
@ -47,15 +47,15 @@ void GPU::reset() {
|
||||||
// Call the correct version of drawArrays based on whether this is an indexed draw (first template parameter)
|
// Call the correct version of drawArrays based on whether this is an indexed draw (first template parameter)
|
||||||
// And whether we are going to use the shader JIT (second template parameter)
|
// And whether we are going to use the shader JIT (second template parameter)
|
||||||
void GPU::drawArrays(bool indexed) {
|
void GPU::drawArrays(bool indexed) {
|
||||||
constexpr bool shaderJITEnabled = false; // TODO: Make a configurable option
|
const bool shaderJITEnabled = ShaderJIT::isAvailable() && config.shaderJitEnabled;
|
||||||
|
|
||||||
if (indexed) {
|
if (indexed) {
|
||||||
if constexpr (ShaderJIT::isAvailable() && shaderJITEnabled)
|
if (shaderJITEnabled)
|
||||||
drawArrays<true, true>();
|
drawArrays<true, true>();
|
||||||
else
|
else
|
||||||
drawArrays<true, false>();
|
drawArrays<true, false>();
|
||||||
} else {
|
} else {
|
||||||
if constexpr (ShaderJIT::isAvailable() && shaderJITEnabled)
|
if (shaderJITEnabled)
|
||||||
drawArrays<false, true>();
|
drawArrays<false, true>();
|
||||||
else
|
else
|
||||||
drawArrays<false, false>();
|
drawArrays<false, false>();
|
||||||
|
|
|
@ -10,7 +10,7 @@ _declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, gl), memory(cpu.getTicksRef()) {
|
Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, gl, 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");
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,13 @@ Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.load(std::filesystem::current_path() / "config.toml");
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Emulator::~Emulator() { config.save(std::filesystem::current_path() / "config.toml"); }
|
||||||
|
|
||||||
void Emulator::reset() {
|
void Emulator::reset() {
|
||||||
cpu.reset();
|
cpu.reset();
|
||||||
gpu.reset();
|
gpu.reset();
|
||||||
|
|
Loading…
Add table
Reference in a new issue