Switch to using shaderMode

This commit is contained in:
offtkp 2024-08-08 14:41:32 +03:00
parent 0cf5687e64
commit fb3d595ebe
8 changed files with 58 additions and 14 deletions

View file

@ -13,17 +13,17 @@ struct EmulatorConfig {
static constexpr bool shaderJitDefault = false;
#endif
// For now, use specialized shaders by default on MacOS as M1 drivers are buggy when using the ubershader, and on Android since mobile GPUs are
// horrible. On other platforms we default to ubershader + shadergen fallback for lights
// For now, use specialized shaders by default on MacOS as M1 drivers are buggy when using the ubershader, and on Android since mobile GPUs are
// horrible. On other platforms we default to ubershader + shadergen fallback for lights
#if defined(__ANDROID__) || defined(__APPLE__)
static constexpr bool ubershaderDefault = false;
static constexpr ShaderMode defaultShaderMode = ShaderMode::Specialized;
#else
static constexpr bool ubershaderDefault = true;
static constexpr ShaderMode defaultShaderMode = ShaderMode::Ubershader;
#endif
bool shaderJitEnabled = shaderJitDefault;
bool discordRpcEnabled = false;
bool useUbershaders = ubershaderDefault;
ShaderMode shaderMode = defaultShaderMode;
bool accurateShaderMul = false;
// Toggles whether to force shadergen when there's more than N lights active and we're using the ubershader, for better performance

View file

@ -20,6 +20,12 @@ enum class RendererType : s8 {
Software = 3,
};
enum class ShaderMode {
Specialized,
Ubershader,
Hybrid,
};
struct EmulatorConfig;
class GPU;
struct SDL_Window;
@ -56,6 +62,8 @@ class Renderer {
static constexpr u32 vertexBufferSize = 0x10000;
static std::optional<RendererType> typeFromString(std::string inString);
static const char* typeToString(RendererType rendererType);
static std::optional<ShaderMode> shaderModeFromString(std::string inString);
static const char* shaderModeToString(ShaderMode shaderMode);
virtual void reset() = 0;
virtual void display() = 0; // Display the 3DS screen contents to the window
@ -77,7 +85,7 @@ class Renderer {
virtual std::string getUbershader() { return ""; }
virtual void setUbershader(const std::string& shader) {}
virtual void setUbershaderSetting(bool value) {}
virtual void setShaderMode(ShaderMode shaderMode) {}
// Functions for initializing the graphics context for the Qt frontend, where we don't have the convenience of SDL_Window
#ifdef PANDA3DS_FRONTEND_QT

View file

@ -6,6 +6,7 @@
#include <span>
#include <unordered_map>
#include "config.hpp"
#include "PICA/float_types.hpp"
#include "PICA/pica_frag_config.hpp"
#include "PICA/pica_hash.hpp"
@ -30,7 +31,7 @@ class RendererGL final : public Renderer {
OpenGL::VertexArray vao;
OpenGL::VertexBuffer vbo;
bool enableUbershader = true;
ShaderMode shaderMode = EmulatorConfig::defaultShaderMode;
// Data
struct {
@ -111,7 +112,7 @@ class RendererGL final : public Renderer {
virtual std::string getUbershader() override;
virtual void setUbershader(const std::string& shader) override;
virtual void setUbershaderSetting(bool value) override { enableUbershader = value; }
virtual void setShaderMode(ShaderMode mode) override { shaderMode = mode; }
std::optional<ColourBuffer> getColourBuffer(u32 addr, PICA::ColorFmt format, u32 width, u32 height, bool createIfnotFound = true);