mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-18 19:39:09 +00:00
Fix Iris issues with instancing and batching (#2158)
This commit is contained in:
1 parent
7bb5bfd45c
commit
af599f292e
103 files changed
+4691
-535
No files matched your search
@@ -1,7 +1,10 @@
|
||||
package net.coderbot.iris.gl.program;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.DisplayListManager;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CommandRecorder;
|
||||
import net.coderbot.iris.gl.image.ImageHolder;
|
||||
import net.coderbot.iris.gl.sampler.GlSampler;
|
||||
import net.coderbot.iris.gl.sampler.SamplerHolder;
|
||||
@@ -54,6 +57,7 @@ public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHo
|
||||
shaders.add(fragment);
|
||||
|
||||
int programId = ProgramCreator.create(name, shaders.toArray(new GlShader[0]));
|
||||
initializeFallbackUniforms(programId);
|
||||
|
||||
for (GlShader shader : shaders) {
|
||||
shader.destroy();
|
||||
@@ -62,6 +66,42 @@ public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHo
|
||||
return new ProgramBuilder(name, programId, reservedTextureUnits);
|
||||
}
|
||||
|
||||
/** Initialize alpha and color uniforms to neutral values until the first pass update. */
|
||||
private static void initializeFallbackUniforms(int programId) {
|
||||
final int previous = GLStateManager.getActiveProgram();
|
||||
final CommandRecorder recorder = DisplayListManager.isRecording() ? DisplayListManager.pauseRecording() : null;
|
||||
try {
|
||||
Program.bindManaged(programId);
|
||||
seedUniform1i(programId, "iris_currentAlphaFunc", 7);
|
||||
seedUniform1f(programId, "iris_currentAlphaTest", -1.0f);
|
||||
seedUniform1f(programId, "alphaTestRef", -1.0f);
|
||||
final int modulator = GLStateManager.glGetUniformLocation(programId, "iris_ColorModulator");
|
||||
if (modulator != -1) {
|
||||
RenderSystem.uniform4f(modulator, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
Program.bindManaged(previous);
|
||||
} finally {
|
||||
if (recorder != null) DisplayListManager.resumeRecording(recorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void seedUniform1i(int programId, String name, int value) {
|
||||
final int location = GLStateManager.glGetUniformLocation(programId, name);
|
||||
if (location != -1) {
|
||||
RenderSystem.uniform1i(location, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void seedUniform1f(int programId, String name, float value) {
|
||||
final int location = GLStateManager.glGetUniformLocation(programId, name);
|
||||
if (location != -1) {
|
||||
RenderSystem.uniform1f(location, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static ProgramBuilder beginCompute(String name, @Nullable String source, ImmutableSet<Integer> reservedTextureUnits) {
|
||||
if (!RenderSystem.supportsCompute()) {
|
||||
throw new IllegalStateException("This PC does not support compute shaders, but it's attempting to be used???");
|
||||
|
||||
Reference in new issue
Block a user