This commit is contained in:
mcrcortex
2024-02-05 22:51:04 +10:00
parent 81ce54fe4b
commit af1800226d
9 changed files with 66 additions and 10 deletions

View File

@@ -32,7 +32,8 @@ public class TextureUtils {
} else if (mode == WRITE_CHECK_DEPTH) {
return (data.depth()[index]>>>8)!=((1<<24)-1);
} else if (mode == WRITE_CHECK_ALPHA) {
return ((data.colour()[index]>>>24)&0xff)!=0;
//TODO:FIXME: for some reason it has an alpha of 1 even if its ment to be 0
return ((data.colour()[index]>>>24)&0xff)>1;
}
throw new IllegalArgumentException();
}

View File

@@ -137,6 +137,7 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
this.lodShader.bind();
glDisable(GL_CULL_FACE);
glPointSize(10);
glMultiDrawElementsIndirectCountARB(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 0, (int) (this.geometry.getSectionCount()*4.4), 0);
glEnable(GL_CULL_FACE);

View File

@@ -18,6 +18,7 @@ public class MixinGameRenderer {
@ModifyConstant(method = "getBasicProjectionMatrix", constant = @Constant(floatValue = 0.05F))
public float modifyNearplane(float constant) {
return 10;
//return 10;
return constant;
}
}

View File

@@ -11,6 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinMinecraftClient {
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resource/PeriodicNotificationManager;<init>(Lnet/minecraft/util/Identifier;Lit/unimi/dsi/fastutil/objects/Object2BooleanFunction;)V", shift = At.Shift.AFTER))
private void injectRenderDoc(RunArgs args, CallbackInfo ci) {
//System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll");
System.load("C:\\Program Files\\RenderDoc\\renderdoc.dll");
}
}

View File

@@ -12,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinSodiumWorldRender {
@Inject(method = "drawChunkLayer", at = @At("HEAD"), cancellable = true, require = 0)
private void cancelRender(RenderLayer renderLayer, MatrixStack matrixStack, double x, double y, double z, CallbackInfo ci) {
//ci.cancel();
ci.cancel();
}
}

View File

@@ -11,11 +11,12 @@ public class ActiveSectionTracker {
private final Long2ObjectOpenHashMap<VolatileHolder<WorldSection>>[] loadedSectionCache;
private final SectionLoader loader;
//private final SectionDataCache dataCache;
@SuppressWarnings("unchecked")
public ActiveSectionTracker(int cacheSizeBits, SectionLoader loader) {
public ActiveSectionTracker(int numSlicesBits, SectionLoader loader) {
this.loader = loader;
this.loadedSectionCache = new Long2ObjectOpenHashMap[1<<cacheSizeBits];
this.loadedSectionCache = new Long2ObjectOpenHashMap[1<<numSlicesBits];
for (int i = 0; i < this.loadedSectionCache.length; i++) {
this.loadedSectionCache[i] = new Long2ObjectOpenHashMap<>(1024);
}
@@ -42,7 +43,11 @@ public class ActiveSectionTracker {
//If this thread was the one to create the reference then its the thread to load the section
if (isLoader) {
var section = new WorldSection(lvl, x, y, z, this);
int status = this.loader.load(section);
int status = -1;//this.dataCache.load(section);
if (status == -1) {//Cache miss
status = this.loader.load(section);
}
if (status < 0) {
//TODO: Instead if throwing an exception do something better
throw new IllegalStateException("Unable to load section");

View File

@@ -0,0 +1,48 @@
package me.cortex.voxy.common.world;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
public class SectionDataCache {
private record MapPair(Reference2LongOpenHashMap<SoftReference<long[]>> ref2pos, Long2ObjectMap<SoftReference<long[]>> pos2ref) {
public MapPair() {
this(new Reference2LongOpenHashMap<>(), new Long2ObjectOpenHashMap<>());
}
}
private final MapPair[] maps;
private final ReferenceQueue<long[]> cleanupQueue;
public SectionDataCache(int sliceBits) {
this.cleanupQueue = new ReferenceQueue<>();
this.maps = new MapPair[1<<sliceBits];
for (int i = 0; i < this.maps.length; i++) {
this.maps[i] = new MapPair();
}
}
private MapPair getMap(long pos) {
return this.maps[(int) (ActiveSectionTracker.mixStafford13(pos)&(this.maps.length-1))];
}
public int loadAndPut(WorldSection section) {
var map = this.getMap(section.key);
synchronized (map) {
var entry = map.pos2ref.get(section.key);
if (entry == null) {//No entry in cache so put it in cache
map.pos2ref.put(section.key, new SoftReference<>(section.data));
return -1;
}
//var data = entry.data.get();
//if (data == null) {
// map.remove(section.key);
// return -1;
//}
//System.arraycopy(data, 0, section.data, 0, data.length);
return 0;
}
}
}

View File

@@ -78,14 +78,14 @@ void main() {
offset = offset.zxy;
}
gl_Position = MVP * vec4(corner + offset, 1);
gl_Position = MVP * vec4(corner + offset, 1f);
//Compute the uv coordinates
vec2 modelUV = vec2(modelId&0xFF, (modelId>>8)&0xFF)*(1f/(256f));
//TODO: make the face orientated by 2x3 so that division is not a integer div and modulo isnt needed
// as these are very slow ops
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3, 2)*256f)));
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3f, 2f)*256f)));
uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv
discardAlpha = faceHasAlphaCuttout(faceData);

View File

@@ -47,7 +47,7 @@ void main() {
float d = computeAOAngle(pos, 0.75*(1<<lod), viewNormal);//1
if (d<0.1) {
return;
d = 0f;
}
vec4 ocolour = colour;