Skip to content

Commit 46d7eba

Browse files
committed
lab: Also compile to GLSL to get output in SpirvTest
1 parent e995d89 commit 46d7eba

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/Lab/Experiments/SpirvTest/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using Silk.NET.Core.Native;
23
using Silk.NET.SPIRV.Reflect;
34
using Silk.NET.SPIRV.Cross;
45
using Result = Silk.NET.SPIRV.Reflect.Result;
@@ -39,6 +40,19 @@
3940
throw new Exception($"failed to parse spirv {result.ToString()}");
4041

4142
Console.WriteLine($"Parsed IR");
43+
44+
Compiler* compiler = null;
45+
result = cross.ContextCreateCompiler(context, Backend.Glsl, parsedIr, CaptureMode.Copy, &compiler);
46+
if(result != Silk.NET.SPIRV.Cross.Result.Success)
47+
throw new Exception($"failed to create compiler {result.ToString()}");
48+
49+
byte* source = null;
50+
result = cross.CompilerCompile(compiler, &source);
51+
if(result != Silk.NET.SPIRV.Cross.Result.Success)
52+
throw new Exception($"failed to compile {result.ToString()}");
53+
54+
string? str = SilkMarshal.PtrToString((nint)source, NativeStringEncoding.UTF8);
55+
Console.WriteLine($"Compiled int {str}");
4256

4357
cross.ContextDestroy(context);
4458
}

0 commit comments

Comments
 (0)