forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce9969e
commit 8552860
Showing
36 changed files
with
383 additions
and
222 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/main/java/net/irisshaders/batchedentityrendering/mixin/MixinRenderBuffers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/net/irisshaders/iris/compat/pixelmon/mixin/MixinNormalizedFace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.irisshaders.iris.compat.pixelmon.mixin; | ||
|
||
import com.mojang.blaze3d.vertex.BufferBuilder; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Coerce; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Pseudo | ||
@Mixin(targets = {"com/pixelmonmod/pixelmon/client/models/smd/NormalizedFace"}) | ||
public class MixinNormalizedFace { | ||
/** | ||
* @author embeddedt (original idea by NanoLive) | ||
* @reason Pixelmon manipulates the buffer of a {@link BufferBuilder} directly which causes problems. | ||
* We bypass that code path. | ||
*/ | ||
@Redirect(method = "addFaceForRender", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lcom/pixelmonmod/pixelmon/client/models/smd/DeformVertex;id2:I")) | ||
public int hideBufferBuilderId(@Coerce Object instance) { | ||
return -1; // prevent using "optimized" code path | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...main/java/net/irisshaders/iris/compat/pixelmon/mixin/OculusPixelmonCompatMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.irisshaders.iris.compat.pixelmon.mixin; | ||
|
||
import net.minecraftforge.fml.loading.FMLLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class OculusPixelmonCompatMixinPlugin implements IMixinConfigPlugin { | ||
@Override | ||
public void onLoad(String mixinPackage) { | ||
|
||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return FMLLoader.getLoadingModList().getModFileById("pixelmon") != null; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/net/irisshaders/iris/mixin/MixinChunkRenderDispatcherRebuildTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.irisshaders.iris.mixin; | ||
|
||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings; | ||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraftforge.client.ChunkRenderTypeSet; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(ChunkRenderDispatcher.RenderChunk.RebuildTask.class) | ||
public class MixinChunkRenderDispatcherRebuildTask { | ||
@Redirect(method = "compile", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/BakedModel;getRenderTypes(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;)Lnet/minecraftforge/client/ChunkRenderTypeSet;")) | ||
private ChunkRenderTypeSet oculus$overrideRenderTypes(BakedModel instance, BlockState blockState, RandomSource randomSource, ModelData modelData) { | ||
Map<Holder.Reference<Block>, ChunkRenderTypeSet> idMap = WorldRenderingSettings.INSTANCE.getBlockTypeIds(); | ||
if (idMap != null) { | ||
ChunkRenderTypeSet type = idMap.get(ForgeRegistries.BLOCKS.getDelegateOrThrow(blockState.getBlock())); | ||
if (type != null) { | ||
return type; | ||
} | ||
} | ||
|
||
return instance.getRenderTypes(blockState, randomSource, modelData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/main/java/net/irisshaders/iris/mixin/MixinMinecraft_Images.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/main/java/net/irisshaders/iris/mixin/MixinMinecraft_Keybinds.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/main/java/net/irisshaders/iris/mixin/MixinShaderInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package net.irisshaders.iris.mixin; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.gson.JsonObject; | ||
import com.mojang.blaze3d.shaders.Uniform; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import net.irisshaders.iris.Iris; | ||
import net.irisshaders.iris.gl.IrisRenderSystem; | ||
import net.irisshaders.iris.gl.blending.DepthColorStorage; | ||
import net.irisshaders.iris.pipeline.ShaderRenderingPipeline; | ||
import net.irisshaders.iris.pipeline.WorldRenderingPipeline; | ||
import net.irisshaders.iris.pipeline.programs.ExtendedShader; | ||
import net.irisshaders.iris.pipeline.programs.FallbackShader; | ||
import net.irisshaders.iris.pipeline.programs.ShaderInstanceInterface; | ||
import net.minecraft.client.renderer.ShaderInstance; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.resources.ResourceProvider; | ||
import net.minecraft.util.GsonHelper; | ||
import org.lwjgl.opengl.ARBTextureSwizzle; | ||
import org.lwjgl.opengl.GL20C; | ||
import org.lwjgl.opengl.GL30C; | ||
import net.minecraft.util.GsonHelper; | ||
import org.slf4j.Logger; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import java.io.Reader; | ||
import java.util.Objects; | ||
|
||
@Mixin(ShaderInstance.class) | ||
public abstract class MixinShaderInstance implements ShaderInstanceInterface { | ||
@Unique | ||
private static final ImmutableSet<String> ATTRIBUTE_LIST = ImmutableSet.of("Position", "Color", "Normal", "UV0", "UV1", "UV2"); | ||
|
||
private static boolean shouldOverrideShaders() { | ||
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable(); | ||
|
||
if (pipeline instanceof ShaderRenderingPipeline) { | ||
return ((ShaderRenderingPipeline) pipeline).shouldOverrideShaders(); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@Shadow | ||
public abstract int getId(); | ||
|
||
@Redirect(method = "updateLocations", | ||
at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false)) | ||
private void iris$redirectLogSpam(Logger logger, String message, Object arg1, Object arg2) { | ||
if (((Object) this) instanceof ExtendedShader || ((Object) this) instanceof FallbackShader) { | ||
return; | ||
} | ||
|
||
logger.warn(message, arg1, arg2); | ||
} | ||
|
||
@Redirect(method = "<init>(Lnet/minecraft/server/packs/resources/ResourceProvider;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/blaze3d/vertex/VertexFormat;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/shaders/Uniform;glBindAttribLocation(IILjava/lang/CharSequence;)V")) | ||
public void iris$redirectBindAttributeLocation(int i, int j, CharSequence charSequence) { | ||
if (((Object) this) instanceof ExtendedShader && ATTRIBUTE_LIST.contains(charSequence)) { | ||
Uniform.glBindAttribLocation(i, j, "iris_" + charSequence); | ||
} else { | ||
Uniform.glBindAttribLocation(i, j, charSequence); | ||
} | ||
} | ||
|
||
@Inject(method = "apply", at = @At("TAIL")) | ||
private void iris$lockDepthColorState(CallbackInfo ci) { | ||
if (((Object) this) instanceof ExtendedShader || ((Object) this) instanceof FallbackShader || !shouldOverrideShaders()) { | ||
return; | ||
} | ||
|
||
DepthColorStorage.disableDepthColor(); | ||
} | ||
|
||
@Inject(method = "clear", at = @At("HEAD")) | ||
private void iris$unlockDepthColorState(CallbackInfo ci) { | ||
if (((Object) this) instanceof ExtendedShader || ((Object) this) instanceof FallbackShader || !shouldOverrideShaders()) { | ||
return; | ||
} | ||
|
||
DepthColorStorage.unlockDepthColor(); | ||
} | ||
|
||
@Redirect(method = "<init>(Lnet/minecraft/server/packs/resources/ResourceProvider;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/blaze3d/vertex/VertexFormat;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/GsonHelper;parse(Ljava/io/Reader;)Lcom/google/gson/JsonObject;")) | ||
public JsonObject iris$setupGeometryShader(Reader reader, ResourceProvider resourceProvider, ResourceLocation name, VertexFormat vertexFormat) { | ||
this.iris$createExtraShaders(resourceProvider, name); | ||
return GsonHelper.parse(reader); | ||
} | ||
|
||
@Override | ||
public void iris$createExtraShaders(ResourceProvider provider, ResourceLocation name) { | ||
//no-op, used for ExtendedShader to call before the super constructor | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/net/irisshaders/iris/mixin/OculusMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
src/main/java/net/irisshaders/iris/mixin/devenvironment/MixinMinecraft_NoAuthInDev.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/main/java/net/irisshaders/iris/mixin/devenvironment/MixinProfileKeyPairManager.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/java/net/irisshaders/iris/mixin/devenvironment/MixinSharedConstants_LazyDfu.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.