sdl: add GLES support

This commit is contained in:
BreadFish64 2019-01-30 14:11:39 -06:00
parent 9af8d61ba2
commit cd21abe50f
5 changed files with 17 additions and 3 deletions

View File

@ -105,6 +105,7 @@ void Config::ReadValues() {
Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true);
// Renderer // Renderer
Settings::values.use_gles = sdl2_config->GetBoolean("Renderer", "use_gles", false);
Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true); Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true);
#ifdef __APPLE__ #ifdef __APPLE__
// Hardware shader is broken on macos thanks to poor drivers. // Hardware shader is broken on macos thanks to poor drivers.

View File

@ -92,6 +92,10 @@ udp_pad_index=
use_cpu_jit = use_cpu_jit =
[Renderer] [Renderer]
# Whether to render using GLES or OpenGL
# 0 (default): OpenGL, 1: GLES
use_gles =
# Whether to use software or hardware rendering. # Whether to use software or hardware rendering.
# 0: Software, 1 (default): Hardware # 0: Software, 1 (default): Hardware
use_hw_renderer = use_hw_renderer =

View File

@ -122,8 +122,13 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
SDL_SetMainReady(); SDL_SetMainReady();
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
if (Settings::values.use_gles) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
} else {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
@ -155,7 +160,9 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
exit(1); exit(1);
} }
if (!gladLoadGLLoader(static_cast<GLADloadproc>(SDL_GL_GetProcAddress))) { auto gl_load_func = Settings::values.use_gles ? gladLoadGLES2Loader : gladLoadGLLoader;
if (!gl_load_func(static_cast<GLADloadproc>(SDL_GL_GetProcAddress))) {
LOG_CRITICAL(Frontend, "Failed to initialize GL functions: {}", SDL_GetError()); LOG_CRITICAL(Frontend, "Failed to initialize GL functions: {}", SDL_GetError());
exit(1); exit(1);
} }

View File

@ -67,6 +67,7 @@ void LogSetting(const std::string& name, const T& value) {
void LogSettings() { void LogSettings() {
LOG_INFO(Config, "Citra Configuration:"); LOG_INFO(Config, "Citra Configuration:");
LogSetting("Core_UseCpuJit", Settings::values.use_cpu_jit); LogSetting("Core_UseCpuJit", Settings::values.use_cpu_jit);
LogSetting("Renderer_UseGLES", Settings::values.use_gles);
LogSetting("Renderer_UseHwRenderer", Settings::values.use_hw_renderer); LogSetting("Renderer_UseHwRenderer", Settings::values.use_hw_renderer);
LogSetting("Renderer_UseHwShader", Settings::values.use_hw_shader); LogSetting("Renderer_UseHwShader", Settings::values.use_hw_shader);
LogSetting("Renderer_ShadersAccurateGs", Settings::values.shaders_accurate_gs); LogSetting("Renderer_ShadersAccurateGs", Settings::values.shaders_accurate_gs);

View File

@ -130,6 +130,7 @@ struct Values {
u64 init_time; u64 init_time;
// Renderer // Renderer
bool use_gles;
bool use_hw_renderer; bool use_hw_renderer;
bool use_hw_shader; bool use_hw_shader;
bool shaders_accurate_gs; bool shaders_accurate_gs;