diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index 6116a2e88..55926a1ab 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -1059,6 +1059,14 @@ public class Config + "") .build(); + public static ConfigEntry enableMacosStateValidation = new ConfigEntry.Builder() + .set(false) + .comment("" + + "Experimental option \n" + + "May reduce crashing when Sodium is installed on Mac, may reduce performance, may do nothing. \n" + + "") + .build(); + } public static class ColumnBuilderDebugging diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java index 5efae5050..00fb33f38 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java @@ -23,6 +23,7 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode; import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; +import com.seibel.distanthorizons.core.jar.EPlatform; import com.seibel.distanthorizons.core.logging.ConfigBasedLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.util.objects.GLMessages.*; @@ -32,10 +33,7 @@ import com.seibel.distanthorizons.coreapi.util.StringUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL; -import org.lwjgl.opengl.GL32; -import org.lwjgl.opengl.GLCapabilities; -import org.lwjgl.opengl.GLUtil; +import org.lwjgl.opengl.*; import java.io.PrintStream; import java.util.Collections; @@ -186,6 +184,25 @@ public class GLProxy GL_LOGGER.info("GPU Vendor [" + vendor + "], Preferred upload method is [" + this.preferredUploadMethod + "]."); + // experimental Mac OS + if (Config.Client.Advanced.Debugging.OpenGl.enableMacosStateValidation.get()) + { + EPlatform platform = EPlatform.get(); + if (platform == EPlatform.MACOS) + { + GL_LOGGER.info("Attempting to enable kCGLCEStateValidation."); + CGL.CGLEnable(CGL.CGLGetCurrentContext(), CGL.kCGLCEStateValidation); + // according to some testing by IMS this may reduce issues with Mac OS, + // however according to the + // https://leopard-adc.pepas.com/documentation/GraphicsImaging/Reference/CGL_OpenGL/CGL_OpenGL.pdf#:~:text=If%20enabled%2C%20OpenGL%20inspects%20the,a%20virtual%20screen%20number%20different + } + else + { + GL_LOGGER.info("Unable to enable kCGLCEStateValidation due to OS being ["+platform.name()+"]."); + } + } + + //==========// // clean up // diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index 8a17c7e1c..bca1c4da0 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -494,6 +494,10 @@ "Validate Buffer IDs Before Rendering", "distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip": "Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it.", + "distanthorizons.config.client.advanced.debugging.openGl.enableMacosStateValidation": + "Enable MacOS State Validation", + "distanthorizons.config.client.advanced.debugging.openGl.enableMacosStateValidation.@tooltip": + "Experimental option \nMay reduce crashing when Sodium is installed on Mac, may reduce performance, may do nothing.",