Custom images, textures, SSBO, and ShaderPack/ShaderProperties backports

This commit is contained in:
Jason Mitchell authored and Jason Mitchell committed 2026-01-22 16:32:15 -08:00
1 parent 6d60477b93
commit bb52476d27
54 files changed
+2210 -494

No files matched your search

@@ -5,10 +5,13 @@ import com.google.common.collect.ImmutableSet;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import net.coderbot.iris.gl.sampler.GlSampler;
import net.coderbot.iris.gl.sampler.SamplerBinding;
import net.coderbot.iris.gl.sampler.SamplerHolder;
import net.coderbot.iris.gl.sampler.SamplerLimits;
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
import net.coderbot.iris.gl.texture.TextureAccess;
import net.coderbot.iris.gl.texture.TextureType;
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
import org.lwjgl.opengl.GL13;
@@ -73,11 +76,11 @@ public class ProgramSamplers {
return new Builder(program, reservedTextureUnits);
}
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds) {
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds) {
return customTextureSamplerInterceptor(samplerHolder, customTextureIds, ImmutableSet.of());
}
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
return new CustomTextureSamplerInterceptor(samplerHolder, customTextureIds, flippedAtLeastOnceSnapshot);
}
@@ -145,35 +148,31 @@ public class ProgramSamplers {
}
@Override
public boolean addDefaultSampler(IntSupplier sampler, String... names) {
public boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
if (nextUnit != 0) {
// TODO: Relax this restriction!
throw new IllegalStateException("Texture unit 0 is already used.");
}
return addDynamicSampler(sampler, true, null, names);
if (notifier != null) {
notifiersToReset.add(notifier);
}
return addDynamicSampler(type, texture, sampler, true, notifier, names);
}
/**
* Adds a sampler
* @return false if this sampler is not active, true if at least one of the names referred to an active sampler
*/
@Override
public boolean addDynamicSampler(IntSupplier sampler, String... names) {
return addDynamicSampler(sampler, false, null, names);
public boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names) {
return addDynamicSampler(type, texture, sampler, false, null, names);
}
/**
* Adds a sampler
* @return false if this sampler is not active, true if at least one of the names referred to an active sampler
*/
@Override
public boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names) {
public boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
notifiersToReset.add(notifier);
return addDynamicSampler(sampler, false, notifier, names);
return addDynamicSampler(type, texture, sampler, false, notifier, names);
}
private boolean addDynamicSampler(IntSupplier sampler, boolean used, ValueUpdateNotifier notifier, String... names) {
private boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, boolean used, ValueUpdateNotifier notifier, String... names) {
for (String name : names) {
int location = RenderSystem.getUniformLocation(program, name);
@@ -187,8 +186,6 @@ public class ProgramSamplers {
throw new IllegalStateException("No more available texture units while activating sampler " + name);
}
//System.out.println("Binding dynamic sampler " + name + " to texture unit " + nextUnit);
// Set up this sampler uniform to use this particular texture unit.
calls.add(new GlUniform1iCall(location, nextUnit));
@@ -200,7 +197,7 @@ public class ProgramSamplers {
return false;
}
samplers.add(new SamplerBinding(nextUnit, sampler, notifier));
samplers.add(new SamplerBinding(type, nextUnit, texture, sampler, notifier));
remainingUnits -= 1;
nextUnit += 1;
@@ -209,8 +206,6 @@ public class ProgramSamplers {
nextUnit += 1;
}
//System.out.println("The next unit is " + nextUnit + ", there are " + remainingUnits + " units remaining.");
return true;
}
@@ -221,10 +216,10 @@ public class ProgramSamplers {
public static final class CustomTextureSamplerInterceptor implements SamplerHolder {
private final SamplerHolder samplerHolder;
private final Object2ObjectMap<String, IntSupplier> customTextureIds;
private final Object2ObjectMap<String, TextureAccess> customTextureIds;
private final ImmutableSet<String> deactivatedOverrides;
private CustomTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
private CustomTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
this.samplerHolder = samplerHolder;
this.customTextureIds = customTextureIds;
@@ -244,7 +239,7 @@ public class ProgramSamplers {
private IntSupplier getOverride(IntSupplier existing, String... names) {
for (String name : names) {
if (customTextureIds.containsKey(name) && !deactivatedOverrides.contains(name)) {
return customTextureIds.get(name);
return customTextureIds.get(name).getTextureId();
}
}
@@ -272,24 +267,21 @@ public class ProgramSamplers {
}
@Override
public boolean addDefaultSampler(IntSupplier sampler, String... names) {
sampler = getOverride(sampler, names);
return samplerHolder.addDefaultSampler(sampler, names);
public boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
texture = getOverride(texture, names);
return samplerHolder.addDefaultSampler(type, texture, notifier, sampler, names);
}
@Override
public boolean addDynamicSampler(IntSupplier sampler, String... names) {
sampler = getOverride(sampler, names);
return samplerHolder.addDynamicSampler(sampler, names);
public boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names) {
texture = getOverride(texture, names);
return samplerHolder.addDynamicSampler(type, texture, sampler, names);
}
@Override
public boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names) {
sampler = getOverride(sampler, names);
return samplerHolder.addDynamicSampler(sampler, notifier, names);
public boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
texture = getOverride(texture, names);
return samplerHolder.addDynamicSampler(type, texture, notifier, sampler, names);
}
}
}