Use GLSM instead of relying on the redirector

This commit is contained in:
Jason Mitchell authored and Jason Mitchell committed 2026-03-21 10:56:19 -07:00
1 parent 70cfa2ae90
commit 5f61e387fb
84 files changed
+628 -1140

No files matched your search

@@ -1,5 +1,6 @@
package net.coderbot.iris.gl.buffer;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.lwjgl.opengl.GL11;
@@ -40,8 +41,8 @@ public class ShaderStorageBuffer {
if (!info.relative()) return;
RenderSystem.deleteBuffers(id);
int newId = GL15.glGenBuffers();
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, newId);
int newId = GLStateManager.glGenBuffers();
GLStateManager.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, newId);
// Calculation time
int newWidth = (int) (width * info.scaleX());
@@ -1,5 +1,6 @@
package net.coderbot.iris.gl.buffer;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import net.coderbot.iris.gl.sampler.SamplerLimits;
@@ -36,13 +37,13 @@ public class ShaderStorageBufferHolder {
if (bufferInfo.relative()) {
buffers[index].resizeIfRelative(width, height);
} else {
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, buffer);
GLStateManager.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, buffer);
RenderSystem.bufferStorage(GL43.GL_SHADER_STORAGE_BUFFER, bufferInfo.size(), 0);
RenderSystem.clearBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, GL30.GL_R8, 0, bufferInfo.size(), GL11.GL_RED, GL11.GL_BYTE, new int[]{0});
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, buffer);
}
});
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
GLStateManager.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
private static long toMib(long x) {
@@ -3,6 +3,7 @@ package net.coderbot.iris.gl.framebuffer;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
@@ -10,7 +11,6 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
import java.nio.IntBuffer;
import net.coderbot.iris.gl.GlResource;
import net.coderbot.iris.gl.texture.DepthBufferFormat;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
@@ -25,8 +25,8 @@ public class GlFramebuffer extends GlResource {
super(RenderSystem.createFramebuffer());
this.attachments = new Int2IntArrayMap();
this.maxDrawBuffers = GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
this.maxColorAttachments = GL11.glGetInteger(GL30.GL_MAX_COLOR_ATTACHMENTS);
this.maxDrawBuffers = GLStateManager.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
this.maxColorAttachments = GLStateManager.glGetInteger(GL30.GL_MAX_COLOR_ATTACHMENTS);
this.hasDepthAttachment = false;
}
@@ -91,26 +91,26 @@ public class GlFramebuffer extends GlResource {
}
public void bind() {
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, getGlId());
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, getGlId());
}
public void bindAsReadBuffer() {
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_READ_FRAMEBUFFER, getGlId());
GLStateManager.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, getGlId());
}
public void bindAsDrawBuffer() {
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_DRAW_FRAMEBUFFER, getGlId());
GLStateManager.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, getGlId());
}
@Override
protected void destroyInternal() {
OpenGlHelper.func_153174_h/*glDeleteFramebuffers*/(getGlId());
GLStateManager.glDeleteFramebuffers(getGlId());
}
public boolean isComplete() {
bind();
return OpenGlHelper.func_153167_i/*glCheckFramebufferStatus*/(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE;
return GLStateManager.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE;
}
public int getId() {
@@ -9,7 +9,7 @@ import net.coderbot.iris.shaderpack.FilledIndirectPointer;
import org.joml.Vector2f;
import org.joml.Vector3i;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.opengl.GL42;
import org.lwjgl.opengl.GL43;
@@ -65,7 +65,7 @@ public final class ComputeProgram extends GlResource {
}
public void use() {
GL20.glUseProgram(getGlId());
GLStateManager.glUseProgram(getGlId());
uniforms.update();
samplers.update();
@@ -87,13 +87,13 @@ public final class ComputeProgram extends GlResource {
public static void unbind() {
ProgramUniforms.clearActiveUniforms();
GL20.glUseProgram(0);
GLStateManager.glUseProgram(0);
}
@Override
public void destroyInternal() {
DepthColorStorage.unregisterOwnedProgram(getGlId());
GL20.glDeleteProgram(getGlId());
GLStateManager.glDeleteProgram(getGlId());
}
/**
@@ -2,7 +2,7 @@ package net.coderbot.iris.gl.program;
import net.coderbot.iris.gl.GlResource;
import net.coderbot.iris.gl.blending.DepthColorStorage;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
public final class Program extends GlResource {
private final ProgramUniforms uniforms;
@@ -20,7 +20,7 @@ public final class Program extends GlResource {
}
public void use() {
GL20.glUseProgram(getGlId());
GLStateManager.glUseProgram(getGlId());
uniforms.update();
samplers.update();
@@ -30,13 +30,13 @@ public final class Program extends GlResource {
public static void unbind() {
ProgramUniforms.clearActiveUniforms();
ProgramSamplers.clearActiveSamplers();
GL20.glUseProgram(0);
GLStateManager.glUseProgram(0);
}
@Override
public void destroyInternal() {
DepthColorStorage.unregisterOwnedProgram(getGlId());
GL20.glDeleteProgram(getGlId());
GLStateManager.glDeleteProgram(getGlId());
}
/**
@@ -6,7 +6,7 @@ import net.coderbot.iris.gl.image.ImageBinding;
import net.coderbot.iris.gl.image.ImageHolder;
import net.coderbot.iris.gl.image.ImageLimits;
import net.coderbot.iris.gl.texture.InternalTextureFormat;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.ArrayList;
import java.util.List;
@@ -60,12 +60,12 @@ public class ProgramImages {
@Override
public boolean hasImage(String name) {
return GL20.glGetUniformLocation(program, name) != -1;
return GLStateManager.glGetUniformLocation(program, name) != -1;
}
@Override
public void addTextureImage(IntSupplier textureID, InternalTextureFormat internalFormat, String name) {
int location = GL20.glGetUniformLocation(program, name);
int location = GLStateManager.glGetUniformLocation(program, name);
if (location == -1) {
return;
@@ -1,5 +1,6 @@
package net.coderbot.iris.gl.sampler;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
@@ -12,9 +13,9 @@ public class SamplerLimits {
private final int maxShaderStorageUnits;
private SamplerLimits() {
this.maxTextureUnits = GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS);
this.maxDrawBuffers = GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
this.maxShaderStorageUnits = RenderSystem.supportsSSBO() ? GL11.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS) : 0;
this.maxTextureUnits = GLStateManager.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS);
this.maxDrawBuffers = GLStateManager.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
this.maxShaderStorageUnits = RenderSystem.supportsSSBO() ? GLStateManager.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS) : 0;
}
public static SamplerLimits get() {
@@ -3,6 +3,7 @@
package net.coderbot.iris.gl.shader;
import com.gtnewhorizons.angelica.glsm.GLDebug;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import net.coderbot.iris.gl.GlResource;
import org.apache.logging.log4j.LogManager;
@@ -28,12 +29,12 @@ public class GlShader extends GlResource {
}
private static int createShader(ShaderType type, String name, String src) {
int handle = GL20.glCreateShader(type.id);
int handle = GLStateManager.glCreateShader(type.id);
// TODO: Iris
// ShaderWorkarounds.safeShaderSource(handle, src);
// TODO: ShaderWorkaround
GL20.glShaderSource(handle, src + '\0');
GL20.glCompileShader(handle);
GLStateManager.glShaderSource(handle, src + '\0');
GLStateManager.glCompileShader(handle);
GLDebug.nameObject(KHRDebug.GL_SHADER, handle, name + "(" + type.name().toLowerCase(Locale.ROOT) + ")");
@@ -43,7 +44,7 @@ public class GlShader extends GlResource {
LOGGER.warn("Shader compilation log for " + name + ": " + log);
}
int result = GL20.glGetShaderi(handle, GL20.GL_COMPILE_STATUS);
int result = GLStateManager.glGetShaderi(handle, GL20.GL_COMPILE_STATUS);
if (result != GL11.GL_TRUE) {
throw new RuntimeException("Shader compilation failed, see log for details");
@@ -62,6 +63,6 @@ public class GlShader extends GlResource {
@Override
protected void destroyInternal() {
GL20.glDeleteShader(this.getGlId());
GLStateManager.glDeleteShader(this.getGlId());
}
}
@@ -3,6 +3,7 @@
package net.coderbot.iris.gl.shader;
import com.gtnewhorizons.angelica.glsm.GLDebug;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,7 +21,7 @@ public class ProgramCreator {
public static final int AT_MIDBLOCK = 14;
public static int create(String name, GlShader... shaders) {
int program = GL20.glCreateProgram();
int program = GLStateManager.glCreateProgram();
// TODO: This is *really* hardcoded, we need to refactor this to support external calls to glBindAttribLocation
RenderSystem.bindAttributeLocation(program, MC_ENTITY, "mc_Entity");
@@ -29,10 +30,10 @@ public class ProgramCreator {
RenderSystem.bindAttributeLocation(program, AT_MIDBLOCK, "at_midBlock");
for (GlShader shader : shaders) {
GL20.glAttachShader(program, shader.getHandle());
GLStateManager.glAttachShader(program, shader.getHandle());
}
GL20.glLinkProgram(program);
GLStateManager.glLinkProgram(program);
GLDebug.nameObject(KHRDebug.GL_PROGRAM, program, name);
@@ -47,7 +48,7 @@ public class ProgramCreator {
LOGGER.warn("Program link log for " + name + ": " + log);
}
int result = GL20.glGetProgrami(program, GL20.GL_LINK_STATUS);
int result = GLStateManager.glGetProgrami(program, GL20.GL_LINK_STATUS);
if (result != GL11.GL_TRUE) {
throw new RuntimeException("Shader program linking failed, see log for details");
@@ -12,6 +12,7 @@ import net.coderbot.iris.texture.format.TextureFormat;
import net.coderbot.iris.texture.format.TextureFormatLoader;
import net.coderbot.iris.uniforms.VanillaBiomeList;
import net.minecraft.world.biome.BiomeGenBase;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
@@ -146,7 +147,7 @@ public class StandardMacros {
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L705-L707">Optifine Doc for GLSL Version</a>
*/
public static String getGlVersion(int name) {
final String info = GL11.glGetString(name);
final String info = GLStateManager.glGetString(name);
Matcher matcher = SEMVER_PATTERN.matcher(Objects.requireNonNull(info));
@@ -208,7 +209,7 @@ public class StandardMacros {
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L716-L723">Optifine Doc</a>
*/
public static String getVendor() {
String vendor = Objects.requireNonNull(GL11.glGetString(GL11.GL_VENDOR)).toLowerCase(Locale.ROOT);
String vendor = Objects.requireNonNull(GLStateManager.glGetString(GL11.GL_VENDOR)).toLowerCase(Locale.ROOT);
if (vendor.startsWith("ati")) {
return "MC_GL_VENDOR_ATI";
} else if (vendor.startsWith("intel")) {
@@ -230,7 +231,7 @@ public class StandardMacros {
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L725-L733">Optifine Doc</a>
*/
public static String getRenderer() {
String renderer = Objects.requireNonNull(GL11.glGetString(GL11.GL_RENDERER)).toLowerCase(Locale.ROOT);
String renderer = Objects.requireNonNull(GLStateManager.glGetString(GL11.GL_RENDERER)).toLowerCase(Locale.ROOT);
if (renderer.startsWith("amd")) {
return "MC_GL_RENDERER_RADEON";
} else if (renderer.startsWith("ati")) {
@@ -263,10 +264,10 @@ public class StandardMacros {
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L735-L738">Optifine Doc</a>
*/
public static Set<String> getGlExtensions() {
int numExtensions = GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS);
int numExtensions = GLStateManager.glGetInteger(GL30.GL_NUM_EXTENSIONS);
String[] extensions = new String[numExtensions];
for (int i = 0; i < numExtensions; i++) {
extensions[i] = GL30.glGetStringi(GL11.GL_EXTENSIONS, i);
extensions[i] = GLStateManager.glGetStringi(GL11.GL_EXTENSIONS, i);
}
// TODO note that we do not add extensions based on if the shader uses them and if they are supported
@@ -4,7 +4,6 @@ import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL43;
public interface DepthCopyStrategy {
// FB -> T
@@ -73,7 +72,7 @@ public interface DepthCopyStrategy {
@Override
public void copy(GlFramebuffer sourceFb, int sourceTexture, GlFramebuffer destFb, int destTexture, int width, int height) {
GL43.glCopyImageSubData(sourceTexture, GL11.GL_TEXTURE_2D, 0, 0, 0, 0, destTexture, GL11.GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1);
GLStateManager.glCopyImageSubData(sourceTexture, GL11.GL_TEXTURE_2D, 0, 0, 0, 0, destTexture, GL11.GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1);
}
}
@@ -18,7 +18,7 @@ public class GlTexture extends GlObject implements TextureAccess {
private final TextureType target;
public GlTexture(TextureType target, int sizeX, int sizeY, int sizeZ, int internalFormat, int format, int pixelType, byte[] pixels, TextureFilteringData filteringData) {
this.setHandle(GL11.glGenTextures());
this.setHandle(GLStateManager.glGenTextures());
bindTextureForSetup(target.getGlType(), handle());
TextureUploadHelper.resetTextureUploadState();
@@ -1,5 +1,6 @@
package net.coderbot.iris.gl.texture;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.opengl.GL11;
public class TextureUploadHelper {
@@ -14,9 +15,9 @@ public class TextureUploadHelper {
// It is likely that this also avoids the crashes on AMD that I previously experienced with texture creation.
//
// This code is from Canvas: https://github.com/grondag/canvas/commit/f0ab652d7a8b7cc9febf0209bee15cffce9eac83
GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0);
GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0);
GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
GLStateManager.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0);
GLStateManager.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0);
GLStateManager.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0);
GLStateManager.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
}
}
@@ -2,10 +2,10 @@ package net.coderbot.iris.layer;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.coderbot.iris.gl.shader.ProgramCreator;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import org.lwjgl.opengl.GL20;
public class GbufferPrograms {
private static boolean entities;
@@ -67,10 +67,10 @@ public class GbufferPrograms {
}
public static void setBlockEntityDefaults() {
GL20.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
GL20.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
GL20.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
GL20.glVertexAttrib4f(ProgramCreator.AT_MIDBLOCK, 0.0f, 0.0f, 0.0f, 0.0f);
GLStateManager.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
GLStateManager.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
GLStateManager.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
GLStateManager.glVertexAttrib4f(ProgramCreator.AT_MIDBLOCK, 0.0f, 0.0f, 0.0f, 0.0f);
}
public static WorldRenderingPhase getCurrentPhase() {
@@ -37,7 +37,7 @@ public class ClearPass {
GLStateManager.glClearColor(color.x, color.y, color.z, color.w);
GLStateManager.glClear(clearFlags);
if (Minecraft.isRunningOnMac) {
GL11.glGetError();
GLStateManager.glGetError();
}
}
@@ -10,6 +10,7 @@ import net.coderbot.iris.shaderpack.PackShadowDirectives;
import net.coderbot.iris.shadows.ShadowRenderTargets;
import org.joml.Vector2i;
import org.joml.Vector4f;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
@@ -21,7 +22,7 @@ import java.util.Map;
public class ClearPassCreator {
public static ImmutableList<ClearPass> createClearPasses(RenderTargets renderTargets, boolean fullClear,
PackRenderTargetDirectives renderTargetDirectives) {
final int maxDrawBuffers = GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
final int maxDrawBuffers = GLStateManager.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
// Sort buffers by their clear color so we can group up glClear calls.
Map<Vector2i, Map<ClearPassInformation, IntList>> clearByColor = new HashMap<>();
@@ -81,7 +82,7 @@ public class ClearPassCreator {
public static ImmutableList<ClearPass> createShadowClearPasses(ShadowRenderTargets renderTargets, boolean fullClear,
PackShadowDirectives renderTargetDirectives) {
final int maxDrawBuffers = GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
final int maxDrawBuffers = GLStateManager.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
// Sort buffers by their clear color so we can group up glClear calls.
Map<Vector4f, IntList> clearByColor = new HashMap<>();
@@ -164,7 +164,7 @@ public class CustomTextureManager {
final TextureFormat textureFormat = TextureFormatLoader.getFormat();
if (textureFormat != null) {
final int previousBinding = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
final int previousBinding = GLStateManager.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, pbrTexture.getGlTextureId());
textureFormat.setupTextureParameters(pbrType, pbrTexture);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousBinding);
@@ -1134,7 +1134,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
shadowRenderTargets.getDepthSourceFb().bind();
GLStateManager.glClear(GL11.GL_DEPTH_BUFFER_BIT);
if (Minecraft.isRunningOnMac) {
GL11.glGetError();
GLStateManager.glGetError();
}
@@ -31,8 +31,8 @@ public class CenterDepthSampler {
private boolean destroyed;
public CenterDepthSampler(IntSupplier depthSupplier, float halfLife) {
this.texture = GL11.glGenTextures();
this.altTexture = GL11.glGenTextures();
this.texture = GLStateManager.glGenTextures();
this.altTexture = GLStateManager.glGenTextures();
this.framebuffer = new GlFramebuffer();
// Fall back to a less precise format if the system doesn't support OpenGL 3
@@ -36,7 +36,6 @@ import net.coderbot.iris.uniforms.CommonUniforms;
import net.coderbot.iris.uniforms.FrameUpdateNotifier;
import net.coderbot.iris.uniforms.custom.CustomUniforms;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11;
@@ -144,7 +143,7 @@ public class FinalPassRenderer {
this.swapPasses = swapPasses.build();
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_READ_FRAMEBUFFER, 0);
GLStateManager.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, 0);
}
private static Map<PatchShaderType, String> getTransformed(ProgramSource source, CompletableFuture<Map<PatchShaderType, String>> precomputedTransformFuture, String stageName) {
@@ -276,7 +275,7 @@ public class FinalPassRenderer {
swapPass.from.bind();
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, swapPass.targetTexture);
GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, swapPass.width, swapPass.height);
GLStateManager.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, swapPass.width, swapPass.height);
}
// Make sure to reset the viewport to how it was before... Otherwise weird issues could occur.
@@ -22,12 +22,12 @@ public class FullScreenQuadRenderer {
public static final FullScreenQuadRenderer INSTANCE = new FullScreenQuadRenderer();
private FullScreenQuadRenderer() {
this.vao = org.lwjgl.opengl.GL30.glGenVertexArrays();
this.vao = GLStateManager.glGenVertexArrays();
GLStateManager.glBindVertexArray(vao);
this.quadBuffer = createQuad();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, quadBuffer);
GLStateManager.glBindBuffer(GL15.GL_ARRAY_BUFFER, quadBuffer);
DefaultVertexFormat.POSITION_TEXTURE.setupBufferState(0L);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GLStateManager.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GLStateManager.glBindVertexArray(0);
}
@@ -79,14 +79,14 @@ public class FullScreenQuadRenderer {
private static final Int2ObjectOpenHashMap<int[]> compositeLocCache = new Int2ObjectOpenHashMap<>();
public static void uploadCompositeMatrices() {
final int program = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
final int program = GLStateManager.glGetInteger(GL20.GL_CURRENT_PROGRAM);
if (program == 0) return;
int[] locs = compositeLocCache.get(program);
if (locs == null) {
locs = new int[] {
GL20.glGetUniformLocation(program, "iris_ModelViewMatrix"),
GL20.glGetUniformLocation(program, "iris_ProjectionMatrix")
GLStateManager.glGetUniformLocation(program, "iris_ModelViewMatrix"),
GLStateManager.glGetUniformLocation(program, "iris_ProjectionMatrix")
};
compositeLocCache.put(program, locs);
}
@@ -94,13 +94,13 @@ public class FullScreenQuadRenderer {
if (locs[0] != -1) {
GLStateManager.getModelViewMatrix().get(matBuf);
matBuf.rewind();
GL20.glUniformMatrix4(locs[0], false, matBuf);
GLStateManager.glUniformMatrix4(locs[0], false, matBuf);
}
if (locs[1] != -1) {
GLStateManager.getProjectionMatrix().get(matBuf);
matBuf.rewind();
GL20.glUniformMatrix4(locs[1], false, matBuf);
GLStateManager.glUniformMatrix4(locs[1], false, matBuf);
}
}
@@ -4,9 +4,9 @@ import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import net.coderbot.iris.gl.GlResource;
import net.coderbot.iris.gl.texture.TextureUploadHelper;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL30;
import java.nio.ByteBuffer;
@@ -23,7 +23,7 @@ public class ColorTexture extends GlResource {
TextureUploadHelper.resetTextureUploadState();
RenderSystem.texImage2D(texture, GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (ByteBuffer) null);
EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, texture, 0);
GLStateManager.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
}
public int getTextureId() {
@@ -1,6 +1,7 @@
package net.coderbot.iris.rendertarget;
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import org.lwjgl.opengl.GL11;
@@ -28,8 +29,8 @@ public class NativeImageBackedNoiseTexture extends DynamicTexture {
@Override
public void updateDynamicTexture() {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
super.updateDynamicTexture();
}
@@ -46,7 +46,7 @@ public class NoiseTexture extends GlResource {
TextureUploadHelper.resetTextureUploadState();
// Since we're using tightly-packed RGB data, we must use an alignment of 1 byte instead of the usual 4 bytes.
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
GLStateManager.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
RenderSystem.texImage2D(texture, GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, pixels);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, 0);
@@ -45,7 +45,7 @@ public class RenderTarget {
try (MemoryStack stack = stackPush()) {
IntBuffer textures = stack.mallocInt(2);
GL11.glGenTextures(textures);
GLStateManager.glGenTextures(textures);
this.mainTexture = textures.get(0);
this.altTexture = textures.get(1);
@@ -77,7 +77,7 @@ public class PBRTextureManager {
Class<? extends AbstractTexture> clazz = texture.getClass();
PBRTextureLoader loader = PBRTextureLoaderRegistry.INSTANCE.getLoader(clazz);
if (loader != null) {
int previousTextureBinding = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
int previousTextureBinding = GLStateManager.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
consumer.clear();
try {
loader.load(texture, Minecraft.getMinecraft().getResourceManager(), consumer);
@@ -21,12 +21,12 @@ public class TextureManipulationUtil {
colorFillFBO = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
}
final int previousFramebufferId = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
final int previousFramebufferId = GLStateManager.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
final FloatBuffer previousClearColorBuffer = stack.mallocFloat(4);
GL11.glGetFloat(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
final int previousTextureId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GLStateManager.glGetFloat(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
final int previousTextureId = GLStateManager.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
final IntBuffer previousViewportBuffer = stack.mallocInt(4);
GL11.glGetInteger(GL11.GL_VIEWPORT, previousViewportBuffer);
GLStateManager.glGetInteger(GL11.GL_VIEWPORT, previousViewportBuffer);
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, colorFillFBO);
GLStateManager.glClearColor(
@@ -36,10 +36,10 @@ public class TextureManipulationUtil {
(rgba & 0xFF) / 255.0f);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
for (int level = 0; level <= maxLevel; ++level) {
final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
final int width = GLStateManager.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
final int height = GLStateManager.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
GLStateManager.glViewport(0, 0, width, height);
GL30.glFramebufferTexture2D(
GLStateManager.glFramebufferTexture2D(
GL30.GL_FRAMEBUFFER,
GL30.GL_COLOR_ATTACHMENT0,
GL11.GL_TEXTURE_2D,
@@ -47,10 +47,10 @@ public class TextureManipulationUtil {
level);
GLStateManager.glClear(GL11.GL_COLOR_BUFFER_BIT);
if (Minecraft.isRunningOnMac) {
GL11.glGetError();
GLStateManager.glGetError();
}
GL30.glFramebufferTexture2D(
GLStateManager.glFramebufferTexture2D(
GL30.GL_FRAMEBUFFER,
GL30.GL_COLOR_ATTACHMENT0,
GL11.GL_TEXTURE_2D,
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import kroppeb.stareval.function.FunctionReturn;
import kroppeb.stareval.function.Type;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.BooleanSupplier;
@@ -26,7 +26,7 @@ public class BooleanCachedUniform extends CachedUniform {
@Override
public void push(int location) {
GL20.glUniform1i(location, this.cached ? 1 : 0);
GLStateManager.glUniform1i(location, this.cached ? 1 : 0);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.VectorType;
import org.joml.Vector2f;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.Supplier;
@@ -20,7 +20,7 @@ public class Float2VectorCachedUniform extends VectorCachedUniform<Vector2f> {
@Override
public void push(int location) {
GL20.glUniform2f(location, this.cached.x, this.cached.y);
GLStateManager.glUniform2f(location, this.cached.x, this.cached.y);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.VectorType;
import org.joml.Vector3f;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.Supplier;
@@ -20,7 +20,7 @@ public class Float3VectorCachedUniform extends VectorCachedUniform<Vector3f> {
@Override
public void push(int location) {
GL20.glUniform3f(location, this.cached.x, this.cached.y, this.cached.z);
GLStateManager.glUniform3f(location, this.cached.x, this.cached.y, this.cached.z);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.MatrixType;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -26,7 +26,7 @@ public class Float4MatrixCachedUniform extends VectorCachedUniform<Matrix4f> {
public void push(int location) {
// `gets` the values from the matrix and put's them into a buffer
this.cached.get(buffer);
GL20.glUniformMatrix4(location, false, buffer);
GLStateManager.glUniformMatrix4(location, false, buffer);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.VectorType;
import org.joml.Vector4f;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.Supplier;
@@ -20,7 +20,7 @@ public class Float4VectorCachedUniform extends VectorCachedUniform<Vector4f> {
@Override
public void push(int location) {
GL20.glUniform4f(location, this.cached.x, this.cached.y, this.cached.z, this.cached.w);
GLStateManager.glUniform4f(location, this.cached.x, this.cached.y, this.cached.z, this.cached.w);
}
@Override
@@ -4,7 +4,7 @@ import kroppeb.stareval.function.FunctionReturn;
import kroppeb.stareval.function.Type;
import net.coderbot.iris.gl.uniform.FloatSupplier;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
public class FloatCachedUniform extends CachedUniform {
@@ -25,7 +25,7 @@ public class FloatCachedUniform extends CachedUniform {
@Override
public void push(int location) {
GL20.glUniform1f(location, this.cached);
GLStateManager.glUniform1f(location, this.cached);
}
@Override
@@ -4,7 +4,7 @@ import kroppeb.stareval.function.FunctionReturn;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.VectorType;
import org.joml.Vector2i;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.Supplier;
@@ -21,7 +21,7 @@ public class Int2VectorCachedUniform extends VectorCachedUniform<Vector2i> {
@Override
public void push(int location) {
GL20.glUniform2i(location, this.cached.x, this.cached.y);
GLStateManager.glUniform2i(location, this.cached.x, this.cached.y);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import net.coderbot.iris.parsing.VectorType;
import org.joml.Vector3i;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.Supplier;
@@ -20,7 +20,7 @@ public class Int3VectorCachedUniform extends VectorCachedUniform<Vector3i> {
@Override
public void push(int location) {
GL20.glUniform3i(location, this.cached.x, this.cached.y, this.cached.z);
GLStateManager.glUniform3i(location, this.cached.x, this.cached.y, this.cached.z);
}
@Override
@@ -3,7 +3,7 @@ package net.coderbot.iris.uniforms.custom.cached;
import kroppeb.stareval.function.FunctionReturn;
import kroppeb.stareval.function.Type;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import org.lwjgl.opengl.GL20;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import java.util.function.IntSupplier;
@@ -26,7 +26,7 @@ public class IntCachedUniform extends CachedUniform {
@Override
public void push(int location) {
GL20.glUniform1i(location, this.cached);
GLStateManager.glUniform1i(location, this.cached);
}
@Override