[vintage] Increase blend radius to 14 and fix compile of 1.12.2 #24
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package org.taumc.celeritas.impl.debug;
|
||||
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
||||
import org.embeddedt.embeddium.impl.common.util.NativeBuffer;
|
||||
import org.taumc.celeritas.impl.Celeritas;
|
||||
import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CeleritasDebugStrings {
|
||||
public static List<Pair<String, Integer>> getStringsToRender() {
|
||||
List<Pair<String, Integer>> stringsToRender = new ArrayList<>();
|
||||
|
||||
stringsToRender.add(Pair.of(getNativeMemoryString(), -1));
|
||||
stringsToRender.add(Pair.of("", -1));
|
||||
|
||||
stringsToRender.add(Pair.of("%s Renderer (%s)".formatted("Celeritas", Celeritas.VERSION), 0xFF55FF55));
|
||||
stringsToRender.add(Pair.of("", -1));
|
||||
|
||||
var renderer = CeleritasWorldRenderer.instanceNullable();
|
||||
|
||||
if (renderer != null) {
|
||||
renderer.getDebugStrings().forEach(str -> stringsToRender.add(Pair.of(str, -1)));
|
||||
}
|
||||
|
||||
return stringsToRender;
|
||||
}
|
||||
|
||||
private static String getNativeMemoryString() {
|
||||
return "Off-Heap: +" + MathUtil.toMib(getNativeMemoryUsage()) + "MB";
|
||||
}
|
||||
|
||||
private static long getNativeMemoryUsage() {
|
||||
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() + NativeBuffer.getTotalAllocated();
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -19,7 +19,7 @@ import java.util.*;
|
||||
/**
|
||||
* Provides an extension to vanilla's world renderer.
|
||||
*/
|
||||
public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, PrimitiveRenderSectionManager, Integer, BlockEntity, Float> {
|
||||
public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, PrimitiveRenderSectionManager, Object, BlockEntity, Float> {
|
||||
@Getter
|
||||
private SpriteTransparencyTracker transparencyTracker;
|
||||
|
||||
@@ -57,7 +57,12 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, Primitive
|
||||
|
||||
@Override
|
||||
protected CameraState captureCameraState(float ticks) {
|
||||
Entity viewEntity = Objects.requireNonNull(MinecraftAccessor.celeritas$getInstance().camera, "Client must have view entity");
|
||||
//? if <1.8 {
|
||||
Entity viewEntity = MinecraftAccessor.celeritas$getInstance().camera;
|
||||
//?} else
|
||||
/*Entity viewEntity = MinecraftAccessor.celeritas$getInstance().getCamera();*/
|
||||
|
||||
Objects.requireNonNull(viewEntity, "Client must have view entity");
|
||||
|
||||
double x = viewEntity.prevTickX + (viewEntity.x - viewEntity.prevTickX) * ticks;
|
||||
double y = viewEntity.prevTickY + (viewEntity.y - viewEntity.prevTickY) * ticks + (double) viewEntity.getEyeHeight();
|
||||
@@ -98,7 +103,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, Primitive
|
||||
float partialTicks = partialTicksBoxed;
|
||||
for (var blockEntity : list) {
|
||||
try {
|
||||
BlockEntityRenderDispatcher.INSTANCE.render(blockEntity, partialTicks);
|
||||
BlockEntityRenderDispatcher.INSTANCE.render(blockEntity, partialTicks /*? if >=1.8 {*//*, -1 *//*?}*/);
|
||||
} catch(RuntimeException e) {
|
||||
if(blockEntity.isRemoved()) {
|
||||
System.err.println("Suppressing crash from invalid tile entity");
|
||||
|
||||
+17
-2
@@ -3,6 +3,8 @@ package org.taumc.celeritas.impl.render.terrain;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
//? if >=1.8
|
||||
/*import net.minecraft.client.render.block.BlockLayer;*/
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
@@ -18,7 +20,7 @@ import java.util.Map;
|
||||
|
||||
public class PrimitiveRenderPassConfigurationBuilder {
|
||||
public static final TerrainRenderPass SOLID_PASS, CUTOUT_MIPPED_PASS, TRANSLUCENT_PASS;
|
||||
public static final Material SOLID_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL;
|
||||
public static final Material SOLID_MATERIAL, CUTOUT_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL;
|
||||
|
||||
private record PrimitivePipelineState(int pass, boolean disableBlend) implements TerrainRenderPass.PipelineState {
|
||||
@Override
|
||||
@@ -77,9 +79,11 @@ public class PrimitiveRenderPassConfigurationBuilder {
|
||||
TRANSLUCENT_MATERIAL = new Material(TRANSLUCENT_PASS, AlphaCutoffParameter.ZERO, true);
|
||||
SOLID_MATERIAL = new Material(SOLID_PASS, AlphaCutoffParameter.ZERO, true);
|
||||
CUTOUT_MIPPED_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, true);
|
||||
CUTOUT_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, false);
|
||||
}
|
||||
|
||||
public static RenderPassConfiguration<Integer> build(ChunkVertexType vertexType) {
|
||||
public static RenderPassConfiguration<?> build(ChunkVertexType vertexType) {
|
||||
//? if <1.8 {
|
||||
Int2ObjectMap<Collection<TerrainRenderPass>> vanillaRenderStages = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
vanillaRenderStages.put(1, List.of(TRANSLUCENT_PASS));
|
||||
@@ -91,6 +95,17 @@ public class PrimitiveRenderPassConfigurationBuilder {
|
||||
|
||||
renderTypeToMaterialMap.put(0, CUTOUT_MIPPED_MATERIAL);
|
||||
renderTypeToMaterialMap.put(1, TRANSLUCENT_MATERIAL);
|
||||
//?} else {
|
||||
/*Map<BlockLayer, Collection<TerrainRenderPass>> vanillaRenderStages = new Reference2ReferenceOpenHashMap<>();
|
||||
vanillaRenderStages.put(BlockLayer.SOLID, List.of(SOLID_PASS, CUTOUT_MIPPED_PASS));
|
||||
vanillaRenderStages.put(BlockLayer.TRANSLUCENT, List.of(TRANSLUCENT_PASS));
|
||||
|
||||
Map<BlockLayer, Material> renderTypeToMaterialMap = new Reference2ReferenceOpenHashMap<>();
|
||||
renderTypeToMaterialMap.put(BlockLayer.SOLID, SOLID_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockLayer.CUTOUT, CUTOUT_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockLayer.CUTOUT_MIPPED, CUTOUT_MIPPED_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockLayer.TRANSLUCENT, TRANSLUCENT_MATERIAL);
|
||||
*///?}
|
||||
|
||||
return new RenderPassConfiguration<>(renderTypeToMaterialMap,
|
||||
vanillaRenderStages,
|
||||
|
||||
+9
-1
@@ -6,6 +6,7 @@ import org.embeddedt.embeddium.impl.gl.device.CommandList;
|
||||
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.*;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.executor.ChunkBuilder;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderTask;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
|
||||
@@ -28,7 +29,11 @@ public class PrimitiveRenderSectionManager extends RenderSectionManager {
|
||||
|
||||
public static PrimitiveRenderSectionManager create(ChunkVertexType vertexType, World world, int renderDistance, CommandList commandList) {
|
||||
// TODO support thread option
|
||||
return new PrimitiveRenderSectionManager(PrimitiveRenderPassConfigurationBuilder.build(vertexType), world, renderDistance, commandList, 0, 8, -1);
|
||||
//? if <1.8 {
|
||||
int idealThreadCount = -1;
|
||||
//?} else
|
||||
/*int idealThreadCount = 0;*/
|
||||
return new PrimitiveRenderSectionManager(PrimitiveRenderPassConfigurationBuilder.build(vertexType), world, renderDistance, commandList, 0, 8, idealThreadCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +56,10 @@ public class PrimitiveRenderSectionManager extends RenderSectionManager {
|
||||
final boolean useOcclusionCulling;
|
||||
var camBlockPos = positionedViewport.getBlockCoord();
|
||||
|
||||
//? if <1.8 {
|
||||
var block = this.world.getBlock(camBlockPos.x(), camBlockPos.y(), camBlockPos.z());
|
||||
//?} else
|
||||
/*var block = this.world.getBlockState(new net.minecraft.util.math.BlockPos(camBlockPos.x(), camBlockPos.y(), camBlockPos.z())).getBlock();*/
|
||||
|
||||
//? if >=1.7 {
|
||||
/*boolean opaque = block.isOpaqueCube();
|
||||
|
||||
+26
-10
@@ -1,5 +1,6 @@
|
||||
package org.taumc.celeritas.impl.render.terrain.compile;
|
||||
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import net.minecraft.world.World;
|
||||
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
@@ -14,16 +15,24 @@ import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
||||
import org.taumc.celeritas.impl.render.terrain.PrimitiveRenderPassConfigurationBuilder;
|
||||
import org.taumc.celeritas.impl.render.terrain.SpriteTransparencyTracker;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
||||
public static final int NUM_PASSES = 2;
|
||||
|
||||
public final World world;
|
||||
private final SpriteTransparencyTracker transparencyTracker;
|
||||
|
||||
public final BufferBuilder tesselator;
|
||||
|
||||
public PrimitiveChunkBuildContext(World world, RenderPassConfiguration renderPassConfiguration) {
|
||||
super(renderPassConfiguration);
|
||||
this.world = world;
|
||||
this.transparencyTracker = CeleritasWorldRenderer.instance().getTransparencyTracker();
|
||||
//? if >=1.8 {
|
||||
/*this.tesselator = new BufferBuilder(8192);
|
||||
*///?} else
|
||||
this.tesselator = BufferBuilder.INSTANCE;
|
||||
}
|
||||
|
||||
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
|
||||
@@ -42,7 +51,7 @@ public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
||||
private static final int[] NORMAL_WINDING = new int[] {0, 1, 2, 3};
|
||||
private static final int[] BACKFACE_WINDING = new int[] {3, 2, 1, 0};
|
||||
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material) {
|
||||
public void copyRawBuffer(IntBuffer rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -65,25 +74,32 @@ public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
||||
//?}
|
||||
}
|
||||
|
||||
private void outputQuads(int[] rawBuffer, ChunkVertexEncoder.Vertex[] celeritasVertices, int numQuads, ChunkBuildBuffers buffers, Material material, int[] winding) {
|
||||
private void outputQuads(IntBuffer rawBuffer, ChunkVertexEncoder.Vertex[] celeritasVertices, int numQuads, ChunkBuildBuffers buffers, Material material, int[] winding) {
|
||||
int ptr = 0;
|
||||
var tracker = this.transparencyTracker;
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
var vertex = celeritasVertices[winding[vIdx]];
|
||||
vertex.x = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
vertex.y = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
vertex.z = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
float u = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
float v = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
vertex.x = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||
vertex.y = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||
vertex.z = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||
|
||||
// In 1.8+, color comes before all UVs. In 1.7-, texture UV comes before color.
|
||||
//? if >=1.8
|
||||
/*vertex.color = rawBuffer.get(ptr++);*/
|
||||
|
||||
float u = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||
float v = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||
vertex.u = u;
|
||||
uSum += u;
|
||||
vertex.v = v;
|
||||
vSum += v;
|
||||
vertex.color = rawBuffer[ptr++];
|
||||
vertex.vanillaNormal = rawBuffer[ptr++];
|
||||
vertex.light = rawBuffer[ptr++];
|
||||
//? if <1.8 {
|
||||
vertex.color = rawBuffer.get(ptr++);
|
||||
vertex.vanillaNormal = rawBuffer.get(ptr++);
|
||||
//?}
|
||||
vertex.light = rawBuffer.get(ptr++);
|
||||
}
|
||||
int trueNormal = QuadUtil.calculateNormal(celeritasVertices);
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
|
||||
+43
-12
@@ -1,10 +1,8 @@
|
||||
package org.taumc.celeritas.impl.render.terrain.compile.task;
|
||||
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.render.BlockRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.world.WorldRegion;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
@@ -21,6 +19,7 @@ import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.embeddedt.embeddium.impl.util.task.CancellationToken;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.opengl.GL11C;
|
||||
import org.taumc.celeritas.impl.extensions.TessellatorExtension;
|
||||
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveBuiltRenderSectionData;
|
||||
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveChunkBuildContext;
|
||||
@@ -29,6 +28,8 @@ import org.taumc.celeritas.impl.render.util.Direction;
|
||||
import org.taumc.celeritas.impl.world.cloned.ChunkRenderContext;
|
||||
import org.taumc.celeritas.mixin.core.TessellatorAccessor;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput> {
|
||||
private final RenderSection render;
|
||||
private final int buildTime;
|
||||
@@ -60,19 +61,27 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
||||
int maxZ = minZ + 16;
|
||||
|
||||
// Initialise with minX/minY/minZ so initial getBlockState crash context is correct
|
||||
Vector3i blockPos = new Vector3i(minX, minY, minZ);
|
||||
|
||||
var world = buildContext.world;
|
||||
var chunk = world.getChunkAt(this.render.getChunkX(), this.render.getChunkZ());
|
||||
var region = new WorldRegion(world, minX - 1, minY - 1, minZ - 1, maxX + 1, maxY + 1, maxZ + 1 /*? if >=1.7.10 {*//*, 1*//*?}*/);
|
||||
var renderBlocks = new BlockRenderer(region);
|
||||
var tesselator = BufferBuilder.INSTANCE;
|
||||
var extTesselator = (TessellatorExtension)tesselator;
|
||||
var tesselator = buildContext.tesselator;
|
||||
|
||||
//? if <1.8 {
|
||||
Vector3i blockPos = new Vector3i(minX, minY, minZ);
|
||||
var region = new WorldRegion(world, minX - 1, minY - 1, minZ - 1, maxX + 1, maxY + 1, maxZ + 1 /*? if >=1.7.10 {*//*, 1*//*?}*/);
|
||||
var renderBlocks = new net.minecraft.client.render.BlockRenderer(region);
|
||||
var extTesselator = (TessellatorExtension)tesselator;
|
||||
//? if <1.7
|
||||
TessellatorAccessor.celeritas$setTriangleMode(false);
|
||||
tesselator.offset(-this.render.getOriginX(), -this.render.getOriginY(), -this.render.getOriginZ());
|
||||
WorldChunk.hasSkyLight = false;
|
||||
//?} else {
|
||||
/*var blockPos = new net.minecraft.util.math.BlockPos.Mutable(minX, minY, minZ);
|
||||
var region = new WorldRegion(world, new net.minecraft.util.math.BlockPos(minX, minY, minZ), new net.minecraft.util.math.BlockPos(maxX, maxY, maxZ), 1);
|
||||
var renderBlocks = Minecraft.getInstance().getBlockRenderDispatcher();
|
||||
*///?}
|
||||
|
||||
tesselator.offset(-this.render.getOriginX(), -this.render.getOriginY(), -this.render.getOriginZ());
|
||||
|
||||
|
||||
// Beta is insane and updates the matrix inside the tessellation logic
|
||||
try {
|
||||
@@ -93,9 +102,16 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
||||
}
|
||||
|
||||
Block block = Block.BY_ID[blockId];
|
||||
//?} else {
|
||||
//?} else if <1.8 {
|
||||
/*Block block = chunk.getBlockAt(x & 15, y, z & 15);
|
||||
|
||||
if (block == net.minecraft.block.Blocks.AIR) {
|
||||
continue;
|
||||
}
|
||||
*///?} else {
|
||||
/*var blockState = chunk.getBlockState(blockPos);
|
||||
var block = blockState.getBlock();
|
||||
|
||||
if (block == net.minecraft.block.Blocks.AIR) {
|
||||
continue;
|
||||
}
|
||||
@@ -107,18 +123,29 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
||||
boolean hasBlockEntity = block.hasBlockEntity();
|
||||
|
||||
if (hasBlockEntity) {
|
||||
//? if <1.8 {
|
||||
BlockEntity tileEntity = chunk.getBlockEntityAt(x & 15, y, z & 15);
|
||||
if (BlockEntityRenderDispatcher.INSTANCE.hasRenderer(tileEntity)) {
|
||||
//?} else
|
||||
/*BlockEntity tileEntity = chunk.getBlockEntity(blockPos, WorldChunk.BlockEntityCreationType.CHECK);*/
|
||||
if (BlockEntityRenderDispatcher.INSTANCE.getRenderer(tileEntity) != null) {
|
||||
renderData.globalBlockEntities.add(tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
int pass = block.getRenderLayer();
|
||||
var pass = block.getRenderLayer();
|
||||
|
||||
//? if <1.8 {
|
||||
tesselator.start();
|
||||
renderBlocks.tessellateBlock(block, x, y, z);
|
||||
buildContext.copyRawBuffer(extTesselator.celeritas$getRawBuffer(), extTesselator.celeritas$getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
||||
buildContext.copyRawBuffer(IntBuffer.wrap(extTesselator.celeritas$getRawBuffer()), extTesselator.celeritas$getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
||||
extTesselator.celeritas$reset();
|
||||
//?} else {
|
||||
/*tesselator.begin(GL11C.GL_QUADS, com.mojang.blaze3d.vertex.DefaultVertexFormat.BLOCK);
|
||||
renderBlocks.tessellate(blockState, blockPos, region, tesselator);
|
||||
tesselator.end();
|
||||
buildContext.copyRawBuffer(tesselator.getBuffer().asIntBuffer(), tesselator.getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
||||
tesselator.clear();
|
||||
*///?}
|
||||
|
||||
//? if <1.7 {
|
||||
boolean opaque = Block.IS_OPAQUE[blockId];
|
||||
@@ -126,6 +153,9 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
||||
/*boolean opaque = block.isOpaqueCube();*/
|
||||
|
||||
if (opaque) {
|
||||
//? if >=1.8 {
|
||||
/*occluder.markClosed(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
*///?} else
|
||||
occluder.markClosed(blockPos);
|
||||
}
|
||||
}
|
||||
@@ -144,6 +174,7 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
||||
renderData.hasBlockGeometry = true;
|
||||
}
|
||||
|
||||
//? if <1.8
|
||||
renderData.hasSkyLight = WorldChunk.hasSkyLight;
|
||||
|
||||
encodeVisibilityData(occluder, renderData);
|
||||
|
||||
+5
@@ -43,6 +43,11 @@ public class ChunkOcclusionDataBuilder {
|
||||
--this.openCount;
|
||||
}
|
||||
|
||||
public void markClosed(int x, int y, int z) {
|
||||
this.closed.set(pack(x, y, z), true);
|
||||
--this.openCount;
|
||||
}
|
||||
|
||||
private static int pack(Vector3i pos) {
|
||||
return pack(pos.x() & 15, pos.y() & 15, pos.z() & 15);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.taumc.celeritas.mixin.core;
|
||||
|
||||
//? if <1.8 {
|
||||
import net.minecraft.client.render.BlockRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -12,3 +13,4 @@ public class BlockRendererMixin {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//?}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.taumc.celeritas.mixin.core;
|
||||
|
||||
//? if >=1.8 {
|
||||
/*import net.minecraft.client.gui.overlay.DebugOverlay;
|
||||
import net.minecraft.text.Formatting;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.taumc.celeritas.impl.debug.CeleritasDebugStrings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugOverlay.class)
|
||||
public class DebugOverlayMixin {
|
||||
@Inject(method = "getSystemInfo", at = @At("RETURN"))
|
||||
private void appendCeleritasSystemInfo(CallbackInfoReturnable<List<String>> cir) {
|
||||
var strings = cir.getReturnValue();
|
||||
strings.add("");
|
||||
strings.addAll(CeleritasDebugStrings.getStringsToRender().stream().map(pair -> {
|
||||
// TODO
|
||||
if (pair.right() == 0xFF55FF55) {
|
||||
return Formatting.GREEN + pair.left();
|
||||
} else {
|
||||
return pair.left();
|
||||
}
|
||||
}).toList());
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
@@ -33,6 +33,7 @@ public class GameRendererMixin {
|
||||
GLStateManagerFogService.fogColorBlue = this.fogBlue;
|
||||
}
|
||||
|
||||
//? if <1.8 {
|
||||
private boolean lastVsyncStatus;
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
@@ -48,4 +49,5 @@ public class GameRendererMixin {
|
||||
private boolean celeritas$forceNormalTranslucentTerrainRendering(GameOptions instance) {
|
||||
return false;
|
||||
}
|
||||
//?}
|
||||
}
|
||||
@@ -1,22 +1,18 @@
|
||||
package org.taumc.celeritas.mixin.core;
|
||||
|
||||
//? if <1.8 {
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.minecraft.client.gui.GameGui;
|
||||
import net.minecraft.client.render.TextRenderer;
|
||||
import net.minecraft.client.render.Window;
|
||||
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
||||
import org.embeddedt.embeddium.impl.common.util.NativeBuffer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.taumc.celeritas.impl.Celeritas;
|
||||
import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
||||
import org.taumc.celeritas.impl.debug.CeleritasDebugStrings;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GameGui.class)
|
||||
@@ -25,26 +21,14 @@ public class InGameHudMixin {
|
||||
@Inject(method = "render", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/options/GameOptions;debug"
|
||||
//? if <1.4
|
||||
+ "Profiler"
|
||||
+ "Enabled:Z")), at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glPopMatrix()V", ordinal = 0))
|
||||
private void celeritas$renderDebug(float screenOpen, boolean mouseX, int mouseY, int par4, CallbackInfo ci, @Local(ordinal = 0) Window scaler, @Local(ordinal = 0) TextRenderer font) {
|
||||
+ "Enabled:Z")), at = @At(value = "INVOKE", target ="Lorg/lwjgl/opengl/GL11;glPopMatrix()V", ordinal = 0))
|
||||
private void celeritas$renderDebug(CallbackInfo ci, @Local(ordinal = 0) Window scaler, @Local(ordinal = 0) TextRenderer font) {
|
||||
int currentY = 22;
|
||||
int yDiff = 10;
|
||||
|
||||
int screenWidth = scaler.getWidth();
|
||||
|
||||
List<Pair<String, Integer>> stringsToRender = new ArrayList<>();
|
||||
|
||||
stringsToRender.add(Pair.of(getNativeMemoryString(), -1));
|
||||
stringsToRender.add(Pair.of("", -1));
|
||||
|
||||
stringsToRender.add(Pair.of("%s Renderer (%s)".formatted("Celeritas", Celeritas.VERSION), 0xFF55FF55));
|
||||
stringsToRender.add(Pair.of("", -1));
|
||||
|
||||
var renderer = CeleritasWorldRenderer.instanceNullable();
|
||||
|
||||
if (renderer != null) {
|
||||
renderer.getDebugStrings().forEach(str -> stringsToRender.add(Pair.of(str, -1)));
|
||||
}
|
||||
List<Pair<String, Integer>> stringsToRender = CeleritasDebugStrings.getStringsToRender();
|
||||
|
||||
for (var render : stringsToRender) {
|
||||
if (!render.left().isBlank()) {
|
||||
@@ -55,12 +39,5 @@ public class InGameHudMixin {
|
||||
currentY += yDiff;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getNativeMemoryString() {
|
||||
return "Off-Heap: +" + MathUtil.toMib(getNativeMemoryUsage()) + "MB";
|
||||
}
|
||||
|
||||
private static long getNativeMemoryUsage() {
|
||||
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() + NativeBuffer.getTotalAllocated();
|
||||
}
|
||||
}
|
||||
//?}
|
||||
@@ -13,11 +13,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
private static final String INIT_DISPLAY_METHOD =
|
||||
//? if <1.8 {
|
||||
"init"
|
||||
//?} else
|
||||
/*"initDisplay"*/
|
||||
;
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason apparently b7.3 uses the default depth buffer precision (8-bit), which looks very bad
|
||||
*/
|
||||
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"))
|
||||
@Redirect(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"))
|
||||
private void createWithHighPrecisionDepthBuffer() throws LWJGLException {
|
||||
Display.create(new PixelFormat().withDepthBits(24));
|
||||
}
|
||||
@@ -26,12 +33,12 @@ public class MinecraftMixin {
|
||||
* @author embeddedt
|
||||
* @reason by default b7.3 does not mark the window as resizeable
|
||||
*/
|
||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
|
||||
@Inject(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
|
||||
private void makeResizeable(CallbackInfo ci) {
|
||||
Display.setResizable(true);
|
||||
}
|
||||
|
||||
@ModifyArg(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"), index = 0)
|
||||
@ModifyArg(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"), index = 0)
|
||||
private String removeDuplicateMinecraftInTitle(String newTitle) {
|
||||
if (newTitle.startsWith("Minecraft Minecraft")) {
|
||||
return newTitle.replaceFirst("^Minecraft ", "");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.taumc.celeritas.mixin.core;
|
||||
|
||||
//? if <1.8 {
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -35,4 +36,4 @@ public abstract class TessellatorMixin implements TessellatorExtension {
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//?}
|
||||
@@ -4,7 +4,10 @@ import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.render.Culler;
|
||||
//? if >=1.8
|
||||
/*import net.minecraft.client.render.block.BlockLayer;*/
|
||||
import net.minecraft.client.render.world.WorldRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.living.LivingEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
||||
@@ -26,8 +29,18 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
@Shadow
|
||||
private Minecraft minecraft;
|
||||
|
||||
//? if <1.8 {
|
||||
@Shadow
|
||||
private int chunkGridSizeX, chunkGridSizeY, chunkGridSizeZ;
|
||||
//?}
|
||||
|
||||
//? if >=1.8 {
|
||||
/*@Shadow
|
||||
private int viewDistance;
|
||||
|
||||
@Shadow
|
||||
public abstract void reload();
|
||||
*///?}
|
||||
|
||||
private CeleritasWorldRenderer renderer;
|
||||
|
||||
@@ -52,19 +65,25 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//? if <1.8 {
|
||||
@Inject(method = { "reload", "m_6748042" }, at = @At(opcode = Opcodes.PUTFIELD, value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;chunkGridSizeZ:I", shift = At.Shift.AFTER))
|
||||
private void nullifyBuiltChunkStorage(CallbackInfo ci) {
|
||||
this.chunkGridSizeX = 0;
|
||||
this.chunkGridSizeY = 0;
|
||||
this.chunkGridSizeZ = 0;
|
||||
}
|
||||
//?}
|
||||
|
||||
/**
|
||||
* @reason Redirect the chunk layer render passes to our renderer
|
||||
* @author JellySquid
|
||||
*/
|
||||
@Overwrite
|
||||
public int render(LivingEntity viewEntity, int pass, double ticks) {
|
||||
//? if <1.8 {
|
||||
public int render(LivingEntity viewEntity, int layer, double ticks) {
|
||||
//?} else
|
||||
/*public int render(BlockLayer layer, double ticks, int anaglyphRenderPass, Entity viewEntity) {*/
|
||||
// Allow FalseTweaks mixin to replace constant
|
||||
@SuppressWarnings("unused")
|
||||
double magicSortingConstantValue = 1.0D;
|
||||
@@ -78,16 +97,16 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
double d5 = viewEntity.prevTickZ + (viewEntity.z - viewEntity.prevTickZ) * ticks;
|
||||
|
||||
//? if >=1.0.0-beta.8
|
||||
this.minecraft.gameRenderer.enableLightMap(ticks);
|
||||
this.minecraft.gameRenderer.enableLightMap(/*? if <1.8 {*/ticks/*?}*/);
|
||||
|
||||
try {
|
||||
this.renderer.drawChunkLayer(pass, d3, d4, d5);
|
||||
this.renderer.drawChunkLayer(layer, d3, d4, d5);
|
||||
} finally {
|
||||
RenderDevice.exitManagedCode();
|
||||
}
|
||||
|
||||
//? if >=1.0.0-beta.8
|
||||
this.minecraft.gameRenderer.disableLightMap(ticks);
|
||||
this.minecraft.gameRenderer.disableLightMap(/*? if <1.8 {*/ticks/*?}*/);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -100,6 +119,15 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
* @author JellySquid
|
||||
*/
|
||||
@Overwrite
|
||||
//? if >=1.8 {
|
||||
/*public void setupRender(Entity camera, double tickDelta, Culler culler, int frame, boolean loadChunks) {
|
||||
if (this.minecraft.options.viewDistance != this.viewDistance) {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
updateFrustums(culler, (float)tickDelta);
|
||||
}
|
||||
*///?}
|
||||
public void updateFrustums(Culler camera, float tick) {
|
||||
RenderDevice.enterManagedCode();
|
||||
|
||||
@@ -122,7 +150,7 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
//? if <1.3 {
|
||||
private static final String ON_RELOAD = "m_6748042";
|
||||
//?} else
|
||||
/*private static final String ON_RELOAD = "reload";*/
|
||||
/*private static final String ON_RELOAD = "reload()V";*/
|
||||
|
||||
@Inject(method = ON_RELOAD, at = @At("RETURN"))
|
||||
private void onReload(CallbackInfo ci) {
|
||||
@@ -136,11 +164,22 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
//? if <1.8 {
|
||||
public boolean compileChunks(LivingEntity camera, boolean force) {
|
||||
return true;
|
||||
}
|
||||
//?} else {
|
||||
/*public void compileChunksUntil(long time) {
|
||||
|
||||
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;globalBlockEntities:Ljava/util/List;", ordinal = 0))
|
||||
}
|
||||
*///?}
|
||||
|
||||
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;globalBlockEntities:"
|
||||
//? if >=1.8 {
|
||||
/*+ "Ljava/util/Set;"
|
||||
*///?} else
|
||||
+ "Ljava/util/List;"
|
||||
, ordinal = 0))
|
||||
public void sodium$renderTileEntities(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) float partialTicks) {
|
||||
this.renderer.renderBlockEntities(partialTicks);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The render state object for a chunk section. This contains all the graphics state for each render pass along with
|
||||
@@ -33,7 +34,6 @@ public class RenderSection extends AbstractSection {
|
||||
}
|
||||
|
||||
// Rendering State
|
||||
private boolean built = false; // merge with the flags?
|
||||
private BuiltRenderSectionData contextData;
|
||||
private boolean hasAnythingToRender;
|
||||
@Getter
|
||||
@@ -91,28 +91,17 @@ public class RenderSection extends AbstractSection {
|
||||
this.buildCancellationToken = null;
|
||||
}
|
||||
|
||||
this.clearRenderState();
|
||||
this.setInfo(null);
|
||||
this.disposed = true;
|
||||
}
|
||||
|
||||
public void setInfo(@Nullable BuiltRenderSectionData info) {
|
||||
if (info != null) {
|
||||
this.setRenderState(info);
|
||||
} else {
|
||||
this.clearRenderState();
|
||||
public boolean setInfo(@Nullable BuiltRenderSectionData info) {
|
||||
boolean changed = !Objects.equals(info, this.contextData);
|
||||
if (changed) {
|
||||
this.contextData = info;
|
||||
this.updateCachedContextDataFlags();
|
||||
}
|
||||
}
|
||||
|
||||
private void setRenderState(@NotNull BuiltRenderSectionData info) {
|
||||
this.built = true;
|
||||
this.contextData = info;
|
||||
this.updateCachedContextDataFlags();
|
||||
}
|
||||
|
||||
private void clearRenderState() {
|
||||
this.built = false;
|
||||
this.contextData = null;
|
||||
this.updateCachedContextDataFlags();
|
||||
return changed;
|
||||
}
|
||||
|
||||
public boolean isDisposed() {
|
||||
@@ -120,7 +109,7 @@ public class RenderSection extends AbstractSection {
|
||||
}
|
||||
|
||||
public boolean isBuilt() {
|
||||
return this.built;
|
||||
return this.contextData != null;
|
||||
}
|
||||
|
||||
public RenderRegion getRegion() {
|
||||
|
||||
+60
-22
@@ -83,6 +83,8 @@ public abstract class RenderSectionManager {
|
||||
|
||||
private final Object2ObjectOpenHashMap<TerrainRenderPass, TimerQueryManager> renderPassDrawTimers = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
protected final ReferenceSet<RenderSection> sectionsRequestingUpdate = new ReferenceOpenHashSet<>();
|
||||
|
||||
@Deprecated
|
||||
public RenderSectionManager(RenderPassConfiguration<?> configuration, Supplier<ChunkBuildContext> contextSupplier,
|
||||
BiFunction<RenderDevice, RenderPassConfiguration<?>, ChunkRenderer> chunkRenderer,
|
||||
@@ -368,9 +370,27 @@ public abstract class RenderSectionManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject sections that requested a rebuild between graph updates into the appropriate rebuild lists.
|
||||
*/
|
||||
private void promoteInterimRebuildList() {
|
||||
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists().byUpdateType();
|
||||
for (var section : this.sectionsRequestingUpdate) {
|
||||
rebuildLists.get(section.getPendingUpdate()).add(section);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateChunks(boolean updateImmediately) {
|
||||
this.regions.update();
|
||||
|
||||
// Promotion of the interim rebuild list is not required if a graph update is requested, as the graph
|
||||
// generates a new rebuild list anyway
|
||||
if (!this.renderListManager.isNeedsUpdate() && !sectionsRequestingUpdate.isEmpty()) {
|
||||
this.promoteInterimRebuildList();
|
||||
}
|
||||
|
||||
this.sectionsRequestingUpdate.clear();
|
||||
|
||||
if (!rebuildListHasUpdates()) {
|
||||
return;
|
||||
}
|
||||
@@ -408,6 +428,12 @@ public abstract class RenderSectionManager {
|
||||
for (var result : results) {
|
||||
result.delete();
|
||||
}
|
||||
|
||||
// Forcefully mark the graph as needing updates if the previous render list detected an overflow of the
|
||||
// update queue. This is necessary to queue those additional chunks.
|
||||
if (this.getCurrentRenderListManager().getRebuildLists().hasAdditionalUpdates()) {
|
||||
this.markGraphDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public final void tickVisibleRenders() {
|
||||
@@ -421,11 +447,15 @@ public abstract class RenderSectionManager {
|
||||
|
||||
for (var result : filtered) {
|
||||
if(result.info != null) {
|
||||
// The chunk graph must be rebuilt whenever a section is remeshed, in order to consider changes in
|
||||
// geometry, visibility data, etc.
|
||||
this.markGraphDirty();
|
||||
boolean changed = this.updateSectionInfo(result.render, result.info);
|
||||
|
||||
if (changed) {
|
||||
// The chunk graph must be rebuilt if the render section reports the info has changed. This
|
||||
// could indicate an occlusion data update, block entity addition/removal, animated texture
|
||||
// change, etc.
|
||||
this.markGraphDirty();
|
||||
}
|
||||
|
||||
this.updateSectionInfo(result.render, result.info);
|
||||
// We only change the translucency info on full rebuilds, as sorts can keep using the same data
|
||||
this.updateTranslucencyInfo(result.render, result.meshes);
|
||||
}
|
||||
@@ -451,19 +481,24 @@ public abstract class RenderSectionManager {
|
||||
}
|
||||
|
||||
@MustBeInvokedByOverriders
|
||||
protected void updateSectionInfo(RenderSection render, @Nullable BuiltRenderSectionData info) {
|
||||
render.setInfo(info);
|
||||
long visibilityData = info != null ? info.visibilityData : VisibilityEncoding.NULL;
|
||||
this.renderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
||||
if (this.shadowRenderListManager != null) {
|
||||
this.shadowRenderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
||||
protected boolean updateSectionInfo(RenderSection render, @Nullable BuiltRenderSectionData info) {
|
||||
boolean changed = render.setInfo(info);
|
||||
|
||||
if (changed) {
|
||||
long visibilityData = info != null ? info.visibilityData : VisibilityEncoding.NULL;
|
||||
this.renderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
||||
if (this.shadowRenderListManager != null) {
|
||||
this.shadowRenderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
||||
}
|
||||
|
||||
if (!(info instanceof MinecraftBuiltRenderSectionData<?, ?> data)) {
|
||||
this.sectionsWithGlobalEntities.remove(render);
|
||||
} else if (!data.globalBlockEntities.isEmpty()) {
|
||||
this.sectionsWithGlobalEntities.add(render);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(info instanceof MinecraftBuiltRenderSectionData<?, ?> data)) {
|
||||
this.sectionsWithGlobalEntities.remove(render);
|
||||
} else if (!data.globalBlockEntities.isEmpty()) {
|
||||
this.sectionsWithGlobalEntities.add(render);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static List<ChunkBuildOutput> filterChunkBuildResults(ArrayList<ChunkBuildOutput> outputs) {
|
||||
@@ -648,7 +683,11 @@ public abstract class RenderSectionManager {
|
||||
if (pendingUpdate != null) {
|
||||
section.setPendingUpdate(pendingUpdate);
|
||||
|
||||
this.markGraphDirty();
|
||||
if (!this.getCurrentRenderListManager().isNeedsUpdate() && this.sectionsRequestingUpdate.size() < this.builder.getSchedulingBudget()) {
|
||||
this.sectionsRequestingUpdate.add(section);
|
||||
} else {
|
||||
this.markGraphDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -770,14 +809,13 @@ public abstract class RenderSectionManager {
|
||||
list.add(String.format("G: %d/%d, I: %d/%d MiB (%d buffers)", MathUtil.toMib(deviceUsed), MathUtil.toMib(deviceAllocated), MathUtil.toMib(indexUsed), MathUtil.toMib(indexAllocated), count));
|
||||
list.add(String.format("Transfer Queue: %s", this.regions.getStagingBuffer().toString()));
|
||||
|
||||
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists().byUpdateType();
|
||||
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists();
|
||||
|
||||
list.add(String.format("Chunk Queues: U=%02d (P0=%03d | P1=%03d | P2=%03d)%s",
|
||||
list.add(String.format("Chunk Queues: U=%02d (P0=%03d | P1=%03d | P2=%03d)",
|
||||
this.buildResults.size(),
|
||||
rebuildLists.get(ChunkUpdateType.IMPORTANT_REBUILD).size(),
|
||||
rebuildLists.get(ChunkUpdateType.REBUILD).size(),
|
||||
rebuildLists.get(ChunkUpdateType.INITIAL_BUILD).size(),
|
||||
this.getCurrentRenderListManager().getRebuildLists().hasAdditionalUpdates() ? "(++)" : ""
|
||||
rebuildLists.getUpdateCount(ChunkUpdateType.IMPORTANT_REBUILD),
|
||||
rebuildLists.getUpdateCount(ChunkUpdateType.REBUILD),
|
||||
rebuildLists.getUpdateCount(ChunkUpdateType.INITIAL_BUILD)
|
||||
));
|
||||
|
||||
var debugStats = renderListManager.getDebugStatistics();
|
||||
|
||||
+6
-2
@@ -12,9 +12,13 @@ import java.util.Map;
|
||||
* @param byUpdateType a map from update type to the appropriate list of sections
|
||||
* @param hasAdditionalUpdates whether there were additional updates not queued for efficiency reasons
|
||||
*/
|
||||
public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>> byUpdateType, boolean hasAdditionalUpdates) {
|
||||
public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>> byUpdateType, boolean hasAdditionalUpdates, Map<ChunkUpdateType, Integer> queueOverflowCounts) {
|
||||
public static final ChunkRebuildLists EMPTY;
|
||||
|
||||
public int getUpdateCount(ChunkUpdateType type) {
|
||||
return byUpdateType.get(type).size() + queueOverflowCounts.getOrDefault(type, 0);
|
||||
}
|
||||
|
||||
static {
|
||||
Map<ChunkUpdateType, ArrayDeque<RenderSection>> rebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
||||
|
||||
@@ -22,6 +26,6 @@ public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>>
|
||||
rebuildLists.put(type, new ArrayDeque<>());
|
||||
}
|
||||
|
||||
EMPTY = new ChunkRebuildLists(rebuildLists, false);
|
||||
EMPTY = new ChunkRebuildLists(rebuildLists, false, new EnumMap<>(ChunkUpdateType.class));
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -1,6 +1,7 @@
|
||||
package org.embeddedt.embeddium.impl.render.chunk.lists;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2IntArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
@@ -17,6 +18,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final ObjectArrayList<ChunkRenderList> sortedRenderLists;
|
||||
private final EnumMap<ChunkUpdateType, ArrayDeque<RenderSection>> sortedRebuildLists;
|
||||
private final int[] rebuildQueueOverflowCounts;
|
||||
private final Reference2ReferenceOpenHashMap<RenderRegion, ChunkRenderList> renderListsByRegion;
|
||||
|
||||
private final int frame;
|
||||
@@ -30,6 +32,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
||||
|
||||
this.sortedRenderLists = new ObjectArrayList<>();
|
||||
this.sortedRebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
||||
this.rebuildQueueOverflowCounts = new int[ChunkUpdateType.values().length];
|
||||
this.ignoreQueueSizeLimit = ignoreQueueSizeLimit;
|
||||
this.renderListsByRegion = new Reference2ReferenceOpenHashMap<>();
|
||||
|
||||
@@ -74,6 +77,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
||||
if (this.ignoreQueueSizeLimit || queue.size() < type.getMaximumQueueSize()) {
|
||||
queue.add(section);
|
||||
} else {
|
||||
this.rebuildQueueOverflowCounts[type.ordinal()]++;
|
||||
this.hasAdditionalUpdates = true;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +88,15 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
||||
}
|
||||
|
||||
public ChunkRebuildLists getRebuildLists() {
|
||||
return new ChunkRebuildLists(this.sortedRebuildLists, this.hasAdditionalUpdates);
|
||||
EnumMap<ChunkUpdateType, Integer> overflowCounts = new EnumMap<>(ChunkUpdateType.class);
|
||||
if (this.hasAdditionalUpdates) {
|
||||
var values = ChunkUpdateType.values();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (this.rebuildQueueOverflowCounts[i] != 0) {
|
||||
overflowCounts.put(values[i], this.rebuildQueueOverflowCounts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ChunkRebuildLists(this.sortedRebuildLists, this.hasAdditionalUpdates, overflowCounts);
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,16 @@ plugins {
|
||||
id("celeritas-unimined-plugin")
|
||||
id("xyz.wagyourtail.unimined") version "1.3.15-SNAPSHOT"
|
||||
id("xyz.wagyourtail.jvmdowngrader") version "1.1.3"
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "org.embeddedt"
|
||||
version = rootProject.version
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
data class VersionData(val mcpVersion: String, val forgeVersion: String)
|
||||
|
||||
val versionDataMap = mapOf(
|
||||
@@ -24,7 +29,7 @@ val minecraftVersion = project.name
|
||||
|
||||
val versionData = versionDataMap.getValue(project.name)
|
||||
|
||||
base.archivesName = "celeritas-forge-${project.name}"
|
||||
base.archivesName = "celeritas-forge-mc${project.name.replace("^1\\.".toRegex(), "")}"
|
||||
|
||||
val modCompileOnly by configurations.creating
|
||||
configurations.compileOnly.get().extendsFrom(modCompileOnly)
|
||||
@@ -101,4 +106,16 @@ ProductionJarHelper.createShadowRemapJar(project)
|
||||
tasks.register("packageJar", Copy::class) {
|
||||
from(tasks.named<ShadowJar>("shadowRemapJar").get().archiveFile)
|
||||
into("${rootProject.layout.buildDirectory.get()}/libs/${project.version}")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("default") {
|
||||
artifactId = base.archivesName.get()
|
||||
artifact(tasks.named<ShadowJar>("shadowRemapJar").map { it.archiveFile })
|
||||
artifact(tasks.named("sourcesJar")) {
|
||||
classifier = "sources"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx2G
|
||||
# Gradle stuff
|
||||
stonecutter_version=0.7-beta.2
|
||||
taugradle_version=0.3.36
|
||||
junit_version=5.13.4
|
||||
|
||||
project_base_version=2.3
|
||||
|
||||
@@ -78,7 +79,7 @@ ffapi_1_21_1=0.104.0+2.0.18+1.21.1
|
||||
|
||||
# NeoForge stuff
|
||||
neoforge_1_20_4=20.4.237
|
||||
neoforge_1_21_1=21.1.73
|
||||
neoforge_1_21_1=21.1.200
|
||||
neoforge_1_21_8=21.8.15
|
||||
|
||||
# Forge Stuff
|
||||
|
||||
@@ -80,6 +80,17 @@ dependencies {
|
||||
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
||||
dependencies.add(cfg, dep)
|
||||
}
|
||||
|
||||
testImplementation("net.fabricmc:fabric-loader-junit:${rootProject.property("fabricloader")}")
|
||||
}
|
||||
|
||||
tasks.named<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
val junitDir = project.layout.buildDirectory.file("fabric-junit").get().asFile
|
||||
doFirst {
|
||||
junitDir.mkdirs()
|
||||
}
|
||||
workingDir = junitDir
|
||||
}
|
||||
|
||||
if (stonecutter.constants.getOrDefault("shaders", false)) {
|
||||
|
||||
@@ -20,6 +20,7 @@ plugins {
|
||||
id("celeritas.platform-conventions")
|
||||
id("celeritas.shader-conventions") apply false
|
||||
id("embeddium-fabric-module-finder")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "org.embeddedt"
|
||||
@@ -44,10 +45,15 @@ tasks.named<Jar>("jar") {
|
||||
archiveClassifier.set("deobf")
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
val config: MDGConfig = if (modLoader == ModLoader.NEOFORGE) {
|
||||
apply(plugin = "net.neoforged.moddev")
|
||||
val neoForge = project.extensions.getByName("neoForge") as NeoForgeExtension
|
||||
neoForge.version = versionedProperty("neoforge")
|
||||
neoForge.unitTest.enable()
|
||||
MDGConfig(neoForge, "jar")
|
||||
} else {
|
||||
apply(plugin = "net.neoforged.moddev.legacyforge")
|
||||
@@ -88,10 +94,25 @@ if (parchmentVersion != null) {
|
||||
}
|
||||
}
|
||||
|
||||
modDevExtension.mods {
|
||||
create("embeddium") {
|
||||
sourceSet(sourceSets.main.get())
|
||||
sourceSet(project(":common").sourceSets.main.get())
|
||||
val mainMod = modDevExtension.mods.create("embeddium") {
|
||||
sourceSet(sourceSets.main.get())
|
||||
sourceSet(project(":common").sourceSets.main.get())
|
||||
}
|
||||
|
||||
if (modLoader == ModLoader.NEOFORGE) {
|
||||
(modDevExtension as NeoForgeExtension).unitTest.testedMod = mainMod
|
||||
|
||||
tasks.named<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
} else {
|
||||
// Disable unit tests
|
||||
sourceSets.named("test") {
|
||||
java.setSrcDirs(emptyList<String>())
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
tasks.named("test") {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,11 +169,19 @@ dependencies {
|
||||
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
||||
dependencies.add(cfg, dep)
|
||||
}
|
||||
|
||||
testImplementation(platform("org.junit:junit-bom:${rootProject.property("junit_version")}"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
manifest {
|
||||
attributes.put("MixinConfigs", modMixinConfigs.joinToString(","))
|
||||
if (modLoader == ModLoader.NEOFORGE) {
|
||||
attributes.put("MixinConfigs", modMixinConfigs.joinToString(","))
|
||||
}
|
||||
attributes.put("Fabric-Loom-Mixin-Remap-Type", "static")
|
||||
attributes.put("Fabric-Mapping-Namespace", "intermediary")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,4 +213,16 @@ val packageJar = tasks.register("packageJar", Copy::class) {
|
||||
|
||||
tasks.named("assemble") {
|
||||
dependsOn(packageJar)
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("default") {
|
||||
artifactId = defaultArchiveBaseName
|
||||
artifact(shadowJar.map { it.archiveFile })
|
||||
artifact(tasks.named("sourcesJar")) {
|
||||
classifier = "sources"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.embeddedt.embeddium.impl.junit;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@ExtendWith({ BootstrapExtension.class })
|
||||
public @interface Bootstrap {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.embeddedt.embeddium.impl.junit;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
public class BootstrapExtension implements BeforeAllCallback {
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext context) throws Exception {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.pipeline;
|
||||
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class FluidOcclusionCacheTest {
|
||||
private final FluidOcclusionCache cache = new FluidOcclusionCache();
|
||||
|
||||
@Test
|
||||
void testFullBlockHidesFluidFace() {
|
||||
assertFalse(cache.isTopFluidFacePotentiallyVisible(Shapes.block()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSlabHidesFluidFace() {
|
||||
assertFalse(cache.isTopFluidFacePotentiallyVisible(FluidOcclusionCache.UPPER_HALF_SLAB));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThinSlabDoesNotHideFluidFace() {
|
||||
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(0.0, 0.7, 0.0, 1.0, 1.0, 1.0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInsetBlockDoesNotHideFluidFace() {
|
||||
double inset = 0.1;
|
||||
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(inset, 0.5, inset, 1.0 - inset, 1.0, 1.0 - inset)));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -122,7 +122,7 @@ createStonecutterProject("forge122", listOf("1.12.2", "1.10.2")) { versions ->
|
||||
versions(versions)
|
||||
}
|
||||
|
||||
createStonecutterProject("babric", listOf("1.2.5", "1.0.0-beta.7.3", "1.0.0-beta.8.1", "1.7.10")) { versions ->
|
||||
createStonecutterProject("babric", listOf("1.2.5", "1.0.0-beta.7.3", "1.0.0-beta.8.1", "1.7.10", "1.8.9")) { versions ->
|
||||
centralScript = "build.gradle.kts"
|
||||
versions(versions)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user