vulkan-go / vulkan

Vulkan API bindings for Go programming language
MIT License
742 stars 55 forks source link

accessing GetInstanceProcAddr externally (to call vkCreateMacOSSurfaceMVK) #36

Closed rcoreilly closed 5 years ago

rcoreilly commented 5 years ago

I'm trying to integrate vulkan-go into my graphics package which has its own existing platform-specific backends, so I don't want to use GLFW. I want to be able to call e.g., vkCreateMacOSSurfaceMVK on macos to create a surface. As far as I've been able to determine, I need to do something like this:

vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)
    vgo_vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK");

to get the function pointer, and then I can call that.

but everything depends on that vgo_vkGetInstanceProcAddr which is in turn based on a static getInstanceProcAddress in vk_wrapper_desktop.c

would it be possible to export that somehow? or is there some way I can get access to that variable without having to reimplement my own copy of the code that gets it in the first place?

alternatively, can all the platform-specific create surface routines such as vkCreateMacOSSurfaceMVK be exported in a way that would be visible inside my cgo .m objective-C files? not sure how that would even work -- don't want to get into complicated pathing / config issues to find the cgo headers from vulkan-go.. I tried various ways of declaring them as extern vars and nothing has worked.

I might have missed something obvious here -- I'm a newbie to vulkan[-go]. Thanks!

rcoreilly commented 5 years ago

figured it out -- just including vulkan/vulkan.h directly in my .m file and then I can access vkGetInstanceProcAddr directly from there -- and need to add vulkan as a link framework too. i.e., just needed to go down to the vulkan level instead of using the vulkan-go wrappers at this point.