Compare commits

..
Author SHA1 Message Date
Jason Mitchell 78334717e7 Fix TAA:
* Return an immutable view of the underlying camera position to avoid mutating it
* Update Camera Uniforms to utilize the view instead of mutating in place
2025-11-05 09:59:47 -08:00
MalTeeez a77765a2c9 Allow avoiding other mods spash screen handlers (#1080) 2025-10-31 16:06:28 -07:00
sisyphussy 1a9fe45ee9 Add VAO test (#1089) 2025-10-31 10:10:01 -07:00
7 changed files with 136 additions and 14 deletions

No files matched your search

+2
View File
@@ -101,6 +101,8 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
// For testing alternative splash screens, can be sourced from https://github.com/MalTeeez/ModernSplash/releases
//runtimeOnly(rfg.deobf(files("dependencies/modernsplash-1.7.10-1.2.2-dev.jar")))
// Hodgepodge
transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
@@ -87,8 +87,7 @@ public class BatchingFontRenderer {
}
this.isSGA = Objects.equals(this.locationFontTexture.getResourcePath(), "textures/font/ascii_sga.png");
// noinspection deprecation
this.isSplash = underlying instanceof SplashProgress.SplashFontRenderer;
this.isSplash = FontStrategist.isSplashFontRendererActive(underlying);
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
@@ -3,8 +3,10 @@ package com.gtnewhorizons.angelica.client.font;
import com.google.common.collect.HashMultiset;
import com.gtnewhorizons.angelica.config.FontConfig;
import com.gtnewhorizons.angelica.mixins.interfaces.ResourceAccessor;
import cpw.mods.fml.client.SplashProgress;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.DefaultResourcePack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -125,4 +127,17 @@ public class FontStrategist {
}
customFontInUse = (FontConfig.enableCustomFont && (primaryFontFound || fallbackFontFound));
}
public static boolean isSplashFontRendererActive(FontRenderer fontRenderer) {
// noinspection deprecation
boolean active = fontRenderer instanceof SplashProgress.SplashFontRenderer;
try {
Class<?> customSplashClass = Class.forName("gkappa.modernsplash.CustomSplash$SplashFontRenderer");
active = active || customSplashClass.isInstance(fontRenderer);
} catch (ClassNotFoundException ignored) {
}
return active;
}
}
@@ -44,7 +44,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import org.joml.Matrix4f;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.lwjgl.BufferUtils;
@@ -141,11 +141,11 @@ public class ShadowRenderer {
public static MatrixStack createShadowModelView(float sunPathRotation, float intervalSize) {
// Determine the camera position
final Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
final double cameraX = cameraPos.x;
final double cameraY = cameraPos.y;
final double cameraZ = cameraPos.z;
final double cameraX = cameraPos.x();
final double cameraY = cameraPos.y();
final double cameraZ = cameraPos.z();
// Set up our modelview matrix stack
final MatrixStack modelView = new MatrixStack();
@@ -461,7 +461,7 @@ public class ShadowRenderer {
MODELVIEW_BUFFER.clear().rewind();
modelView.peek().getModel().get(MODELVIEW_BUFFER);
GL11.glLoadMatrix(MODELVIEW_BUFFER);
for (TileEntity tileEntity : visibleTileEntities) {
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
continue;
@@ -475,10 +475,10 @@ public class ShadowRenderer {
continue;
}
renderTileEntity(tileEntity, cameraX, cameraY, cameraZ, partialTicks);
shadowTileEntities++;
}
GLStateManager.glPopMatrix();
renderedShadowTileEntities = shadowTileEntities;
@@ -530,7 +530,7 @@ public class ShadowRenderer {
terrainFrustumHolder = createShadowFrustum(renderDistanceMultiplier, terrainFrustumHolder);
// Determine the player camera position
final Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
final double cameraX = cameraPos.x();
final double cameraY = cameraPos.y();
@@ -5,6 +5,7 @@ import lombok.Getter;
import net.coderbot.iris.gl.uniform.UniformHolder;
import net.minecraft.client.Minecraft;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.ONCE;
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
@@ -34,7 +35,7 @@ public class CameraUniforms {
return client.gameSettings.renderDistanceChunks * 16;
}
public static Vector3d getUnshiftedCameraPosition() {
public static Vector3dc getUnshiftedCameraPosition() {
return RenderingState.INSTANCE.getCameraPosition();
}
@@ -59,8 +60,8 @@ public class CameraUniforms {
}
private void update() {
previousCameraPosition = currentCameraPosition;
currentCameraPosition = getUnshiftedCameraPosition().add(shift);
previousCameraPosition.set(currentCameraPosition);
currentCameraPosition.set(getUnshiftedCameraPosition()).add(shift);
updateShift();
}
@@ -0,0 +1,96 @@
package com.gtnewhorizons.angelica.glsm;
import com.gtnewhorizon.gtnhlib.client.opengl.UniversalVAO;
import com.gtnewhorizons.angelica.AngelicaExtension;
import com.gtnewhorizons.angelica.util.GLSMUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL30;
import static com.gtnewhorizons.angelica.util.GLSMUtil.verifyState;
@ExtendWith(AngelicaExtension.class)
public class GLSM_VAO_UnitTest {
@Test
void testDefaultStates() {
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, 0, "GL_VERTEX_ARRAY_BINDING Initial State");
verifyState(GL13.GL_CLIENT_ACTIVE_TEXTURE, GL13.GL_TEXTURE0, "GL_CLIENT_ACTIVE_TEXTURE Initial State");
}
@Test
void testVAOPreservesStates() {
boolean vertexStateEnabled = GL11.glIsEnabled(GL11.GL_VERTEX_ARRAY);
// Stride = vertexSize * byte size of the type (= 4 for both GL_FLOAT and GL_INT)
final int defaultVertexSize = 2;
final int defaultVertexType = GL11.GL_FLOAT;
final int defaultVertexStride = defaultVertexSize * 4;
final int vaoVertexSize = 4;
final int vaoVertexType = GL11.GL_INT;
final int vaoVertexStride = vaoVertexSize * 4;
// Set the vertex attrib to a defined state
int vbo = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
GL11.glVertexPointer(defaultVertexSize, defaultVertexType, defaultVertexStride, 0);
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, defaultVertexSize, "GL_VERTEX_ARRAY_SIZE - Setup");
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, defaultVertexType, "GL_VERTEX_ARRAY_TYPE - Setup");
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, defaultVertexStride, "GL_VERTEX_ARRAY_STRIDE - Setup");
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
// Verify VAO & VBO creation
int vao = UniversalVAO.genVertexArrays();
Assertions.assertNotEquals(0, vao, "GL_VERTEX_ARRAY_BINDING - VAO Created");
UniversalVAO.bindVertexArray(vao);
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, vao, "GL_VERTEX_ARRAY_BINDING - Bound");
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
verifyState(GL15.GL_ARRAY_BUFFER_BINDING, vbo, "GL_ARRAY_BUFFER_BINDING - Bound");
// Set & Verify the VAO states
GLSMUtil.setClientState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled);
verifyState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled, "GL_VERTEX_ARRAY - Set");
GL11.glVertexPointer(vaoVertexSize, vaoVertexType, vaoVertexStride, 0);
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, vaoVertexSize, "GL_VERTEX_ARRAY_SIZE - Set");
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, vaoVertexType, "GL_VERTEX_ARRAY_TYPE - Set");
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, vaoVertexStride, "GL_VERTEX_ARRAY_STRIDE - Set");
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
// Check if everything got reset to default
UniversalVAO.bindVertexArray(0);
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, 0, "GL_VERTEX_ARRAY_BINDING - Unbound");
verifyState(GL15.GL_ARRAY_BUFFER_BINDING, 0, "GL_ARRAY_BUFFER_BINDING - Unbound");
verifyState(GL11.GL_VERTEX_ARRAY, vertexStateEnabled, "GL_VERTEX_ARRAY - Reset");
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, defaultVertexSize, "GL_VERTEX_ARRAY_SIZE - Reset");
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, defaultVertexType, "GL_VERTEX_ARRAY_TYPE - Reset");
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, defaultVertexStride, "GL_VERTEX_ARRAY_STRIDE - Reset");
// Check if the VAO states are still valid after re-binding it
UniversalVAO.bindVertexArray(vao);
verifyState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled, "GL_VERTEX_ARRAY - Rebound");
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, vaoVertexSize, "GL_VERTEX_ARRAY_SIZE - Rebound");
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, vaoVertexType, "GL_VERTEX_ARRAY_TYPE - Rebound");
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, vaoVertexStride, "GL_VERTEX_ARRAY_STRIDE - Rebound");
UniversalVAO.bindVertexArray(0);
GL15.glDeleteBuffers(vbo);
UniversalVAO.deleteVertexArrays(vao);
}
}
@@ -254,4 +254,13 @@ public class GLSMUtil {
// Reset draw buffer
GLStateManager.glDrawBuffer(GLStateManager.DEFAULT_DRAW_BUFFER);
}
public static void setClientState(int glCap, boolean state) {
if (state) {
GL11.glEnableClientState(glCap);
} else {
GL11.glDisableClientState(glCap);
}
}
}