Skip to content

Commit 1051549

Browse files
committed
Merge branch '1.20.1' of https://github.com/IrisShaders/Iris into 1.20
2 parents b613f2e + c6c2608 commit 1051549

File tree

77 files changed

+989
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+989
-725
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.coderbot.batchedentityrendering.mixin;
2+
3+
import com.mojang.blaze3d.vertex.BufferBuilder;
4+
import net.minecraft.client.renderer.MultiBufferSource;
5+
import net.minecraft.client.renderer.RenderType;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.gen.Accessor;
8+
9+
import java.util.Map;
10+
11+
@Mixin(MultiBufferSource.BufferSource.class)
12+
public interface BufferSourceAccessor {
13+
@Accessor
14+
Map<RenderType, BufferBuilder> getFixedBuffers();
15+
}

src/main/java/net/coderbot/batchedentityrendering/mixin/MixinRenderBuffers.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public class MixinRenderBuffers implements RenderBuffersExt, MemoryTrackingRende
4747
@Final
4848
private ChunkBufferBuilderPack fixedBufferPack;
4949

50-
@Shadow
51-
@Final
52-
private SortedMap<RenderType, BufferBuilder> fixedBuffers;
53-
5450
@Inject(method = "bufferSource", at = @At("HEAD"), cancellable = true)
5551
private void batchedentityrendering$replaceBufferSource(CallbackInfoReturnable<MultiBufferSource.BufferSource> cir) {
5652
if (begins == 0) {
@@ -125,8 +121,9 @@ public int getMaxBegins() {
125121
@Override
126122
public void freeAndDeleteBuffers() {
127123
buffered.freeAndDeleteBuffer();
128-
((ChunkBufferBuilderPackAccessor) this.fixedBufferPack).getBuilders().values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
129-
fixedBuffers.values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
124+
((SectionBufferBuilderPackAccessor) this.fixedBufferPack).getBuilders().values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
125+
((BufferSourceAccessor) bufferSource).getFixedBuffers().forEach((renderType, bufferBuilder) -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
126+
((BufferSourceAccessor) bufferSource).getFixedBuffers().clear();
130127
((MemoryTrackingBuffer) ((OutlineBufferSourceAccessor) outlineBufferSource).getOutlineBufferSource()).freeAndDeleteBuffer();
131128
}
132129

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.Map;
1010

1111
@Mixin(ChunkBufferBuilderPack.class)
12-
public interface ChunkBufferBuilderPackAccessor {
12+
public interface SectionBufferBuilderPackAccessor {
1313
@Accessor
1414
Map<RenderType, BufferBuilder> getBuilders();
1515
}

src/main/java/net/coderbot/iris/Iris.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.common.base.Throwables;
44
import com.mojang.blaze3d.platform.GlDebug;
55
import com.mojang.blaze3d.platform.InputConstants;
6+
import com.sun.jna.platform.unix.LibC;
67
import net.coderbot.iris.config.IrisConfig;
78
import net.coderbot.iris.gl.GLDebug;
89
import net.coderbot.iris.gl.shader.ShaderCompileException;
@@ -27,6 +28,7 @@
2728
import net.coderbot.iris.texture.pbr.PBRTextureManager;
2829
import net.minecraft.ChatFormatting;
2930
import net.minecraft.SharedConstants;
31+
import net.minecraft.Util;
3032
import net.minecraft.client.KeyMapping;
3133
import net.minecraft.client.Minecraft;
3234
import net.minecraft.client.multiplayer.ClientLevel;
@@ -46,6 +48,7 @@
4648
import net.minecraftforge.network.NetworkConstants;
4749
import org.jetbrains.annotations.NotNull;
4850
import org.lwjgl.glfw.GLFW;
51+
import org.lwjgl.system.Configuration;
4952

5053
import java.io.IOException;
5154
import java.io.InputStream;
@@ -89,9 +92,10 @@ public class Iris {
8992
private static PipelineManager pipelineManager;
9093
private static IrisConfig irisConfig;
9194
private static FileSystem zipFileSystem;
92-
private static KeyMapping reloadKeybind;
93-
private static KeyMapping toggleShadersKeybind;
94-
private static KeyMapping shaderpackScreenKeybind;
95+
private static final KeyMapping reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
96+
private static final KeyMapping toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
97+
private static final KeyMapping shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
98+
private static final KeyMapping wireframeKeybind = new KeyMapping("iris.keybind.wireframe", InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), "iris.keybinds");
9599

96100
private static final Map<String, String> shaderPackOptionQueue = new HashMap<>();
97101
// Flag variable used when reloading
@@ -103,7 +107,7 @@ public class Iris {
103107
private static boolean fallback;
104108

105109
// Change this for snapshots!
106-
private static String backupVersionNumber = "1.19.4";
110+
private static String backupVersionNumber = "1.20.3";
107111

108112
public Iris() {
109113
try {
@@ -127,11 +131,7 @@ public Iris() {
127131
*
128132
* <p>This is called right before options are loaded, so we can add key bindings here.</p>
129133
*/
130-
public void onEarlyInitialize() {
131-
reloadKeybind = new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds");
132-
toggleShadersKeybind = new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds");
133-
shaderpackScreenKeybind = new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds");
134-
134+
public static void onEarlyInitialize() {
135135
try {
136136
if (!Files.exists(getShaderpacksDirectory())) {
137137
Files.createDirectories(getShaderpacksDirectory());
@@ -230,9 +230,17 @@ public static void handleKeybinds(Minecraft minecraft) {
230230
}
231231
} else if (shaderpackScreenKeybind.consumeClick()) {
232232
minecraft.setScreen(new ShaderPackScreen(null));
233+
} else if (wireframeKeybind.consumeClick()) {
234+
if (irisConfig.areDebugOptionsEnabled() && minecraft.player != null && !Minecraft.getInstance().isLocalServer()) {
235+
minecraft.player.displayClientMessage(Component.literal("No cheating; wireframe only in singleplayer!"), false);
236+
}
233237
}
234238
}
235239

240+
public static boolean shouldActivateWireframe() {
241+
return irisConfig.areDebugOptionsEnabled() && wireframeKeybind.isDown();
242+
}
243+
236244
public static void toggleShaders(Minecraft minecraft, boolean enabled) throws IOException {
237245
irisConfig.setShadersEnabled(enabled);
238246
irisConfig.save();

src/main/java/net/coderbot/iris/features/FeatureFlags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public enum FeatureFlags {
1414
CUSTOM_IMAGES(() -> true, IrisRenderSystem::supportsImageLoadStore),
1515
PER_BUFFER_BLENDING(() -> true, IrisRenderSystem::supportsBufferBlending),
1616
COMPUTE_SHADERS(() -> true, IrisRenderSystem::supportsCompute),
17+
TESSELATION_SHADERS(() -> true, IrisRenderSystem::supportsTesselation),
1718
ENTITY_TRANSLUCENT(() -> true, () -> true),
1819
REVERSED_CULLING(() -> true, () -> true),
1920
SSBO(() -> true, IrisRenderSystem::supportsSSBO),

src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class IrisRenderSystem {
4242
private static DSAAccess dsaState;
4343
private static boolean hasMultibind;
4444
private static boolean supportsCompute;
45+
private static boolean supportsTesselation;
46+
private static int polygonMode = GL43C.GL_FILL;
47+
private static int backupPolygonMode = GL43C.GL_FILL;
4548
private static int[] samplers;
4649

4750
public static void initRenderer() {
@@ -59,6 +62,7 @@ public static void initRenderer() {
5962
hasMultibind = GL.getCapabilities().OpenGL45 || GL.getCapabilities().GL_ARB_multi_bind;
6063

6164
supportsCompute = GL.getCapabilities().glDispatchCompute != MemoryUtil.NULL;
65+
supportsTesselation = GL.getCapabilities().GL_ARB_tessellation_shader || GL.getCapabilities().OpenGL40;
6266

6367
samplers = new int[SamplerLimits.get().getMaxTextureUnits()];
6468
}
@@ -365,6 +369,10 @@ public static boolean supportsCompute() {
365369
return supportsCompute;
366370
}
367371

372+
public static boolean supportsTesselation() {
373+
return supportsTesselation;
374+
}
375+
368376
public static int genSampler() {
369377
return GL33C.glGenSamplers();
370378
}
@@ -425,6 +433,23 @@ public static void deleteBuffers(int glId) {
425433
GL43C.glDeleteBuffers(glId);
426434
}
427435

436+
public static void setPolygonMode(int mode) {
437+
if (mode != polygonMode) {
438+
polygonMode = mode;
439+
GL43C.glPolygonMode(GL43C.GL_FRONT_AND_BACK, mode);
440+
}
441+
}
442+
443+
public static void overridePolygonMode() {
444+
backupPolygonMode = polygonMode;
445+
setPolygonMode(GL43C.GL_FILL);
446+
}
447+
448+
public static void restorePolygonMode() {
449+
setPolygonMode(backupPolygonMode);
450+
backupPolygonMode = GL43C.GL_FILL;
451+
}
452+
428453
public interface DSAAccess {
429454
void generateMipmaps(int texture, int target);
430455

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.coderbot.iris.gl.framebuffer;
2+
3+
public record ViewportData(float scale, float viewportX, float viewportY) {
4+
private static ViewportData DEFAULT = new ViewportData(1.0f, 0.0f, 0.0f);
5+
6+
public static ViewportData defaultValue() {
7+
return DEFAULT;
8+
}
9+
}

src/main/java/net/coderbot/iris/gl/shader/ShaderType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public enum ShaderType {
1313
VERTEX(GL20.GL_VERTEX_SHADER),
1414
GEOMETRY(GL32C.GL_GEOMETRY_SHADER),
1515
FRAGMENT(GL20.GL_FRAGMENT_SHADER),
16-
COMPUTE(GL43C.GL_COMPUTE_SHADER);
16+
COMPUTE(GL43C.GL_COMPUTE_SHADER),
17+
TESSELATION_CONTROL(GL43C.GL_TESS_CONTROL_SHADER),
18+
TESSELATION_EVAL(GL43C.GL_TESS_EVALUATION_SHADER);
1719

1820
public final int id;
1921

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package net.coderbot.iris.gui;
2+
3+
import net.fabricmc.api.EnvType;
4+
import net.fabricmc.api.Environment;
5+
import net.minecraft.client.gui.GuiGraphics;
6+
import net.minecraft.client.gui.components.Button;
7+
import net.minecraft.network.chat.CommonComponents;
8+
import net.minecraft.network.chat.Component;
9+
import net.minecraft.resources.ResourceLocation;
10+
11+
@Environment(EnvType.CLIENT)
12+
public class OldImageButton extends Button {
13+
protected final ResourceLocation resourceLocation;
14+
protected final int xTexStart;
15+
protected final int yTexStart;
16+
protected final int yDiffTex;
17+
protected final int textureWidth;
18+
protected final int textureHeight;
19+
20+
public OldImageButton(
21+
int pImageButton0, int pInt1, int pInt2, int pInt3, int pInt4, int pInt5, ResourceLocation pResourceLocation6, Button.OnPress pButton$OnPress7
22+
) {
23+
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt3, pResourceLocation6, 256, 256, pButton$OnPress7);
24+
}
25+
26+
public OldImageButton(
27+
int pImageButton0,
28+
int pInt1,
29+
int pInt2,
30+
int pInt3,
31+
int pInt4,
32+
int pInt5,
33+
int pInt6,
34+
ResourceLocation pResourceLocation7,
35+
Button.OnPress pButton$OnPress8
36+
) {
37+
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt6, pResourceLocation7, 256, 256, pButton$OnPress8);
38+
}
39+
40+
public OldImageButton(
41+
int pImageButton0,
42+
int pInt1,
43+
int pInt2,
44+
int pInt3,
45+
int pInt4,
46+
int pInt5,
47+
int pInt6,
48+
ResourceLocation pResourceLocation7,
49+
int pInt8,
50+
int pInt9,
51+
Button.OnPress pButton$OnPress10
52+
) {
53+
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt6, pResourceLocation7, pInt8, pInt9, pButton$OnPress10, CommonComponents.EMPTY);
54+
}
55+
56+
public OldImageButton(
57+
int pImageButton0,
58+
int pInt1,
59+
int pInt2,
60+
int pInt3,
61+
int pInt4,
62+
int pInt5,
63+
int pInt6,
64+
ResourceLocation pResourceLocation7,
65+
int pInt8,
66+
int pInt9,
67+
Button.OnPress pButton$OnPress10,
68+
Component pComponent11
69+
) {
70+
super(pImageButton0, pInt1, pInt2, pInt3, pComponent11, pButton$OnPress10, DEFAULT_NARRATION);
71+
this.textureWidth = pInt8;
72+
this.textureHeight = pInt9;
73+
this.xTexStart = pInt4;
74+
this.yTexStart = pInt5;
75+
this.yDiffTex = pInt6;
76+
this.resourceLocation = pResourceLocation7;
77+
}
78+
79+
@Override
80+
public void renderWidget(GuiGraphics pImageButton0, int pInt1, int pInt2, float pFloat3) {
81+
this.renderTexture(
82+
pImageButton0,
83+
this.resourceLocation,
84+
this.getX(),
85+
this.getY(),
86+
this.xTexStart,
87+
this.yTexStart,
88+
this.yDiffTex,
89+
this.width,
90+
this.height,
91+
this.textureWidth,
92+
this.textureHeight
93+
);
94+
}
95+
}

src/main/java/net/coderbot/iris/gui/debug/DebugLoadFailedGridScreen.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,4 @@ protected void init() {
5454

5555
widget.visitWidgets(this::addRenderableWidget);
5656
}
57-
58-
@Override
59-
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
60-
if (this.minecraft.level == null) {
61-
this.renderBackground(guiGraphics);
62-
} else {
63-
guiGraphics.fillGradient(0, 0, width, height, 0x4F232323, 0x4F232323);
64-
}
65-
super.render(guiGraphics, i, j, f);
66-
}
6757
}

0 commit comments

Comments
 (0)