Skip to content

Commit

Permalink
Merge pull request IrisShaders#1111 from maximumpower55/no-duplicate-…
Browse files Browse the repository at this point in the history
…uniforms

Stop duplicated uniforms from being added
  • Loading branch information
coderbot16 authored Dec 20, 2021
2 parents f615e21 + 033ef76 commit f46e667
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/net/coderbot/iris/gl/program/ProgramUniforms.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package net.coderbot.iris.gl.program;

import java.nio.IntBuffer;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalInt;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.GlStateManager;
Expand Down Expand Up @@ -155,8 +160,14 @@ public OptionalInt location(String name, UniformType type) {
return OptionalInt.empty();
}

locations.put(id, name);
uniformNames.put(name, type);
if (!locations.containsKey(id) && !uniformNames.containsKey(name)) {
locations.put(id, name);
uniformNames.put(name, type);
} else {
Iris.logger.warn("[" + this.name + "] Duplicate uniform: " + type.toString().toLowerCase() + " " + name);

return OptionalInt.empty();
}

return OptionalInt.of(id);
}
Expand Down Expand Up @@ -252,6 +263,7 @@ public Builder addDynamicUniform(Uniform uniform, ValueUpdateNotifier notifier)
@Override
public UniformHolder externallyManagedUniform(String name, UniformType type) {
externalUniformNames.put(name, type);

return this;
}
}
Expand Down

0 comments on commit f46e667

Please sign in to comment.