Skip to content

Commit 35fd9e2

Browse files
committed
Add UnmanagedCallersOnly ProcAddr methods
1 parent 54322bf commit 35fd9e2

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

  • sources/Vulkan/Vulkan

sources/Vulkan/Vulkan/Vk.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Runtime.InteropServices;
12
using Silk.NET.Core.Loader;
23

34
namespace Silk.NET.Vulkan;
@@ -35,9 +36,14 @@ private class NativeContext : INativeContext
3536

3637
public unsafe void* LoadFunction(string functionName, string libraryNameHint)
3738
{
38-
if (functionName.EndsWith("ProcAddr"))
39+
if (functionName == "vkGetDeviceProcAddr")
3940
{
40-
return null;
41+
return (delegate* unmanaged<DeviceHandle, sbyte*, void*>)&GetDeviceProcAddr;
42+
}
43+
44+
if (functionName == "vkGetInstanceProcAddr")
45+
{
46+
return (delegate* unmanaged<InstanceHandle, sbyte*, void*>)&GetInstanceProcAddr;
4147
}
4248

4349
void* ptr = Ivk.GetDeviceProcAddr(Vk.CurrentDevice.GetValueOrDefault(), functionName);
@@ -50,6 +56,18 @@ private class NativeContext : INativeContext
5056
return ptr;
5157
}
5258

59+
[UnmanagedCallersOnly]
60+
private static unsafe void* GetDeviceProcAddr(DeviceHandle device, sbyte* pName)
61+
{
62+
return DllImport.GetDeviceProcAddr(device, pName);
63+
}
64+
65+
[UnmanagedCallersOnly]
66+
private static unsafe void* GetInstanceProcAddr(InstanceHandle instance, sbyte* pName)
67+
{
68+
return DllImport.GetInstanceProcAddr(instance, pName);
69+
}
70+
5371
public void Dispose() {}
5472
}
5573
}

0 commit comments

Comments
 (0)