fix iris issues when enabling and disabling voxy rendering while shaders are active
This commit is contained in:
@@ -134,8 +134,8 @@ dependencies {
|
|||||||
modCompileOnly("maven.modrinth:modmenu:17.0.0-alpha.1")
|
modCompileOnly("maven.modrinth:modmenu:17.0.0-alpha.1")
|
||||||
modRuntimeOnlyMsk("maven.modrinth:modmenu:17.0.0-alpha.1")
|
modRuntimeOnlyMsk("maven.modrinth:modmenu:17.0.0-alpha.1")
|
||||||
|
|
||||||
modCompileOnly("maven.modrinth:iris:1.10.0+1.21.11-fabric")
|
modCompileOnly("maven.modrinth:iris:1.10.4+1.21.11-fabric")
|
||||||
//modRuntimeOnlyMsk("maven.modrinth:iris:1.10.0+1.21.11-fabric")
|
modRuntimeOnlyMsk("maven.modrinth:iris:1.10.4+1.21.11-fabric")
|
||||||
|
|
||||||
//modCompileOnly("maven.modrinth:starlight:1.1.3+1.20.4")
|
//modCompileOnly("maven.modrinth:starlight:1.1.3+1.20.4")
|
||||||
|
|
||||||
|
|||||||
@@ -146,18 +146,12 @@ public class SodiumConfigBuilder {
|
|||||||
protected Identifier[] postRunnerConflicts;
|
protected Identifier[] postRunnerConflicts;
|
||||||
protected Identifier[] postChangeFlags;
|
protected Identifier[] postChangeFlags;
|
||||||
public OPTION setPostChangeRunner(Consumer<TYPE> postRunner, String... dontRunIfChangedVars) {
|
public OPTION setPostChangeRunner(Consumer<TYPE> postRunner, String... dontRunIfChangedVars) {
|
||||||
if (this.postChangeFlags != null) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
this.postRunner = postRunner;
|
this.postRunner = postRunner;
|
||||||
this.postRunnerConflicts = mapIds(dontRunIfChangedVars);
|
this.postRunnerConflicts = mapIds(dontRunIfChangedVars);
|
||||||
return (OPTION) this;
|
return (OPTION) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OPTION setPostChangeFlags(String... flags) {
|
public OPTION setPostChangeFlags(String... flags) {
|
||||||
if (this.postRunner != null) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
this.postChangeFlags = mapIds(flags);
|
this.postChangeFlags = mapIds(flags);
|
||||||
return (OPTION) this;
|
return (OPTION) this;
|
||||||
}
|
}
|
||||||
@@ -169,14 +163,21 @@ public class SodiumConfigBuilder {
|
|||||||
option.setName(this.name);
|
option.setName(this.name);
|
||||||
option.setTooltip(this.tooltip);
|
option.setTooltip(this.tooltip);
|
||||||
|
|
||||||
|
Set<Identifier> flags = new LinkedHashSet<>();
|
||||||
if (this.postRunner != null) {
|
if (this.postRunner != null) {
|
||||||
var id = Identifier.parse(this.id);
|
var id = Identifier.parse(this.id);
|
||||||
var runner = this.postRunner;
|
var runner = this.postRunner;
|
||||||
var getter = this.getter;
|
var getter = this.getter;
|
||||||
ctx.postRunner.register(id, ()->runner.accept(getter.get()), this.postRunnerConflicts);
|
ctx.postRunner.register(id, ()->runner.accept(getter.get()), this.postRunnerConflicts);
|
||||||
option.setFlags(id);
|
flags.add(id);
|
||||||
} else if (this.postChangeFlags != null) {
|
}
|
||||||
option.setFlags(this.postChangeFlags);
|
|
||||||
|
if (this.postChangeFlags != null) {
|
||||||
|
flags.addAll(List.of(this.postChangeFlags));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flags.isEmpty()) {
|
||||||
|
option.setFlags(flags.toArray(Identifier[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
option.setBinding(this.setter, this.getter);
|
option.setBinding(this.setter, this.getter);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import me.cortex.voxy.client.config.SodiumConfigBuilder.*;
|
|||||||
import me.cortex.voxy.client.VoxyClient;
|
import me.cortex.voxy.client.VoxyClient;
|
||||||
import me.cortex.voxy.client.VoxyClientInstance;
|
import me.cortex.voxy.client.VoxyClientInstance;
|
||||||
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
||||||
|
import me.cortex.voxy.client.core.util.IrisUtil;
|
||||||
import me.cortex.voxy.common.util.cpu.CpuLayout;
|
import me.cortex.voxy.common.util.cpu.CpuLayout;
|
||||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||||
import net.caffeinemc.mods.sodium.api.config.ConfigEntryPoint;
|
import net.caffeinemc.mods.sodium.api.config.ConfigEntryPoint;
|
||||||
@@ -24,37 +25,37 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
|||||||
var cc = B.registerModOptions("voxy", "Voxy", VoxyCommon.MOD_VERSION)
|
var cc = B.registerModOptions("voxy", "Voxy", VoxyCommon.MOD_VERSION)
|
||||||
.setIcon(Identifier.parse("voxy:icon.png"));
|
.setIcon(Identifier.parse("voxy:icon.png"));
|
||||||
|
|
||||||
|
final var RENDER_RELOAD = OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString();
|
||||||
|
|
||||||
SodiumConfigBuilder.buildToSodium(B, cc, CFG::save, postOp->{
|
SodiumConfigBuilder.buildToSodium(B, cc, CFG::save, postOp->{
|
||||||
postOp.register("voxy:update_threads", ()->{
|
postOp.register("voxy:update_threads", ()->{
|
||||||
var instance = VoxyCommon.getInstance();
|
var instance = VoxyCommon.getInstance();
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
instance.updateDedicatedThreads();
|
instance.updateDedicatedThreads();
|
||||||
}
|
}
|
||||||
}, "voxy:enabled");
|
}, "voxy:enabled").register("voxy:iris_reload", ()->IrisUtil.reload());
|
||||||
},
|
},
|
||||||
new Page(Component.translatable("voxy.config.general"),
|
new Page(Component.translatable("voxy.config.general"),
|
||||||
new Group(
|
new Group(
|
||||||
new BoolOption(
|
new BoolOption(
|
||||||
"voxy:enabled",
|
"voxy:enabled",
|
||||||
Component.translatable("voxy.config.general.enabled"),
|
Component.translatable("voxy.config.general.enabled"),
|
||||||
()->CFG.enabled, v->CFG.enabled=v)
|
()->CFG.enabled, v->{
|
||||||
|
CFG.enabled=v;
|
||||||
|
//we need to special case enabled, since the render reload flag runs befor us and its quite important we get it right
|
||||||
|
if (v&&VoxyClientInstance.isInGame) {
|
||||||
|
VoxyCommon.createInstance();
|
||||||
|
}
|
||||||
|
})
|
||||||
.setPostChangeRunner(c->{
|
.setPostChangeRunner(c->{
|
||||||
if (c) {
|
if (!c) {
|
||||||
if (VoxyClientInstance.isInGame) {
|
|
||||||
VoxyCommon.createInstance();
|
|
||||||
var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
|
|
||||||
if (vrsh != null && CFG.enableRendering) {
|
|
||||||
vrsh.createRenderer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
|
var vrsh = (IGetVoxyRenderSystem) Minecraft.getInstance().levelRenderer;
|
||||||
if (vrsh != null) {
|
if (vrsh != null) {
|
||||||
vrsh.shutdownRenderer();
|
vrsh.shutdownRenderer();
|
||||||
}
|
}
|
||||||
VoxyCommon.shutdownInstance();
|
VoxyCommon.shutdownInstance();
|
||||||
}
|
}
|
||||||
}).setEnabler(null)
|
}).setPostChangeFlags(RENDER_RELOAD, "voxy:iris_reload").setEnabler(null)
|
||||||
), new Group(
|
), new Group(
|
||||||
new IntOption(
|
new IntOption(
|
||||||
"voxy:thread_count",
|
"voxy:thread_count",
|
||||||
@@ -89,7 +90,8 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
|||||||
vrsh.shutdownRenderer();
|
vrsh.shutdownRenderer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},"voxy:enabled", "voxy:renderer_reload")
|
},"voxy:enabled", RENDER_RELOAD)
|
||||||
|
.setPostChangeFlags("voxy:iris_reload")
|
||||||
.setEnabler("voxy:enabled")
|
.setEnabler("voxy:enabled")
|
||||||
), new Group(
|
), new Group(
|
||||||
new IntOption(
|
new IntOption(
|
||||||
@@ -112,19 +114,19 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
|||||||
vrs.setRenderDistance(c);
|
vrs.setRenderDistance(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "voxy:rendering", "voxy:renderer_reload")
|
}, "voxy:rendering", RENDER_RELOAD)
|
||||||
), new Group(
|
), new Group(
|
||||||
new BoolOption(
|
new BoolOption(
|
||||||
"voxy:eviromental_fog",
|
"voxy:eviromental_fog",
|
||||||
Component.translatable("voxy.config.general.environmental_fog"),
|
Component.translatable("voxy.config.general.environmental_fog"),
|
||||||
()->CFG.useEnvironmentalFog, v->CFG.useEnvironmentalFog=v)
|
()->CFG.useEnvironmentalFog, v->CFG.useEnvironmentalFog=v)
|
||||||
.setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString())
|
.setPostChangeFlags(RENDER_RELOAD)
|
||||||
), new Group(
|
), new Group(
|
||||||
new BoolOption(
|
new BoolOption(
|
||||||
"voxy:render_debug",
|
"voxy:render_debug",
|
||||||
Component.translatable("voxy.config.general.render_statistics"),
|
Component.translatable("voxy.config.general.render_statistics"),
|
||||||
()-> RenderStatistics.enabled, v->RenderStatistics.enabled=v)
|
()-> RenderStatistics.enabled, v->RenderStatistics.enabled=v)
|
||||||
.setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString()))
|
.setPostChangeFlags(RENDER_RELOAD))
|
||||||
).setEnablerAND("voxy:enabled", "voxy:rendering"));
|
).setEnablerAND("voxy:enabled", "voxy:rendering"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
import org.lwjgl.opengl.ARBDrawBuffersBlend;
|
||||||
import org.lwjgl.opengl.GL14;
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
@@ -203,7 +204,7 @@ public class ModelTextureBakery {
|
|||||||
if (layer == ChunkSectionLayer.TRANSLUCENT) {
|
if (layer == ChunkSectionLayer.TRANSLUCENT) {
|
||||||
glEnablei(GL_BLEND, 0);
|
glEnablei(GL_BLEND, 0);
|
||||||
glDisablei(GL_BLEND, 1);
|
glDisablei(GL_BLEND, 1);
|
||||||
glBlendFuncSeparatei(0, GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
ARBDrawBuffersBlend.glBlendFuncSeparateiARB(0, GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);//FUCK YOU INTEL (screams), for _some reason_ discard or something... JUST DOESNT WORK??
|
glDisable(GL_BLEND);//FUCK YOU INTEL (screams), for _some reason_ discard or something... JUST DOESNT WORK??
|
||||||
//glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE);
|
//glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE);
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import net.irisshaders.iris.api.v0.IrisApi;
|
|||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.shadows.ShadowRenderer;
|
import net.irisshaders.iris.shadows.ShadowRenderer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class IrisUtil {
|
public class IrisUtil {
|
||||||
|
|
||||||
public record CapturedViewportParameters(ChunkRenderMatrices matrices, FogParameters parameters, double x, double y, double z) {
|
public record CapturedViewportParameters(ChunkRenderMatrices matrices, FogParameters parameters, double x, double y, double z) {
|
||||||
public Viewport<?> apply(VoxyRenderSystem vrs) {
|
public Viewport<?> apply(VoxyRenderSystem vrs) {
|
||||||
return vrs.setupViewport(this.matrices, this.parameters, this.x, this.y, this.z);
|
return vrs.setupViewport(this.matrices, this.parameters, this.x, this.y, this.z);
|
||||||
@@ -34,6 +37,19 @@ public class IrisUtil {
|
|||||||
public static void clearIrisSamplers() {
|
public static void clearIrisSamplers() {
|
||||||
if (IRIS_INSTALLED) clearIrisSamplers0();
|
if (IRIS_INSTALLED) clearIrisSamplers0();
|
||||||
}
|
}
|
||||||
|
public static void reload() {
|
||||||
|
if (IRIS_INSTALLED) reload0();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void reload0() {
|
||||||
|
try {
|
||||||
|
if (IrisApi.getInstance().isShaderPackInUse()) {//Only reload if there is a shaderpack
|
||||||
|
Iris.reload();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void clearIrisSamplers0() {
|
private static void clearIrisSamplers0() {
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
|
|||||||
@@ -60,10 +60,14 @@ public abstract class MixinLevelRenderer implements IGetVoxyRenderSystem {
|
|||||||
@Override
|
@Override
|
||||||
public void createRenderer() {
|
public void createRenderer() {
|
||||||
if (this.renderer != null) throw new IllegalStateException("Cannot have multiple renderers");
|
if (this.renderer != null) throw new IllegalStateException("Cannot have multiple renderers");
|
||||||
if (!VoxyConfig.CONFIG.isRenderingEnabled()) {
|
if (!VoxyConfig.CONFIG.enabled) {
|
||||||
Logger.info("Not creating renderer due to disabled");
|
Logger.info("Not creating renderer due to disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!VoxyConfig.CONFIG.isRenderingEnabled()) {
|
||||||
|
Logger.info("Not creating renderer due to disabled rendering");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.level == null) {
|
if (this.level == null) {
|
||||||
Logger.error("Not creating renderer due to null world");
|
Logger.error("Not creating renderer due to null world");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ public class Mapper {
|
|||||||
return (id&(~(0xFFL<<56)))|(Integer.toUnsignedLong(light&0xFF)<<56);
|
return (id&(~(0xFFL<<56)))|(Integer.toUnsignedLong(light&0xFF)<<56);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long withBlockBiome(long id, int block, int biome) {
|
||||||
|
return (id&(0xFFL<<56))|(Integer.toUnsignedLong(block)<<27)|(Integer.toUnsignedLong(biome)<<47);
|
||||||
|
}
|
||||||
|
|
||||||
public static long airWithLight(int light) {
|
public static long airWithLight(int light) {
|
||||||
return Integer.toUnsignedLong(light&0xFF)<<56;
|
return Integer.toUnsignedLong(light&0xFF)<<56;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user