changes and attempted fixes

This commit is contained in:
mcrcortex
2025-08-27 21:21:29 +10:00
parent d8324dacd4
commit f2bcfca8e8
6 changed files with 40 additions and 5 deletions

View File

@@ -98,6 +98,8 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
glBlitNamedFramebuffer(sourceFrameBuffer, targetFb, 0,0, width, height, 0,0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL30.GL_FRAMEBUFFER, targetFb);
//GL11C.glClearStencil(1);
//GL11C.glClear(GL_STENCIL_BUFFER_BIT);
//This whole thing is hell, we basicly want to create a mask stenicel/depth mask specificiclly
// in theory we could do this in a single pass by passing in the depth buffer from the sourceFrambuffer

View File

@@ -25,9 +25,11 @@ public class Capabilities {
public final boolean indirectParameters;
public final boolean isIntel;
public final boolean subgroup;
public final boolean sparseBuffer;
public Capabilities() {
var cap = GL.getCapabilities();
this.sparseBuffer = cap.GL_ARB_sparse_buffer;
this.compute = cap.glDispatchComputeIndirect != 0;
this.indirectParameters = cap.glMultiDrawElementsIndirectCountARB != 0;
this.repFragTest = cap.GL_NV_representative_fragment_test;

View File

@@ -4,6 +4,7 @@ import me.cortex.voxy.common.util.TrackedObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.MemoryUtil;
import static org.lwjgl.opengl.ARBSparseBuffer.GL_SPARSE_STORAGE_BIT_ARB;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE;
import static org.lwjgl.opengl.GL15.glDeleteBuffers;
import static org.lwjgl.opengl.GL45C.*;
@@ -23,7 +24,9 @@ public class GlBuffer extends TrackedObject {
this.id = glCreateBuffers();
this.size = size;
glNamedBufferStorage(this.id, size, flags);
this.zero();
if ((flags&GL_SPARSE_STORAGE_BIT_ARB)==0) {
this.zero();
}
COUNT++;
TOTAL_SIZE += size;

View File

@@ -1,6 +1,7 @@
package me.cortex.voxy.client.core.model;
import net.caffeinemc.mods.sodium.client.util.color.ColorSRGB;
import net.minecraft.client.texture.MipmapHelper;
//Texturing utils to manipulate data from the model bakery
public class TextureUtils {
@@ -177,7 +178,11 @@ public class TextureUtils {
public static int mipColours(int one, int two, int three, int four) {
return weightedAverageColor(weightedAverageColor(one, two), weightedAverageColor(three, four));
if (true) {
return MipmapHelper.blend(one, two, three, four, false);
} else {
return weightedAverageColor(weightedAverageColor(one, two), weightedAverageColor(three, four));
}
}
//TODO: FIXME!!! ITS READING IT AS ABGR??? isnt the format RGBA??

View File

@@ -4,7 +4,9 @@ import me.cortex.voxy.client.core.gl.Capabilities;
import me.cortex.voxy.client.core.gl.GlBuffer;
import me.cortex.voxy.common.Logger;
import static org.lwjgl.opengl.GL11C.glFinish;
import static org.lwjgl.opengl.ARBSparseBuffer.GL_SPARSE_STORAGE_BIT_ARB;
import static org.lwjgl.opengl.ARBSparseBuffer.glNamedBufferPageCommitmentARB;
import static org.lwjgl.opengl.GL11C.*;
public class BasicSectionGeometryData implements IGeometryData {
public static final int SECTION_METADATA_SIZE = 32;
@@ -28,7 +30,26 @@ public class BasicSectionGeometryData implements IGeometryData {
}
Logger.info(msg);
Logger.info("if your game crashes/exits here without any other log message, try manually decreasing the geometry capacity");
this.geometryBuffer = new GlBuffer(geometryCapacity);
glGetError();//Clear any errors
var buffer = new GlBuffer(geometryCapacity);
int error = glGetError();
if (error != GL_NO_ERROR) {
if (error == GL_OUT_OF_MEMORY && Capabilities.INSTANCE.sparseBuffer) {
Logger.error("Failed to allocate geometry buffer, attempting workaround with sparse buffers");
buffer.free();
buffer = new GlBuffer(geometryCapacity, GL_SPARSE_STORAGE_BIT_ARB);
glNamedBufferPageCommitmentARB(buffer.id, 0, geometryCapacity, true);
buffer.zero();
error = glGetError();
if (error != GL_NO_ERROR) {
buffer.free();
throw new IllegalStateException("Unable to allocate geometry buffer using workaround, got gl error " + error);
}
} else {
throw new IllegalStateException("Unable to allocate geometry buffer, got gl error " + error);
}
}
this.geometryBuffer = buffer;
long delta = System.currentTimeMillis() - start;
Logger.info("Successfully allocated and zeroed the geometry buffer in " + delta + "ms");
}

View File

@@ -33,4 +33,6 @@ accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap
accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getChunk (I)Lnet/minecraft/world/chunk/WorldChunk;
accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getIndex (II)I
accessible field net/minecraft/client/texture/SpriteAtlasTexture mipLevel I
accessible field net/minecraft/client/texture/SpriteAtlasTexture mipLevel I
accessible method net/minecraft/client/texture/MipmapHelper blend (IIIIZ)I