Class CachedShaderCompiler
java.lang.Object
foundry.veil.impl.client.render.shader.DirectShaderCompiler
foundry.veil.impl.client.render.shader.CachedShaderCompiler
- All Implemented Interfaces:
ShaderCompiler
,AutoCloseable
,org.lwjgl.system.NativeResource
Attempts to cache the exact same shader sources to reduce the number of compiled shaders.
-
Nested Class Summary
Nested classes/interfaces inherited from interface foundry.veil.api.client.render.shader.ShaderCompiler
ShaderCompiler.Context
-
Constructor Summary
ConstructorDescriptionCachedShaderCompiler
(@Nullable net.minecraft.server.packs.resources.ResourceProvider provider) -
Method Summary
Modifier and TypeMethodDescriptioncompile
(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, String source) Creates a new shader and attempts to attach the specified sources to it.compile
(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, net.minecraft.resources.ResourceLocation id) Creates a new shader and attempts to attach sources read from file to it.void
free()
Methods inherited from class foundry.veil.impl.client.render.shader.DirectShaderCompiler
addDefaultProcessors, addPreprocessor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.lwjgl.system.NativeResource
close
Methods inherited from interface foundry.veil.api.client.render.shader.ShaderCompiler
addPreprocessor
-
Constructor Details
-
CachedShaderCompiler
public CachedShaderCompiler(@Nullable @Nullable net.minecraft.server.packs.resources.ResourceProvider provider)
-
-
Method Details
-
compile
public CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, net.minecraft.resources.ResourceLocation id) throws IOException, ShaderException Description copied from interface:ShaderCompiler
Creates a new shader and attempts to attach sources read from file to it. The sources are read from The shader will automatically be deleted at some point in the future.- Specified by:
compile
in interfaceShaderCompiler
- Overrides:
compile
in classDirectShaderCompiler
- Parameters:
context
- The context for compiling the shadertype
- The type of shader to createid
- The id of the shader to attach- Returns:
- A new shader that can be attached to programs
- Throws:
IOException
- If the file could not be found.ShaderException
- If an error occurs compiling the shader
-
compile
public CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, String source) throws IOException, ShaderException Description copied from interface:ShaderCompiler
Creates a new shader and attempts to attach the specified sources to it. The shader will automatically be deleted at some point in the future.- Specified by:
compile
in interfaceShaderCompiler
- Overrides:
compile
in classDirectShaderCompiler
- Parameters:
context
- The context for compiling the shadertype
- The type of shader to createsource
- The source of the shader to attach- Returns:
- A new shader that can be attached to programs
- Throws:
IOException
- If an error occurs processing the shader sourceShaderException
- If an error occurs compiling the shader
-
free
public void free()- Specified by:
free
in interfaceorg.lwjgl.system.NativeResource
- Overrides:
free
in classDirectShaderCompiler
-