1 type ShaderFile = 2 val bytes : Array<u8> 3 val metadata : Metadata 4 5 def discard = 6 bytes.discard 7 8 is Discard 9 10 module shader/file 11 12 def get (path : String) (prev_file : Option<ShaderFile>) = 13 let modified = fs/modified_time path 14 let file_name = Path.get_file_name path 15 let shader_path = Path.remove_file_name path 16 let compiled_path = "$shader_path/$file_name.spv" 17 18 let compiled_modified = if fs/exists compiled_path 19 then fs/modified_time compiled_path 20 else sys/Time.new 21 22 if modified > compiled_modified then 23 let output = 24 sys/process/run "glslangValidator -V $path -o $compiled_path" 25 |> wait 26 27 if output.stdout.contains "ERROR" then 28 fail output.stdout 29 30 assert fs/modified_time compiled_path >= modified 31 32 let metadata = metadata/get path 33 let bytes = fs/read_bytes compiled_path 34 35 ShaderFile =bytes =metadata 36