-
-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
196 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderLoadingMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.irisshaders.iris.pipeline.programs; | ||
|
||
import net.minecraft.client.renderer.CompiledShaderProgram; | ||
|
||
import java.util.function.BiConsumer; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* A specialized map mapping {@link ShaderKey} to {@link CompiledShaderProgram}. | ||
* Avoids much of the complexity / overhead of an EnumMap while ultimately | ||
* fulfilling the same function. | ||
*/ | ||
public class ShaderLoadingMap { | ||
private final ShaderSupplier[] shaders; | ||
|
||
public ShaderLoadingMap(Function<ShaderKey, ShaderSupplier> factory) { | ||
ShaderKey[] ids = ShaderKey.values(); | ||
|
||
this.shaders = new ShaderSupplier[ids.length]; | ||
|
||
for (int i = 0; i < ids.length; i++) { | ||
this.shaders[i] = factory.apply(ids[i]); | ||
} | ||
} | ||
|
||
public void forAllShaders(BiConsumer<ShaderKey, ShaderSupplier> consumer) { | ||
for (int i = 0; i < ShaderKey.values().length; i++) { | ||
consumer.accept(ShaderKey.values()[i], this.shaders[i]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
common/src/main/java/net/irisshaders/iris/pipeline/programs/ShaderSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.irisshaders.iris.pipeline.programs; | ||
|
||
import net.minecraft.client.renderer.CompiledShaderProgram; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public record ShaderSupplier(int id, Supplier<CompiledShaderProgram> shader) { | ||
} |
Oops, something went wrong.