merge-stonecutter #16
No files matched your search
@@ -1,30 +0,0 @@
|
|||||||
package net.irisshaders.iris.gl;
|
|
||||||
|
|
||||||
public abstract class GlResource {
|
|
||||||
private final int id;
|
|
||||||
private boolean isValid;
|
|
||||||
|
|
||||||
protected GlResource(int id) {
|
|
||||||
this.id = id;
|
|
||||||
isValid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void destroy() {
|
|
||||||
destroyInternal();
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void destroyInternal();
|
|
||||||
|
|
||||||
protected void assertValid() {
|
|
||||||
if (!isValid) {
|
|
||||||
throw new IllegalStateException("Tried to use a destroyed GlResource");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getGlId() {
|
|
||||||
assertValid();
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
|||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
// Do not extend GlResource, this is immutable.
|
|
||||||
public class ShaderStorageBuffer {
|
public class ShaderStorageBuffer {
|
||||||
protected final int index;
|
protected final int index;
|
||||||
protected final ShaderStorageInfo info;
|
protected final ShaderStorageInfo info;
|
||||||
|
|||||||
+13
-13
@@ -4,20 +4,20 @@ import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
||||||
import net.irisshaders.iris.texture.TextureInfoCache;
|
import net.irisshaders.iris.texture.TextureInfoCache;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
|
|
||||||
public class GlFramebuffer extends GlResource {
|
public class GlFramebuffer extends GlObject {
|
||||||
private final Int2IntMap attachments;
|
private final Int2IntMap attachments;
|
||||||
private final int maxDrawBuffers;
|
private final int maxDrawBuffers;
|
||||||
private final int maxColorAttachments;
|
private final int maxColorAttachments;
|
||||||
private boolean hasDepthAttachment;
|
private boolean hasDepthAttachment;
|
||||||
|
|
||||||
public GlFramebuffer() {
|
public GlFramebuffer() {
|
||||||
super(IrisRenderSystem.createFramebuffer());
|
this.setHandle(IrisRenderSystem.createFramebuffer());
|
||||||
|
|
||||||
this.attachments = new Int2IntArrayMap();
|
this.attachments = new Int2IntArrayMap();
|
||||||
this.maxDrawBuffers = GL_STATE_MANAGER.glGetInteger(GL30C.GL_MAX_DRAW_BUFFERS);
|
this.maxDrawBuffers = GL_STATE_MANAGER.glGetInteger(GL30C.GL_MAX_DRAW_BUFFERS);
|
||||||
@@ -29,7 +29,7 @@ public class GlFramebuffer extends GlResource {
|
|||||||
int internalFormat = TextureInfoCache.INSTANCE.getInfo(texture).getInternalFormat();
|
int internalFormat = TextureInfoCache.INSTANCE.getInfo(texture).getInternalFormat();
|
||||||
DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
||||||
|
|
||||||
int fb = getGlId();
|
int fb = handle();
|
||||||
|
|
||||||
if (depthBufferFormat.isCombinedStencil()) {
|
if (depthBufferFormat.isCombinedStencil()) {
|
||||||
IrisRenderSystem.framebufferTexture2D(fb, GL30C.GL_FRAMEBUFFER, GL30C.GL_DEPTH_STENCIL_ATTACHMENT, GL30C.GL_TEXTURE_2D, texture, 0);
|
IrisRenderSystem.framebufferTexture2D(fb, GL30C.GL_FRAMEBUFFER, GL30C.GL_DEPTH_STENCIL_ATTACHMENT, GL30C.GL_TEXTURE_2D, texture, 0);
|
||||||
@@ -41,14 +41,14 @@ public class GlFramebuffer extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addColorAttachment(int index, int texture) {
|
public void addColorAttachment(int index, int texture) {
|
||||||
int fb = getGlId();
|
int fb = handle();
|
||||||
|
|
||||||
IrisRenderSystem.framebufferTexture2D(fb, GL30C.GL_FRAMEBUFFER, GL30C.GL_COLOR_ATTACHMENT0 + index, GL30C.GL_TEXTURE_2D, texture, 0);
|
IrisRenderSystem.framebufferTexture2D(fb, GL30C.GL_FRAMEBUFFER, GL30C.GL_COLOR_ATTACHMENT0 + index, GL30C.GL_TEXTURE_2D, texture, 0);
|
||||||
attachments.put(index, texture);
|
attachments.put(index, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noDrawBuffers() {
|
public void noDrawBuffers() {
|
||||||
IrisRenderSystem.drawBuffers(getGlId(), new int[]{GL30C.GL_NONE});
|
IrisRenderSystem.drawBuffers(handle(), new int[]{GL30C.GL_NONE});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBuffers(int[] buffers) {
|
public void drawBuffers(int[] buffers) {
|
||||||
@@ -67,11 +67,11 @@ public class GlFramebuffer extends GlResource {
|
|||||||
glBuffers[index++] = GL30C.GL_COLOR_ATTACHMENT0 + buffer;
|
glBuffers[index++] = GL30C.GL_COLOR_ATTACHMENT0 + buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisRenderSystem.drawBuffers(getGlId(), glBuffers);
|
IrisRenderSystem.drawBuffers(handle(), glBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readBuffer(int buffer) {
|
public void readBuffer(int buffer) {
|
||||||
IrisRenderSystem.readBuffer(getGlId(), GL30C.GL_COLOR_ATTACHMENT0 + buffer);
|
IrisRenderSystem.readBuffer(handle(), GL30C.GL_COLOR_ATTACHMENT0 + buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColorAttachment(int index) {
|
public int getColorAttachment(int index) {
|
||||||
@@ -83,19 +83,19 @@ public class GlFramebuffer extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_FRAMEBUFFER, getGlId());
|
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_FRAMEBUFFER, handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindAsReadBuffer() {
|
public void bindAsReadBuffer() {
|
||||||
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_READ_FRAMEBUFFER, getGlId());
|
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_READ_FRAMEBUFFER, handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindAsDrawBuffer() {
|
public void bindAsDrawBuffer() {
|
||||||
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_DRAW_FRAMEBUFFER, getGlId());
|
GL_STATE_MANAGER.glBindFramebuffer(GL30C.GL_DRAW_FRAMEBUFFER, handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteFramebuffers(getGlId());
|
GL_STATE_MANAGER.glDeleteFramebuffers(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
@@ -105,6 +105,6 @@ public class GlFramebuffer extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,21 @@ package net.irisshaders.iris.gl.image;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.InternalTextureFormat;
|
import net.irisshaders.iris.gl.texture.InternalTextureFormat;
|
||||||
import net.irisshaders.iris.gl.texture.PixelFormat;
|
import net.irisshaders.iris.gl.texture.PixelFormat;
|
||||||
import net.irisshaders.iris.gl.texture.PixelType;
|
import net.irisshaders.iris.gl.texture.PixelType;
|
||||||
import net.irisshaders.iris.gl.texture.TextureType;
|
import net.irisshaders.iris.gl.texture.TextureType;
|
||||||
import org.lwjgl.opengl.*;
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
|
import org.lwjgl.opengl.ARBClearTexture;
|
||||||
|
import org.lwjgl.opengl.GL11C;
|
||||||
|
import org.lwjgl.opengl.GL13C;
|
||||||
|
import org.lwjgl.opengl.GL20C;
|
||||||
|
import org.lwjgl.opengl.GL30C;
|
||||||
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
public class GlImage extends GlResource {
|
public class GlImage extends GlObject {
|
||||||
protected final String name;
|
protected final String name;
|
||||||
protected final String samplerName;
|
protected final String samplerName;
|
||||||
protected final TextureType target;
|
protected final TextureType target;
|
||||||
@@ -20,7 +26,7 @@ public class GlImage extends GlResource {
|
|||||||
private final boolean clear;
|
private final boolean clear;
|
||||||
|
|
||||||
public GlImage(String name, String samplerName, TextureType target, PixelFormat format, InternalTextureFormat internalFormat, PixelType pixelType, boolean clear, int width, int height, int depth) {
|
public GlImage(String name, String samplerName, TextureType target, PixelFormat format, InternalTextureFormat internalFormat, PixelType pixelType, boolean clear, int width, int height, int depth) {
|
||||||
super(IrisRenderSystem.createTexture(target.getGlType()));
|
this.setHandle(IrisRenderSystem.createTexture(target.getGlType()));
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.samplerName = samplerName;
|
this.samplerName = samplerName;
|
||||||
@@ -30,12 +36,12 @@ public class GlImage extends GlResource {
|
|||||||
this.pixelType = pixelType;
|
this.pixelType = pixelType;
|
||||||
this.clear = clear;
|
this.clear = clear;
|
||||||
|
|
||||||
// GLDebug.nameObject(GL43C.GL_TEXTURE, getGlId(), name);
|
GLDebug.nameObject(GL43C.GL_TEXTURE, handle(), name);
|
||||||
|
|
||||||
IrisRenderSystem.bindTextureForSetup(target.getGlType(), getGlId());
|
IrisRenderSystem.bindTextureForSetup(target.getGlType(), handle());
|
||||||
target.apply(getGlId(), width, height, depth, internalFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
target.apply(handle(), width, height, depth, internalFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
||||||
|
|
||||||
int texture = getGlId();
|
int texture = handle();
|
||||||
|
|
||||||
setup(texture, width, height, depth);
|
setup(texture, width, height, depth);
|
||||||
|
|
||||||
@@ -81,7 +87,7 @@ public class GlImage extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +102,7 @@ public class GlImage extends GlResource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteTextures(getGlId());
|
GL_STATE_MANAGER.glDeleteTextures(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public InternalTextureFormat getInternalFormat() {
|
public InternalTextureFormat getInternalFormat() {
|
||||||
@@ -130,10 +136,10 @@ public class GlImage extends GlResource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNewSize(int width, int height) {
|
public void updateNewSize(int width, int height) {
|
||||||
IrisRenderSystem.bindTextureForSetup(target.getGlType(), getGlId());
|
IrisRenderSystem.bindTextureForSetup(target.getGlType(), handle());
|
||||||
target.apply(getGlId(), (int) (width * relativeWidth), (int) (height * relativeHeight), 0, internalTextureFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
target.apply(handle(), (int) (width * relativeWidth), (int) (height * relativeHeight), 0, internalTextureFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
||||||
|
|
||||||
int texture = getGlId();
|
int texture = handle();
|
||||||
|
|
||||||
setup(texture, width, height, 0);
|
setup(texture, width, height, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package net.irisshaders.iris.gl.program;
|
|||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.shaderpack.FilledIndirectPointer;
|
import net.irisshaders.iris.shaderpack.FilledIndirectPointer;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.joml.Vector2f;
|
import org.joml.Vector2f;
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
import org.lwjgl.opengl.GL46C;
|
import org.lwjgl.opengl.GL46C;
|
||||||
import org.taumc.celeritas.CeleritasShaderVersionService;
|
import org.taumc.celeritas.CeleritasShaderVersionService;
|
||||||
|
|
||||||
public final class ComputeProgram extends GlResource {
|
public final class ComputeProgram extends GlObject {
|
||||||
private final ProgramUniforms uniforms;
|
private final ProgramUniforms uniforms;
|
||||||
private final ProgramSamplers samplers;
|
private final ProgramSamplers samplers;
|
||||||
private final ProgramImages images;
|
private final ProgramImages images;
|
||||||
@@ -25,7 +25,7 @@ public final class ComputeProgram extends GlResource {
|
|||||||
private FilledIndirectPointer indirectPointer;
|
private FilledIndirectPointer indirectPointer;
|
||||||
|
|
||||||
ComputeProgram(int program, ProgramUniforms uniforms, ProgramSamplers samplers, ProgramImages images) {
|
ComputeProgram(int program, ProgramUniforms uniforms, ProgramSamplers samplers, ProgramImages images) {
|
||||||
super(program);
|
this.setHandle(program);
|
||||||
|
|
||||||
localSize = new int[3];
|
localSize = new int[3];
|
||||||
IrisRenderSystem.getProgramiv(program, GL43C.GL_COMPUTE_WORK_GROUP_SIZE, localSize);
|
IrisRenderSystem.getProgramiv(program, GL43C.GL_COMPUTE_WORK_GROUP_SIZE, localSize);
|
||||||
@@ -65,7 +65,7 @@ public final class ComputeProgram extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void use() {
|
public void use() {
|
||||||
GL_STATE_MANAGER.glUseProgram(getGlId());
|
GL_STATE_MANAGER.glUseProgram(handle());
|
||||||
|
|
||||||
uniforms.update();
|
uniforms.update();
|
||||||
samplers.update();
|
samplers.update();
|
||||||
@@ -86,7 +86,7 @@ public final class ComputeProgram extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void destroyInternal() {
|
public void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteProgram(getGlId());
|
GL_STATE_MANAGER.glDeleteProgram(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +95,7 @@ public final class ComputeProgram extends GlResource {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getProgramId() {
|
public int getProgramId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActiveImages() {
|
public int getActiveImages() {
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package net.irisshaders.iris.gl.program;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
public final class Program extends GlResource {
|
public final class Program extends GlObject {
|
||||||
private final ProgramUniforms uniforms;
|
private final ProgramUniforms uniforms;
|
||||||
private final ProgramSamplers samplers;
|
private final ProgramSamplers samplers;
|
||||||
private final ProgramImages images;
|
private final ProgramImages images;
|
||||||
|
|
||||||
Program(int program, ProgramUniforms uniforms, ProgramSamplers samplers, ProgramImages images) {
|
Program(int program, ProgramUniforms uniforms, ProgramSamplers samplers, ProgramImages images) {
|
||||||
super(program);
|
this.setHandle(program);
|
||||||
|
|
||||||
this.uniforms = uniforms;
|
this.uniforms = uniforms;
|
||||||
this.samplers = samplers;
|
this.samplers = samplers;
|
||||||
@@ -27,7 +27,7 @@ public final class Program extends GlResource {
|
|||||||
|
|
||||||
public void use() {
|
public void use() {
|
||||||
IrisRenderSystem.memoryBarrier(GL43C.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL43C.GL_TEXTURE_FETCH_BARRIER_BIT | GL43C.GL_SHADER_STORAGE_BARRIER_BIT);
|
IrisRenderSystem.memoryBarrier(GL43C.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL43C.GL_TEXTURE_FETCH_BARRIER_BIT | GL43C.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||||
GL_STATE_MANAGER.glUseProgram(getGlId());
|
GL_STATE_MANAGER.glUseProgram(handle());
|
||||||
|
|
||||||
uniforms.update();
|
uniforms.update();
|
||||||
samplers.update();
|
samplers.update();
|
||||||
@@ -35,7 +35,7 @@ public final class Program extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void destroyInternal() {
|
public void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteProgram(getGlId());
|
GL_STATE_MANAGER.glDeleteProgram(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +44,7 @@ public final class Program extends GlResource {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getProgramId() {
|
public int getProgramId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActiveImages() {
|
public int getActiveImages() {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package net.irisshaders.iris.gl.sampler;
|
package net.irisshaders.iris.gl.sampler;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
|
|
||||||
public class GlSampler extends GlResource {
|
public class GlSampler extends GlObject {
|
||||||
public GlSampler(boolean linear, boolean mipmapped, boolean shadow, boolean hardwareShadow) {
|
public GlSampler(boolean linear, boolean mipmapped, boolean shadow, boolean hardwareShadow) {
|
||||||
super(IrisRenderSystem.genSampler());
|
this.setHandle(IrisRenderSystem.genSampler());
|
||||||
|
|
||||||
IrisRenderSystem.samplerParameteri(getId(), GL11C.GL_TEXTURE_MIN_FILTER, linear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
IrisRenderSystem.samplerParameteri(getId(), GL11C.GL_TEXTURE_MIN_FILTER, linear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
||||||
IrisRenderSystem.samplerParameteri(getId(), GL11C.GL_TEXTURE_MAG_FILTER, linear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
IrisRenderSystem.samplerParameteri(getId(), GL11C.GL_TEXTURE_MAG_FILTER, linear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
||||||
@@ -27,10 +27,10 @@ public class GlSampler extends GlResource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
IrisRenderSystem.destroySampler(getGlId());
|
IrisRenderSystem.destroySampler(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,10 @@ package net.irisshaders.iris.gl.shader;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
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.debug.GLDebug;
|
||||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
@@ -18,13 +18,13 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* A compiled OpenGL shader object.
|
* A compiled OpenGL shader object.
|
||||||
*/
|
*/
|
||||||
public class GlShader extends GlResource {
|
public class GlShader extends GlObject {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(GlShader.class);
|
private static final Logger LOGGER = LogManager.getLogger(GlShader.class);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public GlShader(ShaderType type, String name, String src) {
|
public GlShader(ShaderType type, String name, String src) {
|
||||||
super(createShader(type, name, src));
|
this.setHandle(createShader(type, name, src));
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -56,11 +56,11 @@ public class GlShader extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getHandle() {
|
public int getHandle() {
|
||||||
return this.getGlId();
|
return this.handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteShader(this.getGlId());
|
GL_STATE_MANAGER.glDeleteShader(this.handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,31 +5,34 @@ import java.util.function.IntSupplier;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureFilteringData;
|
import net.irisshaders.iris.shaderpack.texture.TextureFilteringData;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
import org.lwjgl.opengl.GL20C;
|
import org.lwjgl.opengl.GL20C;
|
||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
public class GlTexture extends GlResource implements TextureAccess {
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.function.IntSupplier;
|
||||||
|
|
||||||
|
public class GlTexture extends GlObject implements TextureAccess {
|
||||||
private final TextureType target;
|
private final TextureType target;
|
||||||
|
|
||||||
public GlTexture(TextureType target, int sizeX, int sizeY, int sizeZ, int internalFormat, int format, int pixelType, byte[] pixels, TextureFilteringData filteringData) {
|
public GlTexture(TextureType target, int sizeX, int sizeY, int sizeZ, int internalFormat, int format, int pixelType, byte[] pixels, TextureFilteringData filteringData) {
|
||||||
super(GL_STATE_MANAGER.glGenTextures());
|
this.setHandle(GlStateManager._genTexture());
|
||||||
IrisRenderSystem.bindTextureForSetup(target.getGlType(), getGlId());
|
IrisRenderSystem.bindTextureForSetup(target.getGlType(), handle());
|
||||||
|
|
||||||
TextureUploadHelper.resetTextureUploadState();
|
TextureUploadHelper.resetTextureUploadState();
|
||||||
|
|
||||||
ByteBuffer buffer = MemoryUtil.memAlloc(pixels.length);
|
ByteBuffer buffer = MemoryUtil.memAlloc(pixels.length);
|
||||||
buffer.put(pixels);
|
buffer.put(pixels);
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
target.apply(this.getGlId(), sizeX, sizeY, sizeZ, internalFormat, format, pixelType, buffer);
|
target.apply(this.handle(), sizeX, sizeY, sizeZ, internalFormat, format, pixelType, buffer);
|
||||||
MemoryUtil.memFree(buffer);
|
MemoryUtil.memFree(buffer);
|
||||||
|
|
||||||
int texture = this.getGlId();
|
int texture = this.handle();
|
||||||
|
|
||||||
IrisRenderSystem.texParameteri(texture, target.getGlType(), GL11C.GL_TEXTURE_MIN_FILTER, filteringData.shouldBlur() ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
IrisRenderSystem.texParameteri(texture, target.getGlType(), GL11C.GL_TEXTURE_MIN_FILTER, filteringData.shouldBlur() ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
||||||
IrisRenderSystem.texParameteri(texture, target.getGlType(), GL11C.GL_TEXTURE_MAG_FILTER, filteringData.shouldBlur() ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
IrisRenderSystem.texParameteri(texture, target.getGlType(), GL11C.GL_TEXTURE_MAG_FILTER, filteringData.shouldBlur() ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
|
||||||
@@ -58,7 +61,7 @@ public class GlTexture extends GlResource implements TextureAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void bind(int unit) {
|
public void bind(int unit) {
|
||||||
IrisRenderSystem.bindTextureToUnit(target.getGlType(), unit, getGlId());
|
IrisRenderSystem.bindTextureToUnit(target.getGlType(), unit, handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,11 +71,11 @@ public class GlTexture extends GlResource implements TextureAccess {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSupplier getTextureId() {
|
public IntSupplier getTextureId() {
|
||||||
return this::getGlId;
|
return this::handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteTextures(getGlId());
|
GL_STATE_MANAGER.glDeleteTextures(handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1190,7 +1190,8 @@ public abstract class CommonIrisRenderingPipeline implements WorldRenderingPipel
|
|||||||
renderTargets.destroy();
|
renderTargets.destroy();
|
||||||
dhCompat.clearPipeline();
|
dhCompat.clearPipeline();
|
||||||
|
|
||||||
customImages.forEach(GlImage::destroy);
|
customImages.forEach(GlImage::delete);
|
||||||
|
|
||||||
|
|
||||||
if (shadowRenderer != null) {
|
if (shadowRenderer != null) {
|
||||||
shadowRenderer.destroy();
|
shadowRenderer.destroy();
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ package net.irisshaders.iris.targets;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
public class DepthTexture extends GlResource {
|
public class DepthTexture extends GlObject {
|
||||||
public DepthTexture(String name, int width, int height, DepthBufferFormat format) {
|
public DepthTexture(String name, int width, int height, DepthBufferFormat format) {
|
||||||
super(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
this.setHandle(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
||||||
int texture = getGlId();
|
int texture = handle();
|
||||||
|
|
||||||
resize(width, height, format);
|
resize(width, height, format);
|
||||||
GLDebug.nameObject(GL43C.GL_TEXTURE, texture, name);
|
GLDebug.nameObject(GL43C.GL_TEXTURE, texture, name);
|
||||||
@@ -32,11 +32,11 @@ public class DepthTexture extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTextureId() {
|
public int getTextureId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteTextures(getGlId());
|
GL_STATE_MANAGER.glDeleteTextures(handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public class RenderTargets {
|
|||||||
destroyed = true;
|
destroyed = true;
|
||||||
|
|
||||||
for (GlFramebuffer owned : ownedFramebuffers) {
|
for (GlFramebuffer owned : ownedFramebuffers) {
|
||||||
owned.destroy();
|
owned.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RenderTarget target : targets) {
|
for (RenderTarget target : targets) {
|
||||||
@@ -88,8 +88,8 @@ public class RenderTargets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
noTranslucents.destroy();
|
noTranslucents.delete();
|
||||||
noHand.destroy();
|
noHand.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRenderTargetCount() {
|
public int getRenderTargetCount() {
|
||||||
@@ -347,7 +347,7 @@ public class RenderTargets {
|
|||||||
|
|
||||||
if (drawBuffers[i] >= getRenderTargetCount()) {
|
if (drawBuffers[i] >= getRenderTargetCount()) {
|
||||||
// TODO: This causes resource leaks, also we should really verify this in the shaderpack parser...
|
// TODO: This causes resource leaks, also we should really verify this in the shaderpack parser...
|
||||||
framebuffer.destroy();
|
framebuffer.delete();
|
||||||
ownedFramebuffers.remove(framebuffer);
|
ownedFramebuffers.remove(framebuffer);
|
||||||
throw new IllegalStateException("Render target with index " + drawBuffers[i] + " is not supported, only "
|
throw new IllegalStateException("Render target with index " + drawBuffers[i] + " is not supported, only "
|
||||||
+ getRenderTargetCount() + " render targets are supported.");
|
+ getRenderTargetCount() + " render targets are supported.");
|
||||||
@@ -373,7 +373,7 @@ public class RenderTargets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void destroyFramebuffer(GlFramebuffer framebuffer) {
|
public void destroyFramebuffer(GlFramebuffer framebuffer) {
|
||||||
framebuffer.destroy();
|
framebuffer.delete();
|
||||||
ownedFramebuffers.remove(framebuffer);
|
ownedFramebuffers.remove(framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import java.util.Random;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.TextureUploadHelper;
|
import net.irisshaders.iris.gl.texture.TextureUploadHelper;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
@@ -18,14 +18,14 @@ import org.lwjgl.opengl.GL43C;
|
|||||||
* An extremely simple noise texture. Each color channel contains a uniform random value from 0 to 255. Essentially just
|
* An extremely simple noise texture. Each color channel contains a uniform random value from 0 to 255. Essentially just
|
||||||
* dumps an array of random bytes into a texture and calls it a day, literally could not be any simpler than that.
|
* dumps an array of random bytes into a texture and calls it a day, literally could not be any simpler than that.
|
||||||
*/
|
*/
|
||||||
public class NoiseTexture extends GlResource {
|
public class NoiseTexture extends GlObject {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
public NoiseTexture(int width, int height) {
|
public NoiseTexture(int width, int height) {
|
||||||
super(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
this.setHandle(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
||||||
|
|
||||||
int texture = getGlId();
|
int texture = handle();
|
||||||
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
|
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
|
||||||
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
|
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
|
||||||
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_S, GL13C.GL_REPEAT);
|
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_S, GL13C.GL_REPEAT);
|
||||||
@@ -71,11 +71,11 @@ public class NoiseTexture extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTextureId() {
|
public int getTextureId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteTextures(getGlId());
|
GL_STATE_MANAGER.glDeleteTextures(handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -4,18 +4,18 @@ import java.nio.ByteBuffer;
|
|||||||
|
|
||||||
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
|
||||||
|
|
||||||
import net.irisshaders.iris.gl.GlResource;
|
|
||||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||||
import net.irisshaders.iris.gl.texture.TextureUploadHelper;
|
import net.irisshaders.iris.gl.texture.TextureUploadHelper;
|
||||||
|
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL11C;
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.lwjgl.opengl.GL13C;
|
import org.lwjgl.opengl.GL13C;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
public class SingleColorTexture extends GlResource {
|
public class SingleColorTexture extends GlObject {
|
||||||
public SingleColorTexture(int red, int green, int blue, int alpha) {
|
public SingleColorTexture(int red, int green, int blue, int alpha) {
|
||||||
super(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
this.setHandle(IrisRenderSystem.createTexture(GL11C.GL_TEXTURE_2D));
|
||||||
ByteBuffer pixel = BufferUtils.createByteBuffer(4);
|
ByteBuffer pixel = BufferUtils.createByteBuffer(4);
|
||||||
pixel.put((byte) red);
|
pixel.put((byte) red);
|
||||||
pixel.put((byte) green);
|
pixel.put((byte) green);
|
||||||
@@ -23,7 +23,7 @@ public class SingleColorTexture extends GlResource {
|
|||||||
pixel.put((byte) alpha);
|
pixel.put((byte) alpha);
|
||||||
pixel.position(0);
|
pixel.position(0);
|
||||||
|
|
||||||
int texture = getGlId();
|
int texture = handle();
|
||||||
|
|
||||||
GLDebug.nameObject(GL43C.GL_TEXTURE, texture, "single color (" + red + ", " + green + "," + blue + "," + alpha + ")");
|
GLDebug.nameObject(GL43C.GL_TEXTURE, texture, "single color (" + red + ", " + green + "," + blue + "," + alpha + ")");
|
||||||
|
|
||||||
@@ -37,11 +37,11 @@ public class SingleColorTexture extends GlResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTextureId() {
|
public int getTextureId() {
|
||||||
return getGlId();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void destroyInternal() {
|
protected void destroyInternal() {
|
||||||
GL_STATE_MANAGER.glDeleteTextures(getGlId());
|
GL_STATE_MANAGER.glDeleteTextures(handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,5 +40,10 @@ public abstract class GlObject {
|
|||||||
this.handle = INVALID_HANDLE;
|
this.handle = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated // kept around to avoid huge diffs in old Iris code
|
||||||
|
public final void destroy() {
|
||||||
|
this.delete();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void destroyInternal();
|
protected abstract void destroyInternal();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user