Skip to content

Commit

Permalink
support 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RogoShum committed May 5, 2024
1 parent 3772a62 commit a080f1f
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 207 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ dependencies {
implementation "me.zeroeightsix:fiber:${project.fiber_version}"
include "me.zeroeightsix:fiber:${project.fiber_version}"

modImplementation "maven.modrinth:sodium:mc1.20.1-0.5.8"
modImplementation 'maven.modrinth:iris:1.6.17+1.20.1'
modImplementation "maven.modrinth:sodium:mc1.20.4-0.5.8"
modImplementation 'maven.modrinth:iris:1.7.0+1.20.4'

implementation("org.anarres:jcpp:1.4.14")
modImplementation("io.github.douira:glsl-transformer:2.0.0-pre13")

modImplementation('maven.modrinth:nvidium:0.2.6-beta')
//architectury
modImplementation('maven.modrinth:lhGA9TYQ:WbL7MStR')
//modImplementation('maven.modrinth:lhGA9TYQ:WbL7MStR')
}

processResources {
Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.9
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.10
loader_version=0.15.10

# Mod Properties
mod_version=0.5.8
mod_version=0.5.9
maven_group=rogo.renderingculling
archives_base_name=BruteForceRenderingCulling-fabric-1.20.1
archives_base_name=BruteForceRenderingCulling-fabric-1.20.4
mod_id=brute_force_rendering_culling

#Fabric api
fabric_version=0.92.1+1.20.1
fabric_version=0.97.0+1.20.4
fiber_version = 0.23.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
Expand All @@ -27,10 +28,10 @@
import rogo.renderingculling.api.data.ChunkCullingMap;
import rogo.renderingculling.api.data.EntityCullingMap;
import rogo.renderingculling.api.impl.IEntitiesForRender;
import rogo.renderingculling.api.impl.IRenderChunkInfo;
import rogo.renderingculling.api.impl.IRenderSectionVisibility;
import rogo.renderingculling.mixin.AccessorLevelRender;
import rogo.renderingculling.mixin.AccessorMinecraft;
import rogo.renderingculling.mixin.AccessorSectionOcclusionGraph;
import rogo.renderingculling.util.DepthContext;
import rogo.renderingculling.util.LifeTimer;
import rogo.renderingculling.util.OcclusionCullerThread;
Expand Down Expand Up @@ -313,7 +314,7 @@ public static boolean shouldSkipEntity(Entity entity) {
public static void onProfilerPopPush(String s) {
switch (s) {
case "beforeRunTick" -> {
if (((AccessorLevelRender) Minecraft.getInstance().levelRenderer).getNeedsFullRenderChunkUpdate() && Minecraft.getInstance().level != null) {
if (((AccessorSectionOcclusionGraph)((AccessorLevelRender) Minecraft.getInstance().levelRenderer).getSectionOcclusionGraph()).getNeedsFullUpdate() && Minecraft.getInstance().level != null) {
ModLoader.pauseAsync();

LEVEL_SECTION_RANGE = Minecraft.getInstance().level.getMaxSection() - Minecraft.getInstance().level.getMinSection();
Expand Down Expand Up @@ -595,8 +596,8 @@ public static void updateMapData() {
CullingStateManager.ENTITY_CULLING_MAP.getEntityTable().tick(clientTickCount);
Iterable<Entity> entities = Minecraft.getInstance().level.entitiesForRendering();
entities.forEach(entity -> CullingStateManager.ENTITY_CULLING_MAP.getEntityTable().addObject(entity));
for (Object levelrenderer$renderchunkinfo : ((IEntitiesForRender) Minecraft.getInstance().levelRenderer).renderChunksInFrustum()) {
List<BlockEntity> list = ((IRenderChunkInfo) levelrenderer$renderchunkinfo).getRenderChunk().getCompiledChunk().getRenderableBlockEntities();
for (SectionRenderDispatcher.RenderSection section : ((IEntitiesForRender) Minecraft.getInstance().levelRenderer).renderChunksInFrustum()) {
List<BlockEntity> list = section.getCompiled().getRenderableBlockEntities();
list.forEach(entity -> CullingStateManager.ENTITY_CULLING_MAP.getEntityTable().addObject(entity));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package rogo.renderingculling.api.impl;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;

public interface IEntitiesForRender {
ObjectArrayList<?> renderChunksInFrustum();
ChunkRenderDispatcher.RenderChunk invokeGetRelativeFrom(BlockPos pos, ChunkRenderDispatcher.RenderChunk chunk, Direction dir);
ChunkRenderDispatcher.RenderChunk invokeGetRenderChunkAt(BlockPos pos);

ObjectArrayList<SectionRenderDispatcher.RenderSection> renderChunksInFrustum();
}

This file was deleted.

9 changes: 6 additions & 3 deletions src/main/java/rogo/renderingculling/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static float v(int height) {
}

@Override
public void renderBackground(GuiGraphics guiGraphics) {
public void renderTransparentBackground(GuiGraphics guiGraphics) {
Minecraft minecraft = Minecraft.getInstance();
int width = minecraft.getWindow().getGuiScaledWidth() / 2;
int widthScale = 85;
Expand Down Expand Up @@ -75,7 +75,10 @@ public void renderBackground(GuiGraphics guiGraphics) {
.color(bgColor, bgColor, bgColor, bgAlpha)
.uv(u(right - 1), v(top - 1)).endVertex();
RenderSystem.setShaderTexture(0, Minecraft.getInstance().getMainRenderTarget().getColorTextureId());
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
BufferUploader.drawWithShader(bufferbuilder.end());

bgAlpha = 1.0f;
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
Expand All @@ -87,7 +90,7 @@ public void renderBackground(GuiGraphics guiGraphics) {
.color(bgColor, bgColor, bgColor, bgAlpha).endVertex();
bufferbuilder.vertex(right, top, 0.0D)
.color(bgColor, bgColor, bgColor, bgAlpha).endVertex();
RenderSystem.enableBlend();

RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ZERO);
BufferUploader.drawWithShader(bufferbuilder.end());
RenderSystem.defaultBlendFunc();
Expand Down Expand Up @@ -216,7 +219,7 @@ public boolean mouseDragged(double p_94699_, double p_94700_, int p_94701_, doub

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics);
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
List<? extends GuiEventListener> children = children();

for (GuiEventListener button : children) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rogo.renderingculling.mixin;

import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.SectionOcclusionGraph;
import net.minecraft.client.renderer.culling.Frustum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
Expand All @@ -13,7 +14,6 @@ public interface AccessorLevelRender {
@Accessor("capturedFrustum")
Frustum getCapturedFrustum();

@Accessor("needsFullRenderChunkUpdate")
boolean getNeedsFullRenderChunkUpdate();
}

@Accessor("sectionOcclusionGraph")
SectionOcclusionGraph getSectionOcclusionGraph();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package rogo.renderingculling.mixin;

import net.minecraft.client.renderer.SectionOcclusionGraph;
import net.minecraft.client.renderer.culling.Frustum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(SectionOcclusionGraph.class)
public interface AccessorSectionOcclusionGraph {

@Accessor("needsFullUpdate")
boolean getNeedsFullUpdate();
}

25 changes: 0 additions & 25 deletions src/main/java/rogo/renderingculling/mixin/MixinGameRenderer.java

This file was deleted.

36 changes: 5 additions & 31 deletions src/main/java/rogo/renderingculling/mixin/MixinLevelRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.ViewArea;
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix4f;
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.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -28,14 +24,9 @@
@Mixin(LevelRenderer.class)
public abstract class MixinLevelRender implements IEntitiesForRender {

@Mutable
@Final
@Shadow
private ObjectArrayList<LevelRenderer.RenderChunkInfo> renderChunksInFrustum;

@Shadow
@Nullable
protected abstract ChunkRenderDispatcher.RenderChunk getRelativeFrom(BlockPos p_109729_, ChunkRenderDispatcher.RenderChunk p_109730_, Direction p_109731_);
private ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections;

@Shadow
@Nullable
Expand All @@ -44,7 +35,7 @@ public abstract class MixinLevelRender implements IEntitiesForRender {
@Inject(method = "setupRender", at = @At(value = "HEAD"))
public void onSetupRenderHead(Camera p_194339_, Frustum p_194340_, boolean p_194341_, boolean p_194342_, CallbackInfo ci) {
if (this.viewArea != null) {
VanillaAsyncUtil.update((LevelRenderer) (Object) this, this.viewArea.chunks.length);
VanillaAsyncUtil.update((LevelRenderer) (Object) this, this.viewArea.sections.length);
}
}

Expand All @@ -65,25 +56,8 @@ public void onPrepareCullFrustum(PoseStack p_172962_, Vec3 p_172963_, Matrix4f p
}

@Override
public ObjectArrayList<?> renderChunksInFrustum() {
return renderChunksInFrustum;
}

@Override
public ChunkRenderDispatcher.RenderChunk invokeGetRelativeFrom(BlockPos pos, ChunkRenderDispatcher.RenderChunk chunk, Direction dir) {
return this.getRelativeFrom(pos, chunk, dir);
}

@Override
public ChunkRenderDispatcher.RenderChunk invokeGetRenderChunkAt(BlockPos pos) {
return ((AccessorViewArea) this.viewArea).invokeGetRenderChunkAt(pos);
}

@Mixin(ViewArea.class)
public interface AccessorViewArea {

@Invoker("getRenderChunkAt")
ChunkRenderDispatcher.RenderChunk invokeGetRenderChunkAt(BlockPos pos);
public ObjectArrayList<SectionRenderDispatcher.RenderSection> renderChunksInFrustum() {
return visibleSections;
}
}

Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package rogo.renderingculling.mixin;

import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
import net.minecraft.core.BlockPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import rogo.renderingculling.api.impl.IRenderSectionVisibility;

@Mixin(ChunkRenderDispatcher.RenderChunk.class)
@Mixin(SectionRenderDispatcher.RenderSection.class)
public abstract class MixinRenderChunk implements IRenderSectionVisibility {

@Shadow
@Final
private BlockPos.MutableBlockPos origin;
BlockPos.MutableBlockPos origin;

@Unique
private int cullingLastVisibleFrame;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private VisibleChunkCollector onCreateTerrainRenderList(VisibleChunkCollector va
return value;
}

@Inject(method = "updateChunks", at = @At(value = "HEAD"), remap = false)
private void onCreateTerrainRenderList(boolean updateImmediately, CallbackInfo ci) {
@Inject(method = "tickVisibleRenders", at = @At(value = "HEAD"), remap = false)
private void onCreateTerrainRenderList(CallbackInfo ci) {
if (Config.getAsyncChunkRebuild()) {
VisibleChunkCollector collector = CullingStateManager.renderingIris() ? SodiumSectionAsyncUtil.getShadowCollector() : SodiumSectionAsyncUtil.getChunkCollector();
if(collector != null)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/rogo/renderingculling/util/IrisLoaderImpl.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package rogo.renderingculling.util;

import net.coderbot.iris.Iris;
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
import net.coderbot.iris.pipeline.SodiumTerrainPipeline;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.pipeline.newshader.NewWorldRenderingPipeline;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.api.v0.IrisApi;
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
import net.irisshaders.iris.pipeline.SodiumTerrainPipeline;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.Minecraft;

import java.lang.reflect.Field;
Expand All @@ -18,8 +18,8 @@ public int getFrameBufferID() {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipeline().get();
try {
Field f = null;
if (pipeline instanceof NewWorldRenderingPipeline) {
f = NewWorldRenderingPipeline.class.getDeclaredField("sodiumTerrainPipeline");
if (pipeline instanceof IrisRenderingPipeline) {
f = IrisRenderingPipeline.class.getDeclaredField("sodiumTerrainPipeline");
}
if (f != null) {
f.setAccessible(true);
Expand Down
Loading

0 comments on commit a080f1f

Please sign in to comment.