Skip to content

Commit

Permalink
Merge branch '1.20.3' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jul 21, 2024
2 parents 6c20dcd + 4c67e75 commit 258522d
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 73 deletions.
23 changes: 23 additions & 0 deletions src/main/java/kroppeb/stareval/function/AbstractTypedFunction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kroppeb.stareval.function;

import java.util.Arrays;
import java.util.Objects;

public abstract class AbstractTypedFunction implements TypedFunction {
private final Type returnType;
Expand Down Expand Up @@ -41,4 +42,26 @@ public boolean isPure() {
public int priority() {
return this.priority;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof AbstractTypedFunction func) {
return Objects.equals(returnType, func.returnType) &&
Arrays.equals(parameters, func.parameters) &&
priority == func.priority &&
isPure == func.isPure;
}

return false;
}

@Override
public int hashCode() {
return Objects.hash(returnType, Arrays.hashCode(parameters), priority, isPure);
}

@Override
public String toString() {
return TypedFunction.format(this, "unknown");
}
}
14 changes: 14 additions & 0 deletions src/main/java/kroppeb/stareval/function/TypedFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import kroppeb.stareval.expression.Expression;

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

public interface TypedFunction {
Expand Down Expand Up @@ -53,6 +54,19 @@ public Type type() {
public boolean constant() {
return this.isConstant;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof Parameter p) {
return Objects.equals(type, p.type) && Objects.equals(isConstant, p.isConstant);
}
return false;
}

@Override
public int hashCode() {
return Objects.hashCode(type) + 3192 + Objects.hashCode(isConstant);
}
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.irisshaders.batchedentityrendering.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -40,17 +42,15 @@ public class MixinLevelRenderer_EntityListSorting {
@Shadow
private ClientLevel level;

@ModifyVariable(method = "renderLevel", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/lang/Iterable;iterator()Ljava/util/Iterator;"),
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBuffers;bufferSource()Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;shouldRender(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/culling/Frustum;DDD)Z")), allow = 1)
private Iterator<Entity> batchedentityrendering$sortEntityList(Iterator<Entity> iterator) {
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Ljava/lang/Iterable;iterator()Ljava/util/Iterator;"))
private Iterator<Entity> batchedentityrendering$sortEntityList(Iterable<Entity> instance, Operation<Iterator<Entity>> original) {
// Sort the entity list first in order to allow vanilla's entity batching code to work better.
this.level.getProfiler().push("sortEntityList");

Map<EntityType<?>, List<Entity>> sortedEntities = new HashMap<>();

List<Entity> entities = new ArrayList<>();
iterator.forEachRemaining(entity -> {
original.call(instance).forEachRemaining(entity -> {
sortedEntities.computeIfAbsent(entity.getType(), entityType -> new ArrayList<>(32)).add(entity);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum FeatureFlags {
CUSTOM_IMAGES(() -> true, IrisRenderSystem::supportsImageLoadStore),
PER_BUFFER_BLENDING(() -> true, IrisRenderSystem::supportsBufferBlending),
COMPUTE_SHADERS(() -> true, IrisRenderSystem::supportsCompute),
TESSELATION_SHADERS(() -> true, IrisRenderSystem::supportsTesselation),
TESSELLATION_SHADERS(() -> true, IrisRenderSystem::supportsTesselation),
ENTITY_TRANSLUCENT(() -> true, () -> true),
REVERSED_CULLING(() -> true, () -> true),
BLOCK_EMISSION_ATTRIBUTE(() -> true, () -> true),
Expand Down Expand Up @@ -59,6 +59,11 @@ public static boolean isInvalid(String name) {
}

public static FeatureFlags getValue(String value) {
if (value.equalsIgnoreCase("TESSELATION_SHADERS")) {
// fix the sins of the past
value = "TESSELLATION_SHADERS";
}

try {
return FeatureFlags.valueOf(value.toUpperCase(Locale.US));
} catch (IllegalArgumentException e) {
Expand Down
87 changes: 67 additions & 20 deletions src/main/java/net/irisshaders/iris/gl/shader/StandardMacros.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.irisshaders.iris.texture.format.TextureFormat;
import net.irisshaders.iris.texture.format.TextureFormatLoader;
import net.minecraft.Util;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20C;
import org.lwjgl.opengl.GL30C;
Expand Down Expand Up @@ -43,13 +44,14 @@ public static ImmutableList<StringPair> createStandardEnvironmentDefines() {
ArrayList<StringPair> standardDefines = new ArrayList<>();

define(standardDefines, "MC_VERSION", getMcVersion());
define(standardDefines, "IRIS_VERSION", getFormattedIrisVersion());
define(standardDefines, "MC_GL_VERSION", getGlVersion(GL20C.GL_VERSION));
define(standardDefines, "MC_GLSL_VERSION", getGlVersion(GL20C.GL_SHADING_LANGUAGE_VERSION));
define(standardDefines, getOsString());
define(standardDefines, getVendor());
define(standardDefines, getRenderer());
define(standardDefines, "IS_IRIS");
define(standardDefines, "IRIS_TAG_SUPPORT");
define(standardDefines, "IRIS_TAG_SUPPORT", "2");


if (FabricLoader.getInstance().isModLoaded("distanthorizons") && DHCompat.hasRenderingEnabled()) {
Expand Down Expand Up @@ -103,6 +105,7 @@ public static ImmutableList<StringPair> createStandardEnvironmentDefines() {
return ImmutableList.copyOf(standardDefines);
}


/**
* Gets the current mc version String in a 5 digit format
*
Expand All @@ -111,36 +114,78 @@ public static ImmutableList<StringPair> createStandardEnvironmentDefines() {
*/
public static String getMcVersion() {
String version = Iris.getReleaseTarget();

if (version == null) {
throw new IllegalStateException("Could not get the current minecraft version!");
throw new IllegalStateException("Could not get the current Minecraft version!");
}

String[] splitVersion = version.split("\\.");

if (splitVersion.length < 2) {
String formattedVersion = formatVersionString(version);
if (formattedVersion == null) {
Iris.logger.error("Could not parse game version \"" + version + "\"");
splitVersion = Iris.getBackupVersionNumber().split("\\.");
} else {
return formattedVersion;
}
String backupVersion = Iris.getBackupVersionNumber();
String formattedBackupVersion = formatVersionString(backupVersion);
if (formattedBackupVersion == null) {
throw new IllegalArgumentException("Could not parse backup game version \"" + version + "\"");
} else {
return formattedBackupVersion;
}
}

String major = splitVersion[0];
String minor = splitVersion[1];
String bugfix;

if (splitVersion.length < 3) {
bugfix = "00";
/**
* Gets the current Iris version String in a 5 digit format
*
* @return The Iris version string
*
*/
public static String getFormattedIrisVersion() {
String rawVersion = Iris.getVersion();
if (rawVersion == null) {
throw new IllegalArgumentException("Could not get current Iris version!");
}
Matcher matcher = SEMVER_PATTERN.matcher(rawVersion);
if (!matcher.matches()) {
throw new IllegalArgumentException("Could not parse semantic Iris version from \"" + rawVersion + "\"");
}
String major = matcher.group("major");
String minor = matcher.group("minor");
String bugFix = matcher.group("bugfix");
if (bugFix == null) {
bugFix = "0";
}
if (major == null || minor == null) {
throw new IllegalArgumentException("Could not parse semantic Iris version from \"" + rawVersion + "\"");
}
String irisSemver = "%s.%s.%s".formatted(major, minor, bugFix);
String formattedSemver = formatVersionString(irisSemver);
if (formattedSemver == null) {
throw new IllegalArgumentException("Could not get a valid semantic version string for Iris version \"" + irisSemver + "\"");
} else {
bugfix = splitVersion[2];
return formattedSemver;
}
}

if (minor.length() == 1) {
minor = 0 + minor;
/**
*
* Formats a semver string into a 122 format
*
* @param version The string version to format
* @return the formatted version in a 122 format, or <b>null</b> if the string is not a valid semver string.
*/
@Nullable
public static String formatVersionString(String version) {
String[] splitVersion = version.split("\\.");
if (splitVersion.length < 2) {
return null;
}
if (bugfix.length() == 1) {
bugfix = 0 + bugfix;
String major = splitVersion[0];
String minor = splitVersion[1].length() == 1 ? 0 + splitVersion[1] : splitVersion[1];
String bugFix = splitVersion.length < 3 ? "00" : splitVersion[2];
if (bugFix.length() == 1) {
bugFix = 0 + bugFix;
}

return major + minor + bugfix;
return major + minor + bugFix;
}

/**
Expand Down Expand Up @@ -258,6 +303,8 @@ public static String getRenderer() {
return "MC_GL_RENDERER_QUADRO";
} else if (renderer.startsWith("mesa")) {
return "MC_GL_RENDERER_MESA";
} else if (renderer.startsWith("apple")) {
return "MC_GL_RENDERER_APPLE";
}
return "MC_GL_RENDERER_OTHER";
}
Expand Down
15 changes: 1 addition & 14 deletions src/main/java/net/irisshaders/iris/parsing/IrisFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import kroppeb.stareval.function.TypedFunction.Parameter;
import kroppeb.stareval.function.V2FFunction;
import kroppeb.stareval.function.V2IFunction;
import net.irisshaders.iris.Iris;
import org.joml.Matrix4f;
import org.joml.Vector2f;
import org.joml.Vector2i;
Expand Down Expand Up @@ -493,20 +494,6 @@ public void evaluateTo(Expression[] params, FunctionContext context, FunctionRet
}
});
}

for (Type type : VectorType.AllVectorTypes) {
add("if", new AbstractTypedFunction(type, new Type[]{Type.Boolean, type, type}) {
@Override
public void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
params[0].evaluateTo(context, functionReturn);

params[
functionReturn.booleanReturn ? 1 : 2
].evaluateTo(context, functionReturn);

}
});
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public void beginLevelRendering() {

if (!initializedBlockIds) {
WorldRenderingSettings.INSTANCE.setBlockStateIds(
BlockMaterialMapping.createBlockStateIdMap(pack.getIdMap().getBlockProperties()));
BlockMaterialMapping.createBlockStateIdMap(pack.getIdMap().getBlockProperties(), pack.getIdMap().getTagEntries()));
WorldRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(pack.getIdMap().getBlockRenderTypeMap()));
Minecraft.getInstance().levelRenderer.allChanged();
initializedBlockIds = true;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public void beginLevelRendering() {
// A lot of dimension mods touch sky rendering, FabricSkyboxes injects at HEAD and cancels, etc.
DimensionSpecialEffects.SkyType skyType = Minecraft.getInstance().level.effects().skyType();

if (skyType == DimensionSpecialEffects.SkyType.NORMAL) {
if (skyType == DimensionSpecialEffects.SkyType.NORMAL || Minecraft.getInstance().level.dimensionType().hasSkyLight()) {
RenderSystem.depthMask(false);

RenderSystem.setShaderColor(fogColor.x, fogColor.y, fogColor.z, fogColor.w);
Expand Down
Loading

0 comments on commit 258522d

Please sign in to comment.