Skip to content

Commit d639d9a

Browse files
author
Collateral
committed
shaderc compiler static variable
1 parent 00d326f commit d639d9a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main/java/net/vulkanmod/vulkan/ShaderSPIRVUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.lwjgl.util.shaderc.Shaderc.*;
1919

2020
public class ShaderSPIRVUtils {
21+
private static long compiler;
2122

2223
public static SPIRV compileShaderFile(String shaderFile, ShaderKind shaderKind) {
2324
String path = ShaderSPIRVUtils.class.getResource("/assets/vulkanmod/shaders/" + shaderFile).toExternalForm();
@@ -36,7 +37,7 @@ public static SPIRV compileShaderAbsoluteFile(String shaderFile, ShaderKind shad
3637

3738
public static SPIRV compileShader(String filename, String source, ShaderKind shaderKind) {
3839

39-
long compiler = shaderc_compiler_initialize();
40+
if(compiler == 0) compiler = shaderc_compiler_initialize();
4041

4142
if(compiler == NULL) {
4243
throw new RuntimeException("Failed to create shader compiler");
@@ -60,7 +61,7 @@ public static SPIRV compileShader(String filename, String source, ShaderKind sha
6061
throw new RuntimeException("Failed to compile shader " + filename + " into SPIR-V:\n" + shaderc_result_get_error_message(result));
6162
}
6263

63-
shaderc_compiler_release(compiler);
64+
// shaderc_compiler_release(compiler);
6465

6566
return new SPIRV(result, shaderc_result_get_bytes(result));
6667
}

0 commit comments

Comments
 (0)