Skip to content

Commit

Permalink
Added experimental screen batching (Huge performance boost in screens)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Nov 6, 2023
1 parent cd29b33 commit 1fa3c8a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public boolean getBoolean(String key, boolean defaultValue) {
case "dont_add_info_into_debug_hud" -> ImmediatelyFast.config.dont_add_info_into_debug_hud;
case "experimental_disable_error_checking" -> ImmediatelyFast.config.experimental_disable_error_checking;
case "experimental_disable_resource_pack_conflict_handling" -> ImmediatelyFast.config.experimental_disable_resource_pack_conflict_handling;
case "experimental_screen_batching" -> ImmediatelyFast.config.experimental_screen_batching;
case "debug_only_and_not_recommended_disable_universal_batching" -> ImmediatelyFast.config.debug_only_and_not_recommended_disable_universal_batching;
case "debug_only_and_not_recommended_disable_mod_conflict_handling" -> ImmediatelyFast.config.debug_only_and_not_recommended_disable_mod_conflict_handling;
case "debug_only_and_not_recommended_disable_hardware_conflict_handling" -> ImmediatelyFast.config.debug_only_and_not_recommended_disable_hardware_conflict_handling;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ImmediatelyFastConfig {
private String EXPERIMENTAL_INFO = "----- Experimental config values below (Rendering glitches may occur) -----";
public boolean experimental_disable_error_checking = false;
public boolean experimental_disable_resource_pack_conflict_handling = false;
public boolean experimental_screen_batching = false;

// Debug config values
private String DEBUG_INFO = "----- Debug only config values below (Do not touch) -----";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (!ImmediatelyFast.config.experimental_disable_error_checking && packageName.startsWith("disable_error_checking")) {
return false;
}
if (!ImmediatelyFast.config.experimental_screen_batching && packageName.startsWith("screen_batching")) {
return false;
}

if (packageName.startsWith("hud_batching.compat.armorchroma") && PlatformCode.getModVersion("armorchroma").isEmpty()) { // https://github.com/A5b84/armor-chroma-fabric
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast
* Copyright (C) 2023 RK_01/RaphiMC and contributors
*
* 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; either
* version 3 of the License, or (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.immediatelyfast.injection.mixins.screen_batching;

import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.raphimc.immediatelyfast.feature.batching.BatchingBuffers;
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.CallbackInfo;

@Mixin(value = HandledScreen.class, priority = 500)
public abstract class MixinHandledScreen {

@Inject(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;focusedSlot:Lnet/minecraft/screen/slot/Slot;", ordinal = 0))
private void beginBatching(CallbackInfo ci) {
BatchingBuffers.beginHudBatching();
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawForeground(Lnet/minecraft/client/util/math/MatrixStack;II)V", shift = At.Shift.BEFORE))
private void endBatching(CallbackInfo ci) {
BatchingBuffers.endHudBatching();
}

}
3 changes: 2 additions & 1 deletion common/src/main/resources/immediatelyfast-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"hud_batching.consumer.MixinItemRenderer",
"hud_batching.consumer.MixinTextRenderer",
"map_atlas_generation.MixinMapRenderer",
"map_atlas_generation.MixinMapRenderer_MapTexture"
"map_atlas_generation.MixinMapRenderer_MapTexture",
"screen_batching.MixinHandledScreen"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 1fa3c8a

Please sign in to comment.