From 91a1b4adc97d60c6be6d780a65d9e56feb55fd86 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 22 Jan 2024 21:35:16 -0800 Subject: [PATCH] A smaller stage - Cull down RenderStage. - Simplifies the choice users of flywheel have to make. - Allows more time for the impl to run things off-thread while the rest of the level renders. --- .../flywheel/api/event/RenderStage.java | 7 ---- .../flywheel/mixin/LevelRendererMixin.java | 40 ------------------- 2 files changed, 47 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/api/event/RenderStage.java b/src/main/java/com/jozufozu/flywheel/api/event/RenderStage.java index dbefd1931..f15cdc070 100644 --- a/src/main/java/com/jozufozu/flywheel/api/event/RenderStage.java +++ b/src/main/java/com/jozufozu/flywheel/api/event/RenderStage.java @@ -1,15 +1,8 @@ package com.jozufozu.flywheel.api.event; public enum RenderStage { - BEFORE_SKY, - AFTER_SKY, - BEFORE_TERRAIN, - AFTER_SOLID_TERRAIN, - BEFORE_ENTITIES, AFTER_ENTITIES, AFTER_BLOCK_ENTITIES, - BEFORE_CRUMBLING, - AFTER_FINAL_END_BATCH, AFTER_TRANSLUCENT_TERRAIN, AFTER_PARTICLES, AFTER_WEATHER; diff --git a/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java index 7f3196d8f..0c0f02788 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java @@ -88,31 +88,6 @@ abstract class LevelRendererMixin { } } - @Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=sky")) - private void flywheel$onStage$beforeSky(CallbackInfo ci) { - flywheel$dispatch(RenderStage.BEFORE_SKY); - } - - @Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=fog")) - private void flywheel$onStage$afterSky(CallbackInfo ci) { - flywheel$dispatch(RenderStage.AFTER_SKY); - } - - @Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=terrain")) - private void flywheel$onStage$beforeTerrain(CallbackInfo ci) { - flywheel$dispatch(RenderStage.BEFORE_TERRAIN); - } - - @Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=entities")) - private void flywheel$onStage$afterSolidTerrain(CallbackInfo ci) { - flywheel$dispatch(RenderStage.AFTER_SOLID_TERRAIN); - } - - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBuffers;bufferSource()Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;", ordinal = 0)) - private void flywheel$onStage$beforeEntities(CallbackInfo ci) { - flywheel$dispatch(RenderStage.BEFORE_ENTITIES); - } - @Inject(method = "renderLevel", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=blockentities")) private void flywheel$onStage$beforeBlockEntities(CallbackInfo ci) { flywheel$dispatch(RenderStage.AFTER_ENTITIES); @@ -123,26 +98,11 @@ abstract class LevelRendererMixin { flywheel$dispatch(RenderStage.AFTER_BLOCK_ENTITIES); } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;endBatch()V", ordinal = 0)) - private void flywheel$onStage$beforeCrumbling(CallbackInfo ci) { - flywheel$dispatch(RenderStage.BEFORE_CRUMBLING); - } - - @Inject(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/LevelRenderer;translucentTarget:Lcom/mojang/blaze3d/pipeline/RenderTarget;", opcode = Opcodes.GETFIELD, ordinal = 0)) - private void flywheel$onStage$afterFinalEndBatch$fabulous(CallbackInfo ci) { - flywheel$dispatch(RenderStage.AFTER_FINAL_END_BATCH); - } - @Inject(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/LevelRenderer;particlesTarget:Lcom/mojang/blaze3d/pipeline/RenderTarget;", opcode = Opcodes.GETFIELD, ordinal = 0)) private void flywheel$onStage$afterTranslucentTerrain$fabulous(CallbackInfo ci) { flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN); } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;endBatch()V", ordinal = 2, shift = Shift.AFTER)) - private void flywheel$onStage$afterFinalEndBatch(CallbackInfo ci) { - flywheel$dispatch(RenderStage.AFTER_FINAL_END_BATCH); - } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER)) private void flywheel$onStage$afterTranslucentTerrain(CallbackInfo ci) { flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);