13
13
import com .nucleus .io .StreamUtils ;
14
14
import com .nucleus .spirv .SpirvBinary ;
15
15
import com .nucleus .spirv .SpirvBinary .SpirvStream ;
16
+ import com .nucleus .vulkan .structs .ShaderModuleCreateInfo .Type ;
16
17
17
18
/**
18
19
* Used to compile GLSL to SPIR-V in runtime.
@@ -24,16 +25,6 @@ public class GLSLCompiler {
24
25
private static final String TARGET_CLASSES = "target/classes/" ;
25
26
private static final String DESTINATION_RESOURCES = "src/main/resources/" ;
26
27
27
- public enum Stage {
28
- vert (),
29
- tesc (),
30
- tese (),
31
- geom (),
32
- frag (),
33
- comp ();
34
-
35
- }
36
-
37
28
private static GLSLCompiler compiler = new GLSLCompiler ();
38
29
39
30
/**
@@ -59,26 +50,27 @@ public static GLSLCompiler getInstance() {
59
50
public synchronized void compileShaders (String path , ArrayList <String > folders )
60
51
throws IOException , URISyntaxException {
61
52
ByteBuffer buffer = BufferUtils .createByteBuffer (16000 );
62
- compileStage (path , folders , buffer , Stage . vert );
63
- compileStage (path , folders , buffer , Stage . geom );
64
- compileStage (path , folders , buffer , Stage . frag );
53
+ compileStage (path , folders , buffer , Type . VERTEX );
54
+ compileStage (path , folders , buffer , Type . GEOMETRY );
55
+ compileStage (path , folders , buffer , Type . FRAGMENT );
65
56
}
66
57
67
- public void compileStage (String path , ArrayList <String > folders , ByteBuffer buffer , Stage stage )
58
+ public void compileStage (String path , ArrayList <String > folders , ByteBuffer buffer , Type type )
68
59
throws IOException , URISyntaxException {
69
60
for (String folder : folders ) {
70
61
ArrayList <String > currentFolder = new ArrayList <String >();
71
62
currentFolder .add (folder );
72
- String stageSuffix = "." + stage .name ();
63
+ // Get the mime for the shader type/stage - ie the glsl sourcefiles to compile
64
+ String stageSuffix = "." + type .stage ;
73
65
ArrayList <String > filenames = FileUtils .getInstance ().listFiles (path , currentFolder ,
74
66
new String [] { stageSuffix });
75
67
76
68
String name = null ;
77
69
String output = null ;
78
70
for (String filename : filenames ) {
79
71
String filePath = FileUtils .getInstance ().getFilePath (path + filename , folder );
80
- name = filename .substring (0 , filename .length () - (stage . name () .length () + 1 ));
81
- output = name + "_" + stage . name () + ".spv" ;
72
+ name = filename .substring (0 , filename .length () - (type . fileName .length () + 1 ));
73
+ output = name + type . fileName ;
82
74
String cmd = "glslc " + filename + " -o -" ;
83
75
buffer .clear ();
84
76
SpirvBinary binary = compile (
0 commit comments