mono / VulkanSharp

Open source .NET binding for the Vulkan API
MIT License
538 stars 61 forks source link

DllNotFoundException on Mono (Arch Linux) #52

Closed sunkin351 closed 7 years ago

sunkin351 commented 7 years ago

Its attempting to load the vulkan loader with the name vulkan-1 instead of vulkan on my Linux distribution.

sunkin351 commented 7 years ago

May I suggest having your generator take a parameter for the platform one wishes to have bindings for? EDIT: It appears to default to windows with no way to change it. Help?

jonpryor commented 7 years ago

May I suggest having your generator take a parameter for the platform one wishes to have bindings for?

The problem with that is then assemblies are platform-specific, which results in no end of confusion.

The appropriate strategy is to use Windows native library names within [DllImport] declarations and use a <dllmap/> to "remap" the Windows native library name to the appropriate OS-specific native library name.

Indeed, a Vulkan.dll.config file is present, and should be copied to the output file. (Which is where the vulkan-1 references is coming from!)

You should edit the Vulkan.dll.config file to contain an appropriate distro-specific value.

sunkin351 commented 7 years ago

Will keep that in mind.

sunkin351 commented 7 years ago

Also, what should I do about opening a window in a desktop computer? I noticed all your samples are for mobile.

radekdoulik commented 7 years ago

Check our Windows sample, https://github.com/mono/VulkanSharp/blob/master/samples/Inspector.Windows/MainWindow.xaml.cs

YoshiRulz commented 5 years ago

I've made a symlink /usr/lib/libvulkan-1.so -> /usr/lib/libvulkan.so.1 so Mono finds it, but the imported methods are Win32-specific and don't exist in libvulkan.so.1.

https://github.com/mono/VulkanSharp/blob/6d8e3590d17d2b2671f26accb4e1ba75691366de/src/Platforms/Windows/Interop/ImportedCommands.cs#L21-L28

~#> objdump -T /usr/lib/libvulkan-1.so | grep Win32
~#> # no output

As a result I'm getting this error when instantiating my class GLControlWrapper_Vulkan : VulkanControl (my OnLoad override does nothing but call the base method):

System.EntryPointNotFoundException: vkCreateWin32SurfaceKHR
  at (wrapper managed-to-native) Vulkan.Windows.Interop.NativeMethods.vkCreateWin32SurfaceKHR(intptr,Vulkan.Windows.Interop.Win32SurfaceCreateInfoKhr*,Vulkan.Interop.AllocationCallbacks*,ulong*)
  at Vulkan.Windows.InstanceExtension.CreateWin32SurfaceKHR (Vulkan.Instance instance, Vulkan.Windows.Win32SurfaceCreateInfoKhr pCreateInfo, Vulkan.AllocationCallbacks pAllocator) [0x00038] in <4261f9539663473c8039432012590f69>:0 
  at Vulkan.Windows.VulkanControl.OnLoad (System.EventArgs e) [0x00032] in <4261f9539663473c8039432012590f69>:0 
  at BizHawk.Bizware.BizwareGL.Drivers.Vulkan.GLControlWrapper_Vulkan.OnLoad (System.EventArgs e) [0x00001] in <584ae07baffa487aaf2d5a84cb3b3661>:0 
  at System.Windows.Forms.UserControl.OnCreateControl () [0x00006] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.Control.CreateControl () [0x00082] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.Control.WmShowWindow (System.Windows.Forms.Message& m) [0x00036] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x00214] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) [0x00029] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.UserControl.WndProc (System.Windows.Forms.Message& m) [0x00027] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <6d04630604b24bb0bd1a94de821c9d88>:0 
  at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <6d04630604b24bb0bd1a94de821c9d88>:0 

Installing WINE and pointing the symlink at /usr/lib/wine/vulkan-1.dll.so also does not work.

clSharp commented 5 years ago

@YoshiRulz If you are not using Windows your code should not be calling vkCreateWin32SurfaceKHR. You will have to implement your own version of Vulkan.Windows.VulkanControl with a modified OnLoad method. In there you have to create a surface specific to your window manager (http://vulkan-spec-chunked.ahcox.com/ch29s02.html). Perhaps it's possible to just overload VulkanControl.OnLoad() and create the correct surface in there.

YoshiRulz commented 5 years ago

@clSharp My code isn't calling NativeMethods.vkCreateWin32SurfaceKHR, read the stacktrace again. Also, it's sadly not possible to inherit from Windows.VulkanControl and override OnLoad, as it calls the base method in UserControl.

I started to make a copy of VulkanControl with the platform methods swapped out until I got to Win32SurfaceCreateInfoKhr, which is generated code.

https://github.com/mono/VulkanSharp/blob/fbe3609224c057e4433840d8b4757892aa169a63/src/Platforms/Windows/Structs.cs#L1

This brings me back to my original complaint: it seems only Android, iOS, and Windows are being generated, and I'd like this issue reopened until X and/or Wayland are added.

If having broken code is in some way helpful, it's here and the X stuff I tried is here.

TillAlex commented 5 years ago

@YoshiRulz From the stacktrace I see that your code is (at least indirectly) calling vkCreateWin32SurfaceKHR. Just wanted to point you to the fact that you cannot use the windows specific parts of VulkanSharp in linux, which includes Vulkan.Windows.VulkanControl.

Currently the generator is generating the linux specific code in src\Platforms\Linux\, but there is no project compiling that code. You will have to add the platform project similar to what has been done in fafedb0e35d229da1a3d740c12ed5dbde4a2235b. You could more or less copy and paste from Vulkan.Windows plattform or perhaps even better create a netstandard project for linux.