Common and version specific shader packages #10

Merged
embeddedt merged 24 commits from mitchej123/celeritas:common-shaders-and-enhancements into stonecutter 2025-03-31 19:52:28 -04:00
4 changed files with 51 additions and 21 deletions
Showing only changes of commit 3402f0baf0 - Show all commits

No files matched your search

@@ -1,5 +1,8 @@
package com.mitchej123.glsm; package com.mitchej123.glsm;
import net.irisshaders.iris.gl.blending.BlendMode;
import net.irisshaders.iris.gl.blending.ColorMask;
import java.util.ServiceLoader; import java.util.ServiceLoader;
public interface GLStateManagerService { public interface GLStateManagerService {
@@ -52,8 +55,6 @@ public interface GLStateManagerService {
void glClearColor(float red, float green, float blue, float alpha); void glClearColor(float red, float green, float blue, float alpha);
void clear(int mask, boolean checkError); // Non-standard
int glGetTexLevelParameteri(int target, int level, int pname); int glGetTexLevelParameteri(int target, int level, int pname);
void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level); void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level);
@@ -62,13 +63,23 @@ public interface GLStateManagerService {
void glGenTextures(int[] textures); void glGenTextures(int[] textures);
void glDeleteTextures(int texture); void glDeleteTextures(int texture);
void glDeleteTextures(int[] textures); void glDeleteTextures(int[] textures);
void bindTexture(int texture); // Non-standard
void glActiveTexture(int texture); void glActiveTexture(int texture);
int getActiveTexture(); // Non-standard
int glGenBuffers(); int glGenBuffers();
void glBindBuffer(int target, int buffer); void glBindBuffer(int target, int buffer);
void glPixelStorei(int pname, int param); void glPixelStorei(int pname, int param);
// Mojang & Non-Standard
void clear(int mask, boolean checkError); // Non-standard signature
void bindTexture(int texture); // Non-standard signature
int getActiveTexture(); // Mojang Addition
boolean getDepthStateMask();
boolean isBlendEnabled();
BlendMode getBlendMode();
ColorMask getColorMask();
} }
@@ -2,9 +2,6 @@ package net.irisshaders.iris.gl.blending;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import com.mojang.blaze3d.platform.GlStateManager;
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
public class DepthColorStorage { public class DepthColorStorage {
private static boolean originalDepthEnable; private static boolean originalDepthEnable;
private static ColorMask originalColor; private static ColorMask originalColor;
@@ -17,11 +14,9 @@ public class DepthColorStorage {
public static void disableDepthColor() { public static void disableDepthColor() {
if (!depthColorLocked) { if (!depthColorLocked) {
// Only save the previous state if the depth and color mask wasn't already locked // Only save the previous state if the depth and color mask wasn't already locked
GlStateManager.ColorMask colorMask = GlStateManagerAccessor.getCOLOR_MASK();
GlStateManager.DepthState depthState = GlStateManagerAccessor.getDEPTH();
originalDepthEnable = depthState.mask; originalDepthEnable = GL_STATE_MANAGER.getDepthStateMask();
originalColor = new ColorMask(colorMask.red, colorMask.green, colorMask.blue, colorMask.alpha); originalColor = GL_STATE_MANAGER.getColorMask();
} }
depthColorLocked = false; depthColorLocked = false;
@@ -2,10 +2,7 @@ package net.irisshaders.iris.gl.blending;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import com.mojang.blaze3d.platform.GlStateManager;
import net.irisshaders.iris.gl.IrisRenderSystem; import net.irisshaders.iris.gl.IrisRenderSystem;
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
import net.irisshaders.iris.mixin.statelisteners.BooleanStateAccessor;
public class BlendModeStorage { public class BlendModeStorage {
private static boolean originalBlendEnable; private static boolean originalBlendEnable;
@@ -19,10 +16,9 @@ public class BlendModeStorage {
public static void overrideBlend(BlendMode override) { public static void overrideBlend(BlendMode override) {
if (!blendLocked) { if (!blendLocked) {
// Only save the previous state if the blend mode wasn't already locked // Only save the previous state if the blend mode wasn't already locked
GlStateManager.BlendState blendState = GlStateManagerAccessor.getBLEND();
originalBlendEnable = ((BooleanStateAccessor) blendState.mode).isEnabled(); originalBlendEnable = GL_STATE_MANAGER.isBlendEnabled();
originalBlend = new BlendMode(blendState.srcRgb, blendState.dstRgb, blendState.srcAlpha, blendState.dstAlpha); originalBlend = GL_STATE_MANAGER.getBlendMode();
} }
blendLocked = false; blendLocked = false;
@@ -40,10 +36,8 @@ public class BlendModeStorage {
public static void overrideBufferBlend(int index, BlendMode override) { public static void overrideBufferBlend(int index, BlendMode override) {
if (!blendLocked) { if (!blendLocked) {
// Only save the previous state if the blend mode wasn't already locked // Only save the previous state if the blend mode wasn't already locked
GlStateManager.BlendState blendState = GlStateManagerAccessor.getBLEND(); originalBlendEnable = GL_STATE_MANAGER.isBlendEnabled();
originalBlend = GL_STATE_MANAGER.getBlendMode();
originalBlendEnable = ((BooleanStateAccessor) blendState.mode).isEnabled();
originalBlend = new BlendMode(blendState.srcRgb, blendState.dstRgb, blendState.srcAlpha, blendState.dstAlpha);
} }
if (override == null) { if (override == null) {
@@ -2,6 +2,10 @@ package org.embeddedt.embeddium.impl.gl;
import com.mitchej123.glsm.GLStateManagerService; import com.mitchej123.glsm.GLStateManagerService;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.irisshaders.iris.gl.blending.BlendMode;
import net.irisshaders.iris.gl.blending.ColorMask;
import net.irisshaders.iris.mixin.GlStateManagerAccessor;
import net.irisshaders.iris.mixin.statelisteners.BooleanStateAccessor;
public class GLStateManagerImpl implements GLStateManagerService { public class GLStateManagerImpl implements GLStateManagerService {
@Override @Override
@@ -244,4 +248,30 @@ public class GLStateManagerImpl implements GLStateManagerService {
GlStateManager._pixelStore(pname, param); GlStateManager._pixelStore(pname, param);
} }
@Override
public boolean getDepthStateMask() {
return GlStateManagerAccessor.getDEPTH().mask;
}
@Override
public boolean isBlendEnabled() {
GlStateManager.BlendState blendState = GlStateManagerAccessor.getBLEND();
return ((BooleanStateAccessor)blendState.mode).isEnabled();
}
@Override
public BlendMode getBlendMode() {
GlStateManager.BlendState blendState = GlStateManagerAccessor.getBLEND();
return new BlendMode(blendState.srcRgb, blendState.dstRgb, blendState.srcAlpha, blendState.dstAlpha);
}
@Override
public ColorMask getColorMask() {
GlStateManager.ColorMask colorMask = GlStateManagerAccessor.getCOLOR_MASK();
return new ColorMask(colorMask.red, colorMask.green, colorMask.blue, colorMask.alpha);
}
} }