Skip to content

Commit

Permalink
Merge branch '1.19.4' into 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralhalo committed Jun 11, 2023
2 parents 19490a6 + ed27032 commit 9d8ee17
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.Minecraft;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.AccessibilityOptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.SimpleOptionsSubScreen;
import net.minecraft.network.chat.Component;

import grondag.canvas.apiimpl.CanvasState;
import grondag.canvas.shader.data.AccessibilityData;

@Mixin(AccessibilityOptionsScreen.class)
Expand All @@ -44,18 +42,12 @@ public MixinAccessibilityOptionsScreen(Screen screen, Options options, Component

@Inject(at = @At("HEAD"), method = "method_31384")
void onClosing(CallbackInfo ci) {
canvas_onClose();
AccessibilityData.onCloseOptionScreen();
}

@Override
public void onClose() {
canvas_onClose();
AccessibilityData.onCloseOptionScreen();
super.onClose();
}

private static void canvas_onClose() {
if (AccessibilityData.checkChanged() && Minecraft.getInstance().level != null) {
CanvasState.recompileIfNeeded(true);
}
}
}
14 changes: 6 additions & 8 deletions src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
package grondag.canvas.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
Expand All @@ -35,17 +37,13 @@

import grondag.canvas.apiimpl.rendercontext.CanvasBlockRenderContext;

// WIP: change this an inject with cancel so that mods that hook in here don't break directly - esp C&B
// WIP: move hooks upstream so that multi-consumer is available in more cases
@Mixin(ModelBlockRenderer.class)
public abstract class MixinModelBlockRenderer {
/**
* @author grondag
* @reason performance; less bad than inject and cancel at head
*/
@Overwrite
public void tesselateBlock(BlockAndTintGetter blockView, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer buffer, boolean checkSides, RandomSource randomSource, long seed, int overlay) {
@Inject(at = @At("HEAD"), method = "tesselateBlock", cancellable = true)
public void beforeTesselateBlock(BlockAndTintGetter blockView, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer buffer, boolean checkSides, RandomSource randomSource, long seed, int overlay, CallbackInfo ci) {
// PERF: try to avoid threadlocal lookup here
CanvasBlockRenderContext.get().render((ModelBlockRenderer) (Object) this, blockView, model, state, pos, poseStack, buffer, checkSides, seed, overlay);
ci.cancel();
}
}
12 changes: 12 additions & 0 deletions src/main/java/grondag/canvas/mixin/MixinVideoSettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.client.gui.screens.VideoSettingsScreen;
import net.minecraft.network.chat.Component;

import grondag.canvas.shader.data.AccessibilityData;
import grondag.canvas.varia.CanvasButtonWidget;

@Mixin(VideoSettingsScreen.class)
Expand All @@ -41,4 +42,15 @@ public MixinVideoSettingsScreen(Component title) {
private void onInit(CallbackInfo info) {
CanvasButtonWidget.parent = this;
}

@Inject(at = @At("HEAD"), method = "method_19865")
void onClosing(CallbackInfo ci) {
AccessibilityData.onCloseOptionScreen();
}

@Override
public void onClose() {
AccessibilityData.onCloseOptionScreen();
super.onClose();
}
}
19 changes: 16 additions & 3 deletions src/main/java/grondag/canvas/pipeline/PipelineManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class PipelineManager {
private static int oldTex0;
private static int oldTex1;

private static boolean pendingInitPass;
private static boolean pendingResizePass;

public static int width() {
return w;
}
Expand Down Expand Up @@ -103,8 +106,8 @@ public static void init(PrimaryFrameBuffer primary, int width, int height) {

collector.clear(); // releases storage

renderFullFramePasses(Pipeline.onInit);
renderFullFramePasses(Pipeline.onResize);
pendingInitPass = true;
pendingResizePass = true;
}

private static void addVertex(float x, float y, float z, float u, float v, int[] target, int index) {
Expand All @@ -123,10 +126,20 @@ public static void onResize(PrimaryFrameBuffer primary, int newWidth, int newHei

Pipeline.onResize(primary, w, h);

renderFullFramePasses(Pipeline.onResize);
pendingResizePass = true;
}

public static void beforeWorldRender() {
if (pendingInitPass) {
renderFullFramePasses(Pipeline.onInit);
pendingInitPass = false;
}

if (pendingResizePass) {
renderFullFramePasses(Pipeline.onResize);
pendingResizePass = false;
}

renderFullFramePasses(Pipeline.onWorldRenderStart, Timekeeper.ProfilerGroup.BeforeWorld);
Pipeline.defaultFbo.bind();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

import grondag.canvas.apiimpl.CanvasState;

public class AccessibilityData {
static final ResourceLocation id = new ResourceLocation("canvas:accessibility");

Expand All @@ -33,6 +35,12 @@ public class AccessibilityData {

static String cache = null;

public static void onCloseOptionScreen() {
if (AccessibilityData.checkChanged() && Minecraft.getInstance().level != null) {
CanvasState.recompileIfNeeded(true);
}
}

public static boolean checkChanged() {
final var mc = Minecraft.getInstance();

Expand Down

0 comments on commit 9d8ee17

Please sign in to comment.