diff --git a/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java b/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java index 1d2cd4bf0..52507650b 100644 --- a/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java +++ b/src/main/java/com/gtnewhorizons/angelica/config/AngelicaConfig.java @@ -47,6 +47,11 @@ public class AngelicaConfig { @Config.RequiresMcRestart public static boolean enableVBOClouds; + @Config.Comment("Uses cached attributes for VBO rendering, resulting in less CPU overhead. Disable if you notice any graphical issues.") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enableVAO; + @Config.Comment("Enable NotFine features") @Config.DefaultBoolean(true) @Config.RequiresMcRestart diff --git a/src/main/java/com/gtnewhorizons/angelica/hudcaching/HUDCaching.java b/src/main/java/com/gtnewhorizons/angelica/hudcaching/HUDCaching.java index 372faf468..381e12086 100644 --- a/src/main/java/com/gtnewhorizons/angelica/hudcaching/HUDCaching.java +++ b/src/main/java/com/gtnewhorizons/angelica/hudcaching/HUDCaching.java @@ -4,6 +4,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator; import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager; import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.CustomFramebuffer; import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.SharedDepthFramebuffer; +import com.gtnewhorizon.gtnhlib.client.renderer.vao.VertexArrayBuffer; import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat; import com.gtnewhorizons.angelica.compat.ModStatus; @@ -178,10 +179,7 @@ public class HUDCaching { if (quadWidth != width || quadHeight != height) { quadWidth = width; quadHeight = height; - if (quadVAO != null) { - quadVAO.close(); - } - quadVAO = rebuildVAO(width, height); + rebuildVAO(width, height); } GLStateManager.disableDepthTest(); GLStateManager.enableTexture(); @@ -190,7 +188,7 @@ public class HUDCaching { } - private static VertexBuffer rebuildVAO(float width, float height) { + private static void rebuildVAO(float width, float height) { final CapturingTessellator tessellator = TessellatorManager.startCapturingAndGet(); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0, height, 0.0, 0, 0); @@ -198,7 +196,7 @@ public class HUDCaching { tessellator.addVertexWithUV(width, 0, 0.0, 1, 1); tessellator.addVertexWithUV(0, 0, 0.0, 0, 1); tessellator.draw(); - return TessellatorManager.stopCapturingToVAO(DefaultVertexFormat.POSITION_TEXTURE); + quadVAO = TessellatorManager.stopCapturingToVAO(quadVAO, DefaultVertexFormat.POSITION_TEXTURE); } public static void disableHoloInventory() { diff --git a/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java b/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java index 06431ee29..cc113f1d6 100644 --- a/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java +++ b/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java @@ -5,6 +5,7 @@ import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER; import com.google.common.base.Objects; import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry; +import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager; import com.gtnewhorizons.angelica.compat.ModStatus; import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat; import com.gtnewhorizons.angelica.config.AngelicaConfig; @@ -111,6 +112,9 @@ public class ClientProxy extends CommonProxy { FMLCommonHandler.instance().bus().register(Iris.INSTANCE); MinecraftForge.EVENT_BUS.register(Iris.INSTANCE); } + if (!AngelicaConfig.enableVAO) { + VAOManager.disableVao(); + } FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); diff --git a/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java b/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java index a03f72cb3..69cd734cd 100644 --- a/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java @@ -218,12 +218,11 @@ public class CloudRenderer implements IResourceManagerReloadListener { } private void build() { - TessellatorManager.startCapturing(); - CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get(); + CapturingTessellator tess = TessellatorManager.startCapturingAndGet(); vertices(tess); - this.vbo = TessellatorManager.stopCapturingToVBO(FORMAT); + this.vbo = TessellatorManager.stopCapturingToVAO(FORMAT); } private int fullCoord(double coord, int scale) { // Corrects misalignment of UV offset when on negative coords. diff --git a/src/main/java/com/gtnewhorizons/angelica/rendering/ItemRenderListManager.java b/src/main/java/com/gtnewhorizons/angelica/rendering/ItemRenderListManager.java index 16260714d..99e3c16d1 100644 --- a/src/main/java/com/gtnewhorizons/angelica/rendering/ItemRenderListManager.java +++ b/src/main/java/com/gtnewhorizons/angelica/rendering/ItemRenderListManager.java @@ -27,6 +27,7 @@ package com.gtnewhorizons.angelica.rendering; import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator; import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager; +import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager; import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat; import com.gtnewhorizons.angelica.config.AngelicaConfig; @@ -126,7 +127,7 @@ public class ItemRenderListManager { private int expiry; public CachedVBO() { - this.vertexBuffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS); + this.vertexBuffer = VAOManager.createVAO(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS); } private void render(int elapsedTicks) { diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java index d2926de90..bcdd1d599 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java @@ -66,8 +66,7 @@ public class BlockRenderer { final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks. final LightPipeline lighter = this.lighters.getLighter(mode); - TessellatorManager.startCapturing(); - final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get(); + final CapturingTessellator tess = TessellatorManager.startCapturingAndGet(); tess.startDrawingQuads(); // Use setTranslation rather than setOffset so that the float data written to the internal buffer // is done in subchunk-relative coordinates @@ -101,8 +100,7 @@ public class BlockRenderer { final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z); try { - TessellatorManager.startCapturing(); - final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get(); + final CapturingTessellator tess = TessellatorManager.startCapturingAndGet(); tess.startDrawingQuads(); // Use setTranslation rather than setOffset so that the float data written to the internal buffer // is done in subchunk-relative coordinates diff --git a/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java b/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java index 06a2b57dc..e89772d2f 100644 --- a/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java @@ -52,17 +52,13 @@ public class HorizonRenderer { } private void rebuildBuffer() { - if (this.vertexBuffer != null) { - this.vertexBuffer.close(); - } - TessellatorManager.startCapturing(); - final CapturingTessellator tessellator = (CapturingTessellator) TessellatorManager.get(); + final CapturingTessellator tessellator = TessellatorManager.startCapturingAndGet(); // Build the horizon quads into a buffer tessellator.startDrawingQuads(); //(GL11.GL_QUADS, DefaultVertexFormat.POSITION); buildHorizon(currentRenderDistance * 16, tessellator); - this.vertexBuffer = TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION); + this.vertexBuffer = TessellatorManager.stopCapturingToVAO(vertexBuffer, DefaultVertexFormat.POSITION); } private void buildQuad(Tessellator consumer, double x1, double z1, double x2, double z2) { @@ -155,12 +151,9 @@ public class HorizonRenderer { rebuildBuffer(); } - vertexBuffer.bind(); - GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); - GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + vertexBuffer.setupState(); vertexBuffer.draw(floatBuffer); - GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); - vertexBuffer.unbind(); + vertexBuffer.cleanupState(); } public void destroy() { diff --git a/src/test/java/com/gtnewhorizons/angelica/util/GLBit.java b/src/test/java/com/gtnewhorizons/angelica/util/GLBit.java index 49e02f5ab..d3c1aa7b5 100644 --- a/src/test/java/com/gtnewhorizons/angelica/util/GLBit.java +++ b/src/test/java/com/gtnewhorizons/angelica/util/GLBit.java @@ -24,7 +24,7 @@ public final class GLBit { public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; - var that = (GLBit) obj; + GLBit that = (GLBit) obj; return Objects.equals(this.name, that.name) && this.glEnum == that.glEnum && this.initial == that.initial; }