Skip to content

Commit

Permalink
Support true sampler limit
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 11, 2023
1 parent de8e3bd commit b05b6c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin({GlStateManager.class, RenderSystem.class})
@Mixin(GlStateManager.class)
public class MixinGlStateManager {
@ModifyConstant(method = "<clinit>", constant = @Constant(intValue = 12), require = 1)
private static int iris$increaseMaximumAllowedTextureUnits(int existingValue) {
// should be enough, I hope...
// We can't query OpenGL for this since RenderSystem is initialized too early.
return 128;
return SamplerLimits.get().getMaxTextureUnits();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.coderbot.iris.gl.sampler.SamplerLimits;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL46C;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -25,7 +26,7 @@ public class MixinGlStateManager_MultiBind {
@Final
private static GlStateManager.TextureState[] TEXTURES;
private static boolean hasChangedTextures = false;
private static int[] streamlinedTextures = new int[64];
private static int[] streamlinedTextures = new int[SamplerLimits.get().getMaxTextureUnits()];
private static int realActiveTexture = 0;

static {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/MixinRenderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@
import com.mojang.blaze3d.systems.RenderSystem;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gl.GLDebug;
import net.coderbot.iris.gl.sampler.SamplerLimits;
import net.coderbot.iris.samplers.IrisSamplers;
import net.coderbot.iris.texture.TextureTracker;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation;
import net.coderbot.iris.gl.IrisRenderSystem;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(RenderSystem.class)
public class MixinRenderSystem {
@Mutable
@Shadow
@Final
private static int[] shaderTextures;

@Inject(method = "initRenderer", at = @At("RETURN"), remap = false)
private static void iris$onRendererInit(int debugVerbosity, boolean alwaysFalse, CallbackInfo ci) {
shaderTextures = new int[SamplerLimits.get().getMaxTextureUnits()];
Iris.duringRenderSystemInit();
GLDebug.initRenderer();
IrisRenderSystem.initRenderer();
Expand Down

0 comments on commit b05b6c5

Please sign in to comment.