Closed sunkin351 closed 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?
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.
Will keep that in mind.
Also, what should I do about opening a window in a desktop computer? I noticed all your samples are for mobile.
Check our Windows sample, https://github.com/mono/VulkanSharp/blob/master/samples/Inspector.Windows/MainWindow.xaml.cs
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
.
~#> 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.
@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.
@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.
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.
@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.
Its attempting to load the vulkan loader with the name
vulkan-1
instead ofvulkan
on my Linux distribution.