Add GL Context creation debug configs

In an attempt to fix Steam Deck crashing due to being unable to create the GL Context
This commit is contained in:
James Seibel
2023-09-16 08:03:39 -05:00
parent 1ae1f1f36f
commit 8a0e3a710c
4 changed files with 79 additions and 2 deletions
@@ -0,0 +1,30 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.api.enums.config;
/**
* @since API 1.0.0
*/
public enum EGlProfileMode
{
CORE,
COMPAT,
ANY;
}
@@ -1165,21 +1165,35 @@ public class Config
+ "")
.build();
// TODO temporary test, remove me
public static ConfigEntry<Boolean> skipChunkLoadUpdates = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("")
.build();
// TODO temporary test, remove me
public static ConfigEntry<Boolean> skipChunkUnloadUpdates = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("")
.build();
// TODO temporary test, remove me
public static ConfigEntry<Boolean> skipFullDataUpdateQueue = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("")
.build();
// TODO temporary test, remove me
public static ConfigEntry<EGlProfileMode> glProfileMode = new ConfigEntry.Builder<EGlProfileMode>()
.set(EGlProfileMode.CORE)
.comment("")
.build();
// TODO temporary test, remove me
public static ConfigEntry<Boolean> glForwardCompatibilityMode = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment("")
.build();
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.render.glObject;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.seibel.distanthorizons.api.enums.config.EGLErrorHandlingMode;
import com.seibel.distanthorizons.api.enums.config.EGlProfileMode;
import com.seibel.distanthorizons.api.enums.config.EGpuUploadMethod;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
@@ -160,10 +161,27 @@ public class GLProxy
// DO NOT comment out the following 2 lines: they are needed for mac and creating forward compatible contexts
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
// TODO remove me
boolean useForwardCompatibility = Config.Client.Advanced.Debugging.glForwardCompatibilityMode.get();
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, useForwardCompatibility ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE);
// TODO remove me
EGlProfileMode profileMode = Config.Client.Advanced.Debugging.glProfileMode.get();
if (profileMode == EGlProfileMode.CORE)
{
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
}
else if (profileMode == EGlProfileMode.ANY)
{
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_ANY_PROFILE);
}
else
{
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_COMPAT_PROFILE);
}
// create the Lod Builder context
lodBuilderGlContext = GLFW.glfwCreateWindow(64, 48, "LOD Builder Window", 0L, minecraftGlContext);
if (lodBuilderGlContext == 0)
@@ -425,6 +425,14 @@
"OpenGL Error Handling Mode",
"distanthorizons.config.client.advanced.debugging.glErrorHandlingMode.@tooltip":
"Defines how OpenGL errors are handled. \nMay incorrectly catch OpenGL errors thrown by other mods.",
"distanthorizons.config.client.advanced.debugging.glProfileMode":
"OpenGL Profile Mode",
"distanthorizons.config.client.advanced.debugging.glProfileMode.@tooltip":
"Requires rebooting Minecraft to apply.",
"distanthorizons.config.client.advanced.debugging.glForwardCompatibilityMode":
"OpenGL Forward Compatibility Mode",
"distanthorizons.config.client.advanced.debugging.glForwardCompatibilityMode.@tooltip":
"Requires rebooting Minecraft to apply.",
"distanthorizons.config.client.advanced.buffers":
@@ -732,6 +740,13 @@
"distanthorizons.config.enum.EGLErrorHandlingMode.LOG_THROW":
"Log-Throw",
"distanthorizons.config.enum.EGlProfileMode.CORE":
"Core",
"distanthorizons.config.enum.EGlProfileMode.COMPAT":
"Compat",
"distanthorizons.config.enum.EGlProfileMode.ANY":
"Any",
"distanthorizons.config.enum.ELoggerMode.DISABLED":
"Disabled",
"distanthorizons.config.enum.ELoggerMode.LOG_ALL_TO_FILE":