Fix format hopefully

This commit is contained in:
mcrcortex
2024-07-02 22:35:28 +09:00
parent d290fade13
commit 867431751a
4 changed files with 21 additions and 8 deletions

View File

@@ -116,7 +116,7 @@ public class VoxelCore {
}
private AbstractFarWorldRenderer<?,?> createRenderBackend() {
if (false) {
if (true) {
System.out.println("Using Gl46MeshletFarWorldRendering");
return new Gl46MeshletsFarWorldRenderer(VoxyConfig.CONFIG.geometryBufferSize, VoxyConfig.CONFIG.maxSections);
} else {

View File

@@ -4,10 +4,9 @@ import me.cortex.voxy.common.util.TrackedObject;
import static org.lwjgl.opengl.ARBFramebufferObject.glDeleteFramebuffers;
import static org.lwjgl.opengl.ARBFramebufferObject.glGenFramebuffers;
import static org.lwjgl.opengl.GL11C.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11C.glDeleteTextures;
import static org.lwjgl.opengl.GL45C.glCreateTextures;
import static org.lwjgl.opengl.GL45C.glTextureStorage2D;
import static org.lwjgl.opengl.GL11C.*;
import static org.lwjgl.opengl.GL30C.glGetIntegeri;
import static org.lwjgl.opengl.GL45C.*;
public class GlTexture extends TrackedObject {
public final int id;
@@ -35,4 +34,16 @@ public class GlTexture extends TrackedObject {
super.free0();
glDeleteTextures(this.id);
}
//TODO: FIXME, glGetTextureParameteri doesnt work
public static int getRawTextureType(int texture) {
if (!glIsTexture(texture)) {
throw new IllegalStateException("Not texture");
}
int immFormat = glGetTextureParameteri(texture, GL_TEXTURE_IMMUTABLE_FORMAT);
if (immFormat == 0) {
throw new IllegalStateException("Texture: " + texture + " is not immutable");
}
return immFormat;
}
}

View File

@@ -7,6 +7,7 @@ import me.cortex.voxy.client.core.gl.shader.ShaderType;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.ARBDirectStateAccess.*;
import static org.lwjgl.opengl.GL11.glScaled;
import static org.lwjgl.opengl.GL11C.*;
import static org.lwjgl.opengl.GL30C.*;
import static org.lwjgl.opengl.GL33.glBindSampler;
@@ -41,7 +42,8 @@ public class HiZBuffer {
this.levels -= 3;//Arbitrary size, shinks the max level by alot and saves a significant amount of processing time
// (could probably increase it to be defined by a max meshlet coverage computation thing)
this.texture = new GlTexture().store(GL_DEPTH_COMPONENT32, this.levels, width, height);
//GL_DEPTH_COMPONENT32F //Cant use this as it does not match the depth format of the provided depth buffer
this.texture = new GlTexture().store(GL_DEPTH24_STENCIL8, this.levels, width, height);
glTextureParameteri(this.texture.id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTextureParameteri(this.texture.id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTextureParameteri(this.texture.id, GL_TEXTURE_COMPARE_MODE, GL_NONE);
@@ -75,7 +77,7 @@ public class HiZBuffer {
glDepthFunc(GL_ALWAYS);
//System.err.println("SRC: " + GlTexture.getRawTextureType(srcDepthTex) + " DST: " + this.texture.id);
glCopyImageSubData(srcDepthTex, GL_TEXTURE_2D, 0,0,0,0,
this.texture.id, GL_TEXTURE_2D, 0,0,0,0,
width, height, 1);