merge-stonecutter #16
No files matched your search
@@ -9,12 +9,12 @@ import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gl.image.ImageHolder;
|
||||
import net.irisshaders.iris.gl.sampler.GlSampler;
|
||||
import net.irisshaders.iris.gl.sampler.SamplerHolder;
|
||||
import net.irisshaders.iris.gl.shader.GlShader;
|
||||
import net.irisshaders.iris.gl.shader.ProgramCreator;
|
||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||
import net.irisshaders.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.irisshaders.iris.gl.texture.InternalTextureFormat;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlShader;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
// This file is based on code from Sodium by JellySquid, licensed under the LGPLv3 license.
|
||||
|
||||
package net.irisshaders.iris.gl.shader;
|
||||
|
||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A compiled OpenGL shader object.
|
||||
*/
|
||||
public class GlShader extends GlObject {
|
||||
private static final Logger LOGGER = LogManager.getLogger(GlShader.class);
|
||||
|
||||
private final String name;
|
||||
|
||||
public GlShader(ShaderType type, String name, String src) {
|
||||
this.setHandle(createShader(type, name, src));
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static int createShader(ShaderType type, String name, String src) {
|
||||
int handle = GL_STATE_MANAGER.glCreateShader(type.id);
|
||||
ShaderWorkarounds.safeShaderSource(handle, src);
|
||||
GL_STATE_MANAGER.glCompileShader(handle);
|
||||
|
||||
GLDebug.nameObject(KHRDebug.GL_SHADER, handle, name + "(" + type.name().toLowerCase(Locale.ROOT) + ")");
|
||||
|
||||
String log = IrisRenderSystem.getShaderInfoLog(handle);
|
||||
|
||||
if (!log.isEmpty()) {
|
||||
LOGGER.warn("Shader compilation log for " + name + ": " + log);
|
||||
}
|
||||
|
||||
int result = GL_STATE_MANAGER.glGetShaderi(handle, GL20C.GL_COMPILE_STATUS);
|
||||
|
||||
if (result != GL20C.GL_TRUE) {
|
||||
throw new ShaderCompileException(name, log);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getHandle() {
|
||||
return this.handle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
GL_STATE_MANAGER.glDeleteShader(this.handle());
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlShader;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
|
||||
public class ProgramCreator {
|
||||
@@ -25,9 +27,9 @@ public class ProgramCreator {
|
||||
GL_STATE_MANAGER.glBindAttribLocation(program, 1, "UV0");
|
||||
|
||||
for (GlShader shader : shaders) {
|
||||
// GLDebug.nameObject(KHRDebug.GL_SHADER, shader.getHandle(), shader.getName());
|
||||
GLDebug.nameObject(KHRDebug.GL_SHADER, shader.handle(), shader.getName());
|
||||
|
||||
GL_STATE_MANAGER.glAttachShader(program, shader.getHandle());
|
||||
GL_STATE_MANAGER.glAttachShader(program, shader.handle());
|
||||
}
|
||||
|
||||
GL_STATE_MANAGER.glLinkProgram(program);
|
||||
@@ -36,7 +38,7 @@ public class ProgramCreator {
|
||||
|
||||
//Always detach shaders according to https://www.khronos.org/opengl/wiki/Shader_Compilation#Cleanup
|
||||
for (GlShader shader : shaders) {
|
||||
IrisRenderSystem.detachShader(program, shader.getHandle());
|
||||
IrisRenderSystem.detachShader(program, shader.handle());
|
||||
}
|
||||
|
||||
String log = IrisRenderSystem.getProgramInfoLog(program);
|
||||
|
||||
+6
-6
@@ -26,7 +26,6 @@ import net.irisshaders.iris.gl.blending.BufferBlendOverride;
|
||||
import net.irisshaders.iris.gl.program.ProgramImages;
|
||||
import net.irisshaders.iris.gl.program.ProgramSamplers;
|
||||
import net.irisshaders.iris.gl.program.ProgramUniforms;
|
||||
import net.irisshaders.iris.gl.shader.GlShader;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
@@ -39,6 +38,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
|
||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlShader;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -82,28 +82,28 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
|
||||
this.bufferBlendOverrides = bufferBlendOverrides;
|
||||
|
||||
GlShader vert = new GlShader(ShaderType.VERTEX, name + ".vsh", vertex);
|
||||
GL43C.glAttachShader(id, vert.getHandle());
|
||||
GL43C.glAttachShader(id, vert.handle());
|
||||
|
||||
GlShader tessCont = null;
|
||||
if (tessControl != null) {
|
||||
tessCont = new GlShader(ShaderType.TESSELATION_CONTROL, name + ".tcs", tessControl);
|
||||
GL43C.glAttachShader(id, tessCont.getHandle());
|
||||
GL43C.glAttachShader(id, tessCont.handle());
|
||||
}
|
||||
|
||||
GlShader tessE = null;
|
||||
if (tessEval != null) {
|
||||
tessE = new GlShader(ShaderType.TESSELATION_EVAL, name + ".tes", tessEval);
|
||||
GL43C.glAttachShader(id, tessE.getHandle());
|
||||
GL43C.glAttachShader(id, tessE.handle());
|
||||
}
|
||||
|
||||
GlShader geom = null;
|
||||
if (geometry != null) {
|
||||
geom = new GlShader(ShaderType.GEOMETRY, name + ".gsh", geometry);
|
||||
GL43C.glAttachShader(id, geom.getHandle());
|
||||
GL43C.glAttachShader(id, geom.handle());
|
||||
}
|
||||
|
||||
GlShader frag = new GlShader(ShaderType.FRAGMENT, name + ".fsh", fragment);
|
||||
GL43C.glAttachShader(id, frag.getHandle());
|
||||
GL43C.glAttachShader(id, frag.handle());
|
||||
|
||||
GL32.glLinkProgram(this.id);
|
||||
int status = GL32.glGetProgrami(this.id, 35714);
|
||||
|
||||
+6
-6
@@ -17,7 +17,6 @@ import net.irisshaders.iris.gl.blending.BufferBlendOverride;
|
||||
import net.irisshaders.iris.gl.program.ProgramImages;
|
||||
import net.irisshaders.iris.gl.program.ProgramSamplers;
|
||||
import net.irisshaders.iris.gl.program.ProgramUniforms;
|
||||
import net.irisshaders.iris.gl.shader.GlShader;
|
||||
import net.irisshaders.iris.gl.state.FogMode;
|
||||
import net.irisshaders.iris.gl.texture.TextureType;
|
||||
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
|
||||
@@ -29,6 +28,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
|
||||
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
|
||||
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlShader;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -68,28 +68,28 @@ public class IrisLodRenderProgram {
|
||||
this.bufferBlendOverrides = bufferBlendOverrides;
|
||||
|
||||
GlShader vert = new GlShader(ShaderType.VERTEX, name + ".vsh", vertex);
|
||||
GL43C.glAttachShader(id, vert.getHandle());
|
||||
GL43C.glAttachShader(id, vert.handle());
|
||||
|
||||
GlShader tessCont = null;
|
||||
if (tessControl != null) {
|
||||
tessCont = new GlShader(ShaderType.TESSELATION_CONTROL, name + ".tcs", tessControl);
|
||||
GL43C.glAttachShader(id, tessCont.getHandle());
|
||||
GL43C.glAttachShader(id, tessCont.handle());
|
||||
}
|
||||
|
||||
GlShader tessE = null;
|
||||
if (tessEval != null) {
|
||||
tessE = new GlShader(ShaderType.TESSELATION_EVAL, name + ".tes", tessEval);
|
||||
GL43C.glAttachShader(id, tessE.getHandle());
|
||||
GL43C.glAttachShader(id, tessE.handle());
|
||||
}
|
||||
|
||||
GlShader geom = null;
|
||||
if (geometry != null) {
|
||||
geom = new GlShader(ShaderType.GEOMETRY, name + ".gsh", geometry);
|
||||
GL43C.glAttachShader(id, geom.getHandle());
|
||||
GL43C.glAttachShader(id, geom.handle());
|
||||
}
|
||||
|
||||
GlShader frag = new GlShader(ShaderType.FRAGMENT, name + ".fsh", fragment);
|
||||
GL43C.glAttachShader(id, frag.getHandle());
|
||||
GL43C.glAttachShader(id, frag.handle());
|
||||
|
||||
GL32.glLinkProgram(this.id);
|
||||
int status = GL32.glGetProgrami(this.id, 35714);
|
||||
|
||||
Reference in new issue
Block a user