blob: b91a47b93debff6bf1c38ae3220ec477ce2ad955 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright (c) 2019 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.Runtime.InteropServices;
namespace Vulkan {
internal static class LoadingUtils {
public static IntPtr GetDelegate (VkInstance inst, string name) {
byte[] n = System.Text.Encoding.UTF8.GetBytes (name + '\0');
GCHandle hnd = GCHandle.Alloc (n, GCHandleType.Pinned);
IntPtr del = Vk.vkGetInstanceProcAddr (inst, hnd.AddrOfPinnedObject ());
if (del == IntPtr.Zero)
System.Diagnostics.Debug.WriteLine ("instance function pointer not found for " + name);
hnd.Free ();
return del;
}
/// <summary>
/// try to get device function handle if available
/// </summary>
public static void GetDelegate (VkDevice dev, string name, ref IntPtr ptr) {
byte[] n = System.Text.Encoding.UTF8.GetBytes (name + '\0');
GCHandle hnd = GCHandle.Alloc (n, GCHandleType.Pinned);
IntPtr del = Vk.vkGetDeviceProcAddr (dev, hnd.AddrOfPinnedObject ());
if (del == IntPtr.Zero)
System.Diagnostics.Debug.WriteLine ("device function pointer not found for " + name);
else
ptr = del;
hnd.Free ();
}
}
}
|