mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-12 09:09:47 +12:00
Format stuff
This commit is contained in:
parent
a4fcb1c4dc
commit
2849cc3798
12 changed files with 145 additions and 177 deletions
|
@ -220,7 +220,10 @@ namespace PICA {
|
|||
}
|
||||
|
||||
// If this fails you probably added a new field to the struct and forgot to update the copy constructor
|
||||
static_assert(sizeof(FragmentConfig) == sizeof(outConfig.raw) + sizeof(texConfig) + sizeof(fogConfig.raw) + sizeof(lighting.raw) + 7 * sizeof(LightingLUTConfig) + 8 * sizeof(Light));
|
||||
static_assert(
|
||||
sizeof(FragmentConfig) == sizeof(outConfig.raw) + sizeof(texConfig) + sizeof(fogConfig.raw) + sizeof(lighting.raw) +
|
||||
7 * sizeof(LightingLUTConfig) + 8 * sizeof(Light)
|
||||
);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
#include "PICA/pica_vertex.hpp"
|
||||
#include "PICA/regs.hpp"
|
||||
|
|
|
@ -3,31 +3,27 @@
|
|||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
#include "opengl.hpp"
|
||||
#include "renderer_gl/renderer_gl.hpp"
|
||||
#include "PICA/pica_frag_config.hpp"
|
||||
#include "lockfree/spsc/queue.hpp"
|
||||
#include "opengl.hpp"
|
||||
#include "renderer_gl/renderer_gl.hpp"
|
||||
|
||||
namespace PICA::ShaderGen
|
||||
{
|
||||
namespace PICA::ShaderGen {
|
||||
class FragmentGenerator;
|
||||
}
|
||||
|
||||
namespace AsyncCompiler
|
||||
{
|
||||
namespace AsyncCompiler {
|
||||
void* createContext(void* userdata);
|
||||
void makeCurrent(void* userdata, void* context);
|
||||
void destroyContext(void* context);
|
||||
}
|
||||
} // namespace AsyncCompiler
|
||||
|
||||
struct CompilingProgram
|
||||
{
|
||||
struct CompilingProgram {
|
||||
CachedProgram* program;
|
||||
PICA::FragmentConfig* config;
|
||||
};
|
||||
|
||||
struct AsyncCompilerThread
|
||||
{
|
||||
struct AsyncCompilerThread {
|
||||
explicit AsyncCompilerThread(PICA::ShaderGen::FragmentGenerator& fragShaderGen, void* userdata);
|
||||
~AsyncCompilerThread();
|
||||
|
||||
|
@ -38,7 +34,7 @@ struct AsyncCompilerThread
|
|||
// Wait for all queued fragment configurations to be compiled
|
||||
void Finish();
|
||||
|
||||
private:
|
||||
private:
|
||||
PICA::ShaderGen::FragmentGenerator& fragShaderGen;
|
||||
OpenGL::Shader defaultShadergenVs;
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
#include <span>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "PICA/float_types.hpp"
|
||||
#include "PICA/pica_frag_config.hpp"
|
||||
#include "PICA/pica_hash.hpp"
|
||||
#include "PICA/pica_vertex.hpp"
|
||||
#include "PICA/regs.hpp"
|
||||
#include "PICA/shader_gen.hpp"
|
||||
#include "config.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "logger.hpp"
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
#include "renderer_gl/async_compiler.hpp"
|
||||
|
||||
AsyncCompilerThread::AsyncCompilerThread(PICA::ShaderGen::FragmentGenerator& fragShaderGen, void* userdata)
|
||||
: fragShaderGen(fragShaderGen)
|
||||
{
|
||||
AsyncCompilerThread::AsyncCompilerThread(PICA::ShaderGen::FragmentGenerator& fragShaderGen, void* userdata) : fragShaderGen(fragShaderGen) {
|
||||
preallocatedProgramsIndex = 0;
|
||||
running.store(true);
|
||||
|
||||
for (int i = 0; i < preallocatedProgramsSize; i++)
|
||||
{
|
||||
for (int i = 0; i < preallocatedProgramsSize; i++) {
|
||||
preallocatedPrograms[i] = new CompilingProgram();
|
||||
preallocatedPrograms[i]->config = new PICA::FragmentConfig({});
|
||||
}
|
||||
|
@ -15,16 +12,14 @@ AsyncCompilerThread::AsyncCompilerThread(PICA::ShaderGen::FragmentGenerator& fra
|
|||
// The context needs to be created on the main thread so that we can make it shared with that
|
||||
// thread's context
|
||||
void* context = AsyncCompiler::createContext(userdata);
|
||||
thread = std::thread([this, userdata, context]()
|
||||
{
|
||||
thread = std::thread([this, userdata, context]() {
|
||||
AsyncCompiler::makeCurrent(userdata, context);
|
||||
printf("Async compiler started, GL version: %s\n", glGetString(GL_VERSION));
|
||||
|
||||
std::string defaultShadergenVSSource = this->fragShaderGen.getDefaultVertexShader();
|
||||
defaultShadergenVs.create({defaultShadergenVSSource.c_str(), defaultShadergenVSSource.size()}, OpenGL::Vertex);
|
||||
|
||||
while (running.load())
|
||||
{
|
||||
while (running.load()) {
|
||||
CompilingProgram* item;
|
||||
while (programQueue.Pop(item)) {
|
||||
OpenGL::Program& glProgram = item->program->program;
|
||||
|
@ -43,20 +38,17 @@ AsyncCompilerThread::AsyncCompilerThread(PICA::ShaderGen::FragmentGenerator& fra
|
|||
});
|
||||
}
|
||||
|
||||
AsyncCompilerThread::~AsyncCompilerThread()
|
||||
{
|
||||
AsyncCompilerThread::~AsyncCompilerThread() {
|
||||
running.store(false);
|
||||
thread.join();
|
||||
|
||||
for (int i = 0; i < preallocatedProgramsSize; i++)
|
||||
{
|
||||
for (int i = 0; i < preallocatedProgramsSize; i++) {
|
||||
delete preallocatedPrograms[i]->config;
|
||||
delete preallocatedPrograms[i];
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncCompilerThread::PushFragmentConfig(const PICA::FragmentConfig& config, CachedProgram* cachedProgram)
|
||||
{
|
||||
void AsyncCompilerThread::PushFragmentConfig(const PICA::FragmentConfig& config, CachedProgram* cachedProgram) {
|
||||
CompilingProgram* newProgram = preallocatedPrograms[preallocatedProgramsIndex];
|
||||
newProgram->program = cachedProgram;
|
||||
*newProgram->config = config;
|
||||
|
@ -74,10 +66,10 @@ void AsyncCompilerThread::PushFragmentConfig(const PICA::FragmentConfig& config,
|
|||
}
|
||||
}
|
||||
|
||||
void AsyncCompilerThread::Finish()
|
||||
{
|
||||
void AsyncCompilerThread::Finish() {
|
||||
hasWork.test_and_set();
|
||||
|
||||
// Wait for the compiler thread to finish any outstanding work
|
||||
while (hasWork.test_and_set()) {}
|
||||
while (hasWork.test_and_set()) {
|
||||
}
|
||||
}
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "android_utils.hpp"
|
||||
#include "emulator.hpp"
|
||||
#include "renderer_gl/renderer_gl.hpp"
|
||||
#include "services/hid.hpp"
|
||||
#include "android_utils.hpp"
|
||||
|
||||
std::unique_ptr<Emulator> emulator = nullptr;
|
||||
HIDService* hidService = nullptr;
|
||||
|
@ -40,7 +40,7 @@ JNIEnv* jniEnv() {
|
|||
extern "C" {
|
||||
|
||||
#define MAKE_SETTING(functionName, type, settingName) \
|
||||
AlberFunction(void, functionName) (JNIEnv* env, jobject obj, type value) { emulator->getConfig().settingName = value; }
|
||||
AlberFunction(void, functionName)(JNIEnv * env, jobject obj, type value) { emulator->getConfig().settingName = value; }
|
||||
|
||||
MAKE_SETTING(setShaderJitEnabled, jboolean, shaderJitEnabled)
|
||||
|
||||
|
@ -147,9 +147,7 @@ namespace AsyncCompiler {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void makeCurrent(void* mainContext, void* context) {
|
||||
}
|
||||
void makeCurrent(void* mainContext, void* context) {}
|
||||
|
||||
void destroyContext(void* context) {
|
||||
}
|
||||
}
|
||||
void destroyContext(void* context) {}
|
||||
} // namespace AsyncCompiler
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <regex>
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <emulator.hpp>
|
||||
#include <regex>
|
||||
#include <renderer_gl/renderer_gl.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
static retro_environment_t envCallbacks;
|
||||
static retro_video_refresh_t videoCallbacks;
|
||||
|
@ -21,17 +20,11 @@ static bool screenTouched;
|
|||
std::unique_ptr<Emulator> emulator;
|
||||
RendererGL* renderer;
|
||||
|
||||
std::filesystem::path Emulator::getConfigPath() {
|
||||
return std::filesystem::path(savePath / "config.toml");
|
||||
}
|
||||
std::filesystem::path Emulator::getConfigPath() { return std::filesystem::path(savePath / "config.toml"); }
|
||||
|
||||
std::filesystem::path Emulator::getAppDataRoot() {
|
||||
return std::filesystem::path(savePath / "Emulator Files");
|
||||
}
|
||||
std::filesystem::path Emulator::getAppDataRoot() { return std::filesystem::path(savePath / "Emulator Files"); }
|
||||
|
||||
static void* GetGLProcAddress(const char* name) {
|
||||
return (void*)hw_render.get_proc_address(name);
|
||||
}
|
||||
static void* GetGLProcAddress(const char* name) { return (void*)hw_render.get_proc_address(name); }
|
||||
|
||||
static void VideoResetContext() {
|
||||
#ifdef USING_GLES
|
||||
|
@ -47,9 +40,7 @@ static void VideoResetContext() {
|
|||
emulator->initGraphicsContext(nullptr);
|
||||
}
|
||||
|
||||
static void VideoDestroyContext() {
|
||||
emulator->deinitGraphicsContext();
|
||||
}
|
||||
static void VideoDestroyContext() { emulator->deinitGraphicsContext(); }
|
||||
|
||||
static bool SetHWRender(retro_hw_context_type type) {
|
||||
hw_render.context_type = type;
|
||||
|
@ -142,9 +133,7 @@ static std::string FetchVariable(std::string key, std::string def) {
|
|||
return std::string(var.value);
|
||||
}
|
||||
|
||||
static bool FetchVariableBool(std::string key, bool def) {
|
||||
return FetchVariable(key, def ? "enabled" : "disabled") == "enabled";
|
||||
}
|
||||
static bool FetchVariableBool(std::string key, bool def) { return FetchVariable(key, def ? "enabled" : "disabled") == "enabled"; }
|
||||
|
||||
static void configInit() {
|
||||
static const retro_variable values[] = {
|
||||
|
@ -180,7 +169,9 @@ static void configUpdate() {
|
|||
config.sdCardInserted = FetchVariableBool("panda3ds_use_virtual_sd", true);
|
||||
config.sdWriteProtected = FetchVariableBool("panda3ds_write_protect_virtual_sd", false);
|
||||
config.accurateShaderMul = FetchVariableBool("panda3ds_accurate_shader_mul", false);
|
||||
config.shaderMode = FetchVariableBool("panda3ds_use_ubershader", EmulatorConfig::defaultShaderMode == ShaderMode::Ubershader) ? ShaderMode::Ubershader : ShaderMode::Specialized;
|
||||
config.shaderMode = FetchVariableBool("panda3ds_use_ubershader", EmulatorConfig::defaultShaderMode == ShaderMode::Ubershader)
|
||||
? ShaderMode::Ubershader
|
||||
: ShaderMode::Specialized;
|
||||
config.forceShadergenForLights = FetchVariableBool("panda3ds_ubershader_lighting_override", true);
|
||||
config.lightShadergenThreshold = std::clamp(std::stoi(FetchVariable("panda3ds_ubershader_lighting_override_threshold", "1")), 1, 8);
|
||||
config.discordRpcEnabled = false;
|
||||
|
@ -217,27 +208,17 @@ void retro_get_system_av_info(retro_system_av_info* info) {
|
|||
info->timing.sample_rate = 32768;
|
||||
}
|
||||
|
||||
void retro_set_environment(retro_environment_t cb) {
|
||||
envCallbacks = cb;
|
||||
}
|
||||
void retro_set_environment(retro_environment_t cb) { envCallbacks = cb; }
|
||||
|
||||
void retro_set_video_refresh(retro_video_refresh_t cb) {
|
||||
videoCallbacks = cb;
|
||||
}
|
||||
void retro_set_video_refresh(retro_video_refresh_t cb) { videoCallbacks = cb; }
|
||||
|
||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) {
|
||||
audioBatchCallback = cb;
|
||||
}
|
||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audioBatchCallback = cb; }
|
||||
|
||||
void retro_set_audio_sample(retro_audio_sample_t cb) {}
|
||||
|
||||
void retro_set_input_poll(retro_input_poll_t cb) {
|
||||
inputPollCallback = cb;
|
||||
}
|
||||
void retro_set_input_poll(retro_input_poll_t cb) { inputPollCallback = cb; }
|
||||
|
||||
void retro_set_input_state(retro_input_state_t cb) {
|
||||
inputStateCallback = cb;
|
||||
}
|
||||
void retro_set_input_state(retro_input_state_t cb) { inputStateCallback = cb; }
|
||||
|
||||
void retro_init() {
|
||||
enum retro_pixel_format xrgb888 = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
|
@ -255,9 +236,7 @@ void retro_init() {
|
|||
emulator = std::make_unique<Emulator>();
|
||||
}
|
||||
|
||||
void retro_deinit() {
|
||||
emulator = nullptr;
|
||||
}
|
||||
void retro_deinit() { emulator = nullptr; }
|
||||
|
||||
bool retro_load_game(const retro_game_info* game) {
|
||||
configInit();
|
||||
|
@ -283,9 +262,7 @@ void retro_unload_game() {
|
|||
renderer = nullptr;
|
||||
}
|
||||
|
||||
void retro_reset() {
|
||||
emulator->reset(Emulator::ReloadOption::Reload);
|
||||
}
|
||||
void retro_reset() { emulator->reset(Emulator::ReloadOption::Reload); }
|
||||
|
||||
void retro_run() {
|
||||
ConfigCheckVariables();
|
||||
|
@ -400,6 +377,4 @@ void retro_cheat_set(uint index, bool enabled, const char* code) {
|
|||
}
|
||||
}
|
||||
|
||||
void retro_cheat_reset() {
|
||||
emulator->getCheats().reset();
|
||||
}
|
||||
void retro_cheat_reset() { emulator->getCheats().reset(); }
|
||||
|
|
|
@ -631,4 +631,4 @@ namespace AsyncCompiler {
|
|||
std::unique_ptr<GL::Context>* glContext = static_cast<std::unique_ptr<GL::Context>*>(context);
|
||||
delete glContext;
|
||||
}
|
||||
}
|
||||
} // namespace AsyncCompiler
|
|
@ -43,9 +43,13 @@ std::optional<ShaderMode> Renderer::shaderModeFromString(std::string inString) {
|
|||
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
static const std::unordered_map<std::string, ShaderMode> map = {
|
||||
{"specialized", ShaderMode::Specialized}, {"special", ShaderMode::Specialized},
|
||||
{"ubershader", ShaderMode::Ubershader}, {"uber", ShaderMode::Ubershader},
|
||||
{"hybrid", ShaderMode::Hybrid}, {"threaded", ShaderMode::Hybrid}, {"i hate opengl context creation", ShaderMode::Hybrid},
|
||||
{"specialized", ShaderMode::Specialized},
|
||||
{"special", ShaderMode::Specialized},
|
||||
{"ubershader", ShaderMode::Ubershader},
|
||||
{"uber", ShaderMode::Ubershader},
|
||||
{"hybrid", ShaderMode::Hybrid},
|
||||
{"threaded", ShaderMode::Hybrid},
|
||||
{"i hate opengl context creation", ShaderMode::Hybrid},
|
||||
};
|
||||
|
||||
if (auto search = map.find(inString); search != map.end()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue