File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ using Silk . NET . Core . Loader ;
2
+
3
+ namespace Silk . NET . Vulkan ;
4
+
5
+ public partial class Vk
6
+ {
7
+ public static IVk Create ( )
8
+ {
9
+ var context = new NativeContext ( ) ;
10
+ var vk = new Vk ( context ) ;
11
+
12
+ context . Vk = vk ;
13
+
14
+ return vk ;
15
+ }
16
+
17
+ public unsafe IVk Clone ( )
18
+ {
19
+ var context = new NativeContext ( ) ;
20
+ var vk = new Vk ( context ) ;
21
+
22
+ context . Vk = vk ;
23
+
24
+ vk . CurrentInstance = CurrentInstance ;
25
+ vk . CurrentDevice = CurrentDevice ;
26
+ Array . Copy ( _slots , vk . _slots , _slots . Length ) ;
27
+
28
+ return vk ;
29
+ }
30
+
31
+ private class NativeContext : INativeContext
32
+ {
33
+ public Vk Vk { get ; set ; } = null ! ;
34
+ private IVk Ivk => Vk ;
35
+
36
+ public unsafe void * LoadFunction ( string functionName , string libraryNameHint )
37
+ {
38
+ if ( functionName . EndsWith ( "ProcAddr" ) )
39
+ {
40
+ return null ;
41
+ }
42
+
43
+ void * ptr = Ivk . GetDeviceProcAddr ( Vk . CurrentDevice . GetValueOrDefault ( ) , functionName ) ;
44
+ if ( ptr != null )
45
+ {
46
+ return ptr ;
47
+ }
48
+
49
+ ptr = Ivk . GetInstanceProcAddr ( Vk . CurrentInstance . GetValueOrDefault ( ) , functionName ) ;
50
+ return ptr ;
51
+ }
52
+
53
+ public void Dispose ( ) { }
54
+ }
55
+ }
You can’t perform that action at this time.
0 commit comments