-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: add more debug features, remove current fallback for bfs
- Loading branch information
1 parent
95b0725
commit ddfb9f2
Showing
7 changed files
with
139 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/main/java/net/caffeinemc/sodium/mixin/features/debug/MixinMinecraftClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package net.caffeinemc.sodium.mixin.features.debug; | ||
|
||
import java.util.function.Supplier; | ||
import net.caffeinemc.sodium.SodiumClientMod; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.util.TickDurationMonitor; | ||
import net.minecraft.util.profiler.Profiler; | ||
import net.minecraft.util.profiler.SampleType; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(MinecraftClient.class) | ||
public class MixinMinecraftClient { | ||
|
||
private static final Profiler GFX_DEBUGGER = new Profiler() { | ||
@Override | ||
public void startTick() { | ||
this.push(Profiler.ROOT_NAME); | ||
} | ||
|
||
@Override | ||
public void endTick() { | ||
this.pop(); | ||
} | ||
|
||
@Override | ||
public void push(String location) { | ||
SodiumClientMod.DEVICE.pushDebugGroup(location); | ||
} | ||
|
||
@Override | ||
public void push(Supplier<String> locationGetter) { | ||
this.push(locationGetter.get()); | ||
} | ||
|
||
@Override | ||
public void pop() { | ||
SodiumClientMod.DEVICE.popDebugGroup(); | ||
} | ||
|
||
@Override | ||
public void swap(String location) { | ||
this.pop(); | ||
this.push(location); | ||
} | ||
|
||
@Override | ||
public void swap(Supplier<String> locationGetter) { | ||
this.swap(locationGetter.get()); | ||
} | ||
|
||
@Override | ||
public void markSampleType(SampleType type) { | ||
// noop | ||
} | ||
|
||
@Override | ||
public void visit(String marker, int i) { | ||
// noop | ||
} | ||
|
||
@Override | ||
public void visit(Supplier<String> markerGetter, int i) { | ||
// noop | ||
} | ||
}; | ||
|
||
@Inject(method = "startMonitor", at = @At("RETURN"), cancellable = true) | ||
private void addDebugger(boolean active, TickDurationMonitor monitor, CallbackInfoReturnable<Profiler> cir) { | ||
cir.setReturnValue(Profiler.union(cir.getReturnValue(), GFX_DEBUGGER)); | ||
} | ||
|
||
} |
Oops, something went wrong.