Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 24, 2024
1 parent b8b531c commit 9ea4079
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private MixinCompositeRenderType(String name, VertexFormat vertexFormat, VertexF
private void batchedentityrendering$onCompositeInit(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, boolean bl2, CompositeState compositeState, CallbackInfo ci) {
RenderStateShard.TransparencyStateShard transparency = ((CompositeStateAccessor) (Object) compositeState).getTransparency();

if ("water_mask".equals(name)) {
if (name.contains("water_mask")) {
transparencyType = TransparencyType.WATER_MASK;
} else if ("lines".equals(name)) {
transparencyType = TransparencyType.LINES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public void prepareNewPipeline(NewWorldRenderingPipeline pipeline, boolean dhSha
if (pipeline.getDHShadowShader().isPresent() && dhShadowEnabled) {
ProgramSource shadow = pipeline.getDHShadowShader().get();
shadowProgram = IrisLodRenderProgram.createProgram(shadow.getName(), true, shadow, pipeline.getCustomUniforms(), pipeline);
dhShadowFramebuffer = pipeline.createDHFramebufferShadow(shadow);
if (pipeline.hasShadowRenderTargets()) {
dhShadowFramebuffer = pipeline.createDHFramebufferShadow(shadow);
}
shouldOverrideShadow = true;
} else {
shouldOverrideShadow = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ public void setupBuffers() {
}

for (ShaderStorageBuffer buffer : buffers) {
buffer.bind();
if (buffer != null) {
buffer.bind();
}
}
}

public void destroyBuffers() {
for (ShaderStorageBuffer buffer : buffers) {
buffer.destroy();
if (buffer != null) {
buffer.destroy();
}
}
buffers = null;
destroyed = true;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/MixinBoatRender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.coderbot.iris.mixin;

import net.coderbot.iris.pipeline.LightningHandler;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.BoatRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(BoatRenderer.class)
public class MixinBoatRender {
@Redirect(method = "render(Lnet/minecraft/world/entity/vehicle/Boat;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;waterMask()Lnet/minecraft/client/renderer/RenderType;"))
private RenderType changeWaterMask() {

return LightningHandler.IRIS_WATERMASK;
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/coderbot/iris/pipeline/LightningHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.coderbot.iris.layer.InnerWrappedRenderType;
import net.coderbot.iris.layer.LightningRenderStateShard;
import net.coderbot.iris.layer.OuterWrappedRenderType;
import net.coderbot.iris.vertices.IrisVertexFormats;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;

public class LightningHandler extends RenderType {
Expand All @@ -22,6 +24,19 @@ public class LightningHandler extends RenderType {
.setOutputState(WEATHER_TARGET)
.createCompositeState(false)
), new LightningRenderStateShard());
public static final RenderType IRIS_WATERMASK = RenderType.create(
"iris_water_mask",
DefaultVertexFormat.NEW_ENTITY,
VertexFormat.Mode.QUADS,
1536,
false,
true,
RenderType.CompositeState.builder()
.setShaderState(RenderStateShard.RENDERTYPE_WATER_MASK_SHADER)
.setTextureState(NO_TEXTURE)
.setWriteMaskState(DEPTH_WRITE)
.createCompositeState(false)
);

public LightningHandler(String pRenderType0, VertexFormat pVertexFormat1, VertexFormat.Mode pVertexFormat$Mode2, int pInt3, boolean pBoolean4, boolean pBoolean5, Runnable pRunnable6, Runnable pRunnable7) {
super(pRenderType0, pVertexFormat1, pVertexFormat$Mode2, pInt3, pBoolean4, pBoolean5, pRunnable6, pRunnable7);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,15 @@ public void addGbufferOrShadowSamplers(SamplerHolder samplers, ImageHolder image
IrisSamplers.addNoiseSampler(samplerHolder, this.customTextureManager.getNoiseTexture());
IrisSamplers.addCustomImages(samplerHolder, customImages);

if (isShadowPass || IrisSamplers.hasShadowSamplers(samplerHolder)) {
if (IrisSamplers.hasShadowSamplers(samplerHolder)) {
if (!isShadowPass) {
shadowTargetsSupplier.get();
}

IrisSamplers.addShadowSamplers(samplerHolder, Objects.requireNonNull(shadowRenderTargets), null, separateHardwareSamplers);
}

if (isShadowPass || IrisImages.hasShadowImages(images)) {
if ( IrisImages.hasShadowImages(images)) {
// Note: hasShadowSamplers currently queries for shadow images too, so the shadow render targets will be
// created by this point... that's sorta ugly, though.
IrisImages.addShadowColorImages(images, Objects.requireNonNull(shadowRenderTargets), null);
Expand Down Expand Up @@ -1304,6 +1304,11 @@ public GlFramebuffer createDHFramebuffer(ProgramSource sources, boolean trans) {
}

public GlFramebuffer createDHFramebufferShadow(ProgramSource sources) {

return shadowRenderTargets.createDHFramebuffer(ImmutableSet.of(), new int[]{0, 1});
}

public boolean hasShadowRenderTargets() {
return shadowRenderTargets != null;
}
}
10 changes: 10 additions & 0 deletions src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
return;
}

if (trueSize < 1) {
// Assume the shader dev intended to disable the buffer
return;
}

bufferObjects.put(trueIndex, new ShaderStorageInfo(trueSize, false, 0, 0));
} else {
// Assume it's a long one
Expand All @@ -376,6 +381,11 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
return;
}

if (trueSize < 1) {
// Assume the shader dev intended to disable the buffer
return;
}

if (trueIndex > 8) {
Iris.logger.fatal("SSBO's cannot use buffer numbers higher than 8, they're reserved!");
return;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"LightTextureAccessor",
"ProgramTypeAccessor",
"MixinBlockStateBehavior",
"MixinBoatRender",
"MixinBiome",
"MixinBiomes",
"MixinChainedJsonException",
Expand Down

0 comments on commit 9ea4079

Please sign in to comment.