Skip to content

Commit

Permalink
Port non-PBR changes from PBR branch
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 committed May 9, 2022
1 parent 71634fe commit fcc5584
Show file tree
Hide file tree
Showing 29 changed files with 318 additions and 374 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/coderbot/iris/IrisLogging.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ public void info(String info, Object... o) {
public void debug(String debug) {
this.logger.debug(debug);
}

public void debug(String debug, Throwable t) {
this.logger.debug(debug, t);
}
}
7 changes: 5 additions & 2 deletions src/main/java/net/coderbot/iris/LaunchWarn.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package net.coderbot.iris;

import javax.swing.*;
import java.awt.*;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.Desktop;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.net.URI;

Expand Down
31 changes: 23 additions & 8 deletions src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
* This class is responsible for abstracting calls to OpenGL and asserting that calls are run on the render thread.
*/
public class IrisRenderSystem {
public static void getIntegerv(int pname, int[] params) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
GL30C.glGetIntegerv(pname, params);
}

public static void getFloatv(int pname, float[] params) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
GL30C.glGetFloatv(pname, params);
}

public static void generateMipmaps(int mipmapTarget) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
GL30C.glGenerateMipmap(mipmapTarget);
Expand All @@ -28,9 +38,9 @@ public static void bindAttributeLocation(int program, int index, CharSequence na
GL30C.glBindAttribLocation(program, index, name);
}

public static void texImage2D(int i, int j, int k, int l, int m, int n, int o, int p, @Nullable ByteBuffer byteBuffer) {
public static void texImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable ByteBuffer pixels) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
GL30C.glTexImage2D(i, j, k, l, m, n, o, p, byteBuffer);
GL30C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
}

public static void uniformMatrix4fv(int location, boolean transpose, FloatBuffer matrix) {
Expand Down Expand Up @@ -128,15 +138,20 @@ public static void detachShader(int program, int shader) {
GL30C.glDetachShader(program, shader);
}

public static int getTexParameteri(int target, int pname) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
return GL30C.glGetTexParameteri(target, pname);
}

public static void bindImageTexture(int unit, int texture, int level, boolean layered, int layer, int access, int format) {
RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
if (GL.getCapabilities().OpenGL42) {
GL42C.glBindImageTexture(unit, texture, level, layered, layer, access, format);
} else {
EXTShaderImageLoadStore.glBindImageTextureEXT(unit, texture, level, layered, layer, access, format);
}
if (GL.getCapabilities().OpenGL42) {
GL42C.glBindImageTexture(unit, texture, level, layered, layer, access, format);
} else {
EXTShaderImageLoadStore.glBindImageTextureEXT(unit, texture, level, layered, layer, access, format);
}
}

public static int getMaxImageUnits() {
if (GL.getCapabilities().OpenGL42) {
return GlStateManager._getInteger(GL42C.GL_MAX_IMAGE_UNITS);
Expand Down
89 changes: 0 additions & 89 deletions src/main/java/net/coderbot/iris/gl/shader/ShaderConstants.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class StateUpdateNotifiers {
public static ValueUpdateNotifier fogEndNotifier;
public static ValueUpdateNotifier fogDensityNotifier;
public static ValueUpdateNotifier blendFuncNotifier;
public static ValueUpdateNotifier atlasTextureNotifier;
public static ValueUpdateNotifier bindTextureNotifier;
public static ValueUpdateNotifier phaseChangeNotifier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public static DepthBufferFormat fromGlEnum(int glenum) {
}
}

public static DepthBufferFormat fromGlEnumOrDefault(int glenum) {
DepthBufferFormat format = fromGlEnum(glenum);
if (format == null) {
// yolo, just assume it's GL_DEPTH_COMPONENT
return DepthBufferFormat.DEPTH;
}
return format;
}

public int getGlInternalFormat() {
switch (this) {
case DEPTH:
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/GlStateManagerAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@ static GlStateManager.AlphaState getALPHA_TEST() {
static GlStateManager.BlendState getBLEND() {
throw new UnsupportedOperationException("Not accessed");
}

@Accessor("FOG")
static GlStateManager.FogState getFOG() {
throw new UnsupportedOperationException("Not accessed");
}

@Accessor("activeTexture")
static int getActiveTexture() {
throw new UnsupportedOperationException("Not accessed");
}

@Accessor("TEXTURES")
static GlStateManager.TextureState[] getTEXTURES() {
throw new UnsupportedOperationException("Not accessed");
}
}

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/net/coderbot/iris/mixin/MixinRenderTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.pipeline.RenderTarget;
import net.coderbot.iris.rendertarget.Blaze3dRenderTargetExt;
import net.coderbot.iris.samplers.DepthBufferTracker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -27,11 +26,6 @@ public class MixinRenderTarget implements Blaze3dRenderTargetExt {
iris$colorDirty = true;
}

@Inject(method = "createBuffers(IIZ)V", at = @At(value = "INVOKE", target = "com/mojang/blaze3d/platform/GlStateManager._bindTexture (I)V"))
private void iris$onCreateDepthBuffer(int width, int height, boolean checkError, CallbackInfo ci) {
DepthBufferTracker.INSTANCE.trackDepthBuffer(this.depthBufferId);
}

@Override
public boolean iris$isDepthBufferDirty() {
return iris$depthDirty;
Expand Down
39 changes: 0 additions & 39 deletions src/main/java/net/coderbot/iris/mixin/MixinTextureAtlas.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.coderbot.iris.mixin.texture;

import net.coderbot.iris.texture.TextureTracker;
import net.minecraft.client.renderer.texture.AbstractTexture;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(AbstractTexture.class)
public class MixinAbstractTexture {
@Shadow
protected int id;

@Inject(method = "getId()I", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;generateTextureId()I", shift = Shift.BY, by = 2))
private void iris$onGenerateId(CallbackInfoReturnable<Integer> cir) {
TextureTracker.INSTANCE.trackTexture(id, (AbstractTexture) (Object) this);
}
}
Loading

0 comments on commit fcc5584

Please sign in to comment.