mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-12 08:27:39 +00:00
Remove tessellator to buffer (#123)
* Update buildscript * Swap out uploading a tesselator and tesselatorToBuffer with a Capturing Tesselator
This commit is contained in:
1 parent
0460f6dbcd
commit
c19c812c10
7 files changed
+88
-79
No files matched your search
+20
-29
@@ -1,4 +1,4 @@
|
||||
//version: 1699290261
|
||||
//version: 1704135167
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -28,27 +28,11 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
// GTNH RetroFuturaGradle and ASM Fork
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
@@ -64,12 +48,12 @@ plugins {
|
||||
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
id 'com.palantir.git-version' version '3.0.0' apply false
|
||||
id 'de.undercouch.download' version '5.4.0'
|
||||
id 'de.undercouch.download' version '5.5.0'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
|
||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
|
||||
}
|
||||
|
||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||
@@ -133,7 +117,7 @@ propertyDefaultIfUnset("forceEnableMixins", false)
|
||||
propertyDefaultIfUnset("channel", "stable")
|
||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "https://nexus.gtnewhorizons.com/repository/releases/")
|
||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||
propertyDefaultIfUnset("modrinthRelations", "")
|
||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||
@@ -588,13 +572,15 @@ afterEvaluate {
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
name = "GTNH Maven"
|
||||
url = "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
// Links for convenience:
|
||||
// Simple HTML browsing: https://nexus.gtnewhorizons.com/service/rest/repository/browse/releases/
|
||||
// Rich web UI browsing: https://nexus.gtnewhorizons.com/#browse/browse:releases
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
@@ -687,6 +673,8 @@ configurations.all {
|
||||
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
||||
|
||||
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,7 +781,7 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lwjgl3ifyVersion = '1.5.4'
|
||||
def lwjgl3ifyVersion = '1.5.7'
|
||||
if (modId != 'lwjgl3ify') {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
@@ -972,6 +960,9 @@ if (usesShadowedDependencies.toBoolean()) {
|
||||
configurations.apiElements.outgoing.artifacts.clear()
|
||||
configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
tasks.named("jar", Jar) {
|
||||
archiveClassifier.set('dev-preshadow')
|
||||
}
|
||||
tasks.named("reobfJar", ReobfuscatedJar) {
|
||||
inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile}))
|
||||
}
|
||||
@@ -1182,7 +1173,7 @@ publishing {
|
||||
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
||||
maven {
|
||||
url = mavenPublishUrl
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://")
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
@@ -1301,7 +1292,7 @@ def addCurseForgeRelation(String type, String name) {
|
||||
|
||||
// Updating
|
||||
|
||||
def buildscriptGradleVersion = "8.2.1"
|
||||
def buildscriptGradleVersion = "8.5"
|
||||
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
gradleVersion = buildscriptGradleVersion
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Type;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Usage;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.ItemVBOQuadWriter;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.PositionQuadWriter;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
|
||||
public class DefaultVertexFormat {
|
||||
@@ -22,7 +21,7 @@ public class DefaultVertexFormat {
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(OVERLAY_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).build());
|
||||
public static final VertexFormat POSITION = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).build(), new PositionQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).build());
|
||||
|
||||
@@ -26,47 +26,6 @@ public class VertexBuffer implements AutoCloseable {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void upload(Tessellator tessellator, VertexFormat format) {
|
||||
try {
|
||||
this.upload(tessellatorToBuffer(tessellator, format), tessellator.vertexCount);
|
||||
} catch(Exception e) {
|
||||
throw new RuntimeException("Failed to upload vertex buffer", e);
|
||||
} finally {
|
||||
((ITessellatorInstance) tessellator).discard();
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer tessellatorToBuffer(Tessellator tessellator, VertexFormat format) {
|
||||
|
||||
final int verticesPerPrimitive = tessellator.drawMode == GL11.GL_QUADS ? 4 : 3;
|
||||
|
||||
final int[] rawBuffer = tessellator.rawBuffer;
|
||||
final int byteSize = format.getVertexSize() * tessellator.vertexCount;
|
||||
final ByteBuffer byteBuffer = BufferUtils.createByteBuffer(byteSize);
|
||||
|
||||
|
||||
|
||||
for(int quadI = 0 ; quadI < tessellator.vertexCount / verticesPerPrimitive ; quadI++) {
|
||||
for(int vertexI = 0 ; vertexI < 4 ; vertexI++) {
|
||||
final int i = (quadI * 4 * 8 ) + (vertexI * 8);
|
||||
|
||||
// Position
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 0]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 1]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 2]));
|
||||
|
||||
// Texture
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 3]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 4]));
|
||||
|
||||
// Normals
|
||||
byteBuffer.putInt(rawBuffer[i + 6]);
|
||||
}
|
||||
}
|
||||
|
||||
return (ByteBuffer) byteBuffer.rewind();
|
||||
}
|
||||
|
||||
public void upload(ByteBuffer buffer, int vertexCount) {
|
||||
if (this.id == -1) return;
|
||||
this.vertexCount = vertexCount;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-4
@@ -1,8 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.vbo;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IModelCustomExt;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
@@ -12,6 +15,9 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = WavefrontObject.class, remap = false)
|
||||
public abstract class MixinWavefrontObject implements IModelCustomExt {
|
||||
@Unique private VertexBuffer vertexBuffer;
|
||||
@@ -30,13 +36,16 @@ public abstract class MixinWavefrontObject implements IModelCustomExt {
|
||||
if (this.vertexBuffer != null) {
|
||||
this.vertexBuffer.close();
|
||||
}
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawing(currentGroupObject.glDrawingMode);
|
||||
tessellateAll(tessellator);
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawing(currentGroupObject.glDrawingMode);
|
||||
tessellateAll(tess);
|
||||
List<Quad> quads = TessellatorManager.stopCapturing();
|
||||
final ByteBuffer byteBuffer = CapturingTessellator.quadsToBuffer(quads, format);
|
||||
|
||||
this.vertexBuffer = new VertexBuffer();
|
||||
this.vertexBuffer.bind();
|
||||
this.vertexBuffer.upload(tessellator, format);
|
||||
vertexBuffer.upload(byteBuffer, quads.size() * 4);
|
||||
this.vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ public class IrisRenderSystem {
|
||||
Iris.logger.info("ARB_direct_state_access detected, enabling DSA.");
|
||||
}
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
if (dsaState == null) {
|
||||
dsaState = new DSAUnsupported();
|
||||
}
|
||||
|
||||
try {
|
||||
hasMultibind |= Iris.capabilities.GL_ARB_multi_bind;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Renders the sky horizon. Vanilla Minecraft simply uses the "clear color" for its horizon, and then draws a plane
|
||||
@@ -52,15 +57,18 @@ public class HorizonRenderer {
|
||||
if (this.vertexBuffer != null) {
|
||||
this.vertexBuffer.close();
|
||||
}
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tessellator = (CapturingTessellator) TessellatorManager.get();
|
||||
|
||||
// Build the horizon quads into a buffer
|
||||
tessellator.startDrawingQuads(); //(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
|
||||
buildHorizon(currentRenderDistance * 16, tessellator);
|
||||
List<Quad> quads = TessellatorManager.stopCapturing();
|
||||
final ByteBuffer byteBuffer = CapturingTessellator.quadsToBuffer(quads, DefaultVertexFormat.POSITION);
|
||||
|
||||
this.vertexBuffer = new VertexBuffer();
|
||||
this.vertexBuffer.bind();
|
||||
this.vertexBuffer.upload(tessellator, DefaultVertexFormat.POSITION);
|
||||
this.vertexBuffer.upload(byteBuffer, quads.size() * 4);
|
||||
this.vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user