|
19 | 19 |
|
20 | 20 | import net.minecraft.client.gl.GlDebug; |
21 | 21 | import net.raphimc.immediatelyfast.ImmediatelyFast; |
| 22 | +import org.lwjgl.opengl.GL; |
| 23 | +import org.lwjgl.opengl.GLCapabilities; |
| 24 | +import org.slf4j.Logger; |
22 | 25 | import org.spongepowered.asm.mixin.Mixin; |
23 | 26 | import org.spongepowered.asm.mixin.Unique; |
24 | 27 | import org.spongepowered.asm.mixin.injection.At; |
25 | | -import org.spongepowered.asm.mixin.injection.Inject; |
26 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 28 | +import org.spongepowered.asm.mixin.injection.ModifyVariable; |
| 29 | +import org.spongepowered.asm.mixin.injection.Redirect; |
27 | 30 |
|
28 | 31 | @Mixin(GlDebug.class) |
29 | 32 | public abstract class MixinGlDebug { |
30 | 33 |
|
31 | 34 | @Unique |
32 | 35 | private static long immediatelyFast$lastTime; |
33 | 36 |
|
34 | | - @Inject(method = "info", at = @At("RETURN")) |
35 | | - private static void printAdditionalInfo(CallbackInfo ci) { |
| 37 | + @ModifyVariable(method = "enableDebug", at = @At("HEAD"), index = 1, argsOnly = true) |
| 38 | + private static boolean enableSyncDebug(boolean sync) { |
| 39 | + final GLCapabilities capabilities = GL.getCapabilities(); |
| 40 | + return sync || (ImmediatelyFast.config.debug_only_print_additional_error_information && (capabilities.GL_KHR_debug || capabilities.GL_ARB_debug_output)); |
| 41 | + } |
| 42 | + |
| 43 | + @Redirect(method = "info", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) |
| 44 | + private static void appendStackTrace(Logger instance, String message, Object argument) { |
36 | 45 | if (ImmediatelyFast.config.debug_only_print_additional_error_information && System.currentTimeMillis() - immediatelyFast$lastTime > 1000) { |
37 | 46 | immediatelyFast$lastTime = System.currentTimeMillis(); |
38 | | - Thread.dumpStack(); |
| 47 | + instance.info(message, argument, new Exception()); |
| 48 | + } else { |
| 49 | + instance.info(message, argument); |
39 | 50 | } |
40 | 51 | } |
41 | 52 |
|
|
0 commit comments