mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 07:03:02 +00:00
Address comments about SubVBO.render()
This commit is contained in:
1 parent
dea84d4279
commit
c0ea254d62
8 files changed
+29
-11
No files matched your search
@@ -4086,10 +4086,14 @@ public class GLStateManager {
|
||||
if (boundVAO != array) {
|
||||
boundVAO = array;
|
||||
UniversalVAO.bindVertexArray(array);
|
||||
if (ShaderManager.getInstance().isEnabled()) {
|
||||
ShaderManager.getInstance().onBindVertexArray(array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void glDeleteVertexArrays(int array) {
|
||||
ShaderManager.getInstance().onDeleteVertexArray(array);
|
||||
if (array == boundVAO) {
|
||||
// Deleting the bound VAO implicitly unbinds it. Rebind the default VAO.
|
||||
boundVAO = defaultVAO;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.glsm.CompatUniformManager;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.Vec3fStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.Vec4fStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.gl.blending.BlendModeStorage;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -28,6 +29,7 @@ public class ShaderManager {
|
||||
|
||||
private final ShaderCache cache = new ShaderCache();
|
||||
private final Uniforms uniforms = new Uniforms();
|
||||
private final Int2IntOpenHashMap vaoVertexFlags = new Int2IntOpenHashMap();
|
||||
|
||||
@Getter
|
||||
private boolean active = false;
|
||||
@@ -45,6 +47,7 @@ public class ShaderManager {
|
||||
private int currentVertexFlags = VertexFlags.TEXTURE_BIT | VertexFlags.COLOR_BIT | VertexFlags.NORMAL_BIT;
|
||||
|
||||
private ShaderManager() {
|
||||
vaoVertexFlags.defaultReturnValue(-1);
|
||||
boolean isDev = false;
|
||||
try {
|
||||
final Object deobfEnv = Launch.blackboard != null ? Launch.blackboard.get("fml.deobfuscatedEnvironment") : null;
|
||||
@@ -64,6 +67,10 @@ public class ShaderManager {
|
||||
|
||||
VertexFormat.registerSetupBufferStateOverride((format, offset) -> {
|
||||
currentVertexFlags = format.getVertexFlags();
|
||||
final int boundVao = GLStateManager.getBoundVAO();
|
||||
if (boundVao != 0) {
|
||||
vaoVertexFlags.put(boundVao, currentVertexFlags);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -159,6 +166,17 @@ public class ShaderManager {
|
||||
public static void bumpNormalGeneration() { normalGeneration++; }
|
||||
public static void bumpTexCoordGeneration() { texCoordGeneration++; }
|
||||
|
||||
public void onBindVertexArray(int vaoId) {
|
||||
final int flags = vaoVertexFlags.get(vaoId);
|
||||
if (flags != -1) {
|
||||
currentVertexFlags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeleteVertexArray(int vaoId) {
|
||||
vaoVertexFlags.remove(vaoId);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
cache.destroy();
|
||||
uniforms.destroy();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.IVertexArrayObject;
|
||||
import com.gtnewhorizons.angelica.glsm.ffp.ShaderManager;
|
||||
|
||||
/**
|
||||
* A class that stores multiple vertex formats & their corresponding buffers.
|
||||
@@ -34,14 +33,12 @@ public final class DisplayListVBO {
|
||||
private final int drawMode;
|
||||
private final int start;
|
||||
private final int count;
|
||||
private final int vertexFlags;
|
||||
|
||||
public SubVBO(IVertexArrayObject vao, int drawMode, int start, int count, int vertexFlags) {
|
||||
public SubVBO(IVertexArrayObject vao, int drawMode, int start, int count) {
|
||||
this.vao = vao;
|
||||
this.drawMode = drawMode;
|
||||
this.start = start;
|
||||
this.count = count;
|
||||
this.vertexFlags = vertexFlags;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
@@ -49,7 +46,6 @@ public final class DisplayListVBO {
|
||||
}
|
||||
|
||||
public void render() {
|
||||
ShaderManager.getInstance().preDraw(vertexFlags);
|
||||
vao.bind();
|
||||
vao.draw(drawMode, start, count);
|
||||
vao.unbind();
|
||||
|
||||
@@ -74,9 +74,9 @@ public final class DisplayListVBOBuilder {
|
||||
}
|
||||
if (data.drawMode == GL11.GL_QUADS) {
|
||||
final IVertexArrayObject indexedVAO = new IndexedVAO(vbo, IndexBuffer.convertQuadsToTrigs(start, start + vertexCount));
|
||||
vbos[data.drawIndex] = new DisplayListVBO.SubVBO(indexedVAO, GL11.GL_TRIANGLES, 0, vertexCount / 4 * 6, i);
|
||||
vbos[data.drawIndex] = new DisplayListVBO.SubVBO(indexedVAO, GL11.GL_TRIANGLES, 0, vertexCount / 4 * 6);
|
||||
} else {
|
||||
vbos[data.drawIndex] = new DisplayListVBO.SubVBO(vao, data.drawMode, start, vertexCount, i);
|
||||
vbos[data.drawIndex] = new DisplayListVBO.SubVBO(vao, data.drawMode, start, vertexCount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -277,6 +277,7 @@ public enum Mixins implements IMixins {
|
||||
OPTIMIZE_WORLD_UPDATE_LIGHT(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addExcludedMod(TargetedMod.ARCHAICFIX)
|
||||
.addExcludedMod(TargetedMod.SUPERNOVA)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeWorldUpdateLight)
|
||||
.addCommonMixins("angelica.lighting.MixinWorld_FixLightUpdateLag")),
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public enum TargetedMod implements ITargetMod {
|
||||
IC2("ic2.core.coremod.IC2core", "IC2"),
|
||||
NATURA(null, "Natura"),
|
||||
SECURITYCRAFT(null, "securitycraft"),
|
||||
SUPERNOVA("com.mitchej123.supernova.core.SupernovaCore", "supernova"),
|
||||
THAUMCRAFT(null, "Thaumcraft"),
|
||||
TINKERS_CONSTRUCT(null, "TConstruct"),
|
||||
TWILIGHT_FOREST(null, "TwilightForest"),
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.vao.IndexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.ffp.ShaderManager;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -91,7 +91,6 @@ public class ItemRenderListManager {
|
||||
public static void post(DirectTessellator tessellator, CachedVBO vbo) {
|
||||
vbo.allocate(tessellator);
|
||||
TessellatorManager.stopCapturingDirect();
|
||||
ShaderManager.getInstance().preDraw(CachedVBO.VERTEX_FLAGS);
|
||||
vbo.vertexBuffer.render();
|
||||
}
|
||||
|
||||
@@ -100,7 +99,6 @@ public class ItemRenderListManager {
|
||||
}
|
||||
|
||||
public static final class CachedVBO {
|
||||
private static final int VERTEX_FLAGS = DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexFlags();
|
||||
private final IVertexArrayObject vertexBuffer;
|
||||
private final IndexBuffer ebo;
|
||||
private int expiry;
|
||||
@@ -119,7 +117,6 @@ public class ItemRenderListManager {
|
||||
}
|
||||
|
||||
private void render(int elapsedTicks) {
|
||||
ShaderManager.getInstance().preDraw(VERTEX_FLAGS);
|
||||
vertexBuffer.render();
|
||||
expiry = elapsedTicks + EXPIRY_TICKS;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user