diff options
author | David Robillard <d@drobilla.net> | 2020-11-21 17:48:19 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-25 14:18:04 +0100 |
commit | 3e9a2e01da169007b6fc16492f812055645f6d5f (patch) | |
tree | e761ca334ee9b0e3bd91b3a6f83ab1373dd7aa7f | |
parent | 6426b03476fb91efbd90acd599472010f5474390 (diff) | |
download | pugl-3e9a2e01da169007b6fc16492f812055645f6d5f.tar.gz pugl-3e9a2e01da169007b6fc16492f812055645f6d5f.tar.bz2 pugl-3e9a2e01da169007b6fc16492f812055645f6d5f.zip |
Pass vkGetInstanceProcAddr to puglCreateSurface instead of a loader
This allows puglCreateSurface() to be used with some other loader, or when
linking to Vulkan at compile time.
-rw-r--r-- | bindings/cxx/include/pugl/vulkan.hpp | 4 | ||||
-rw-r--r-- | examples/pugl_vulkan_cxx_demo.cpp | 7 | ||||
-rw-r--r-- | examples/pugl_vulkan_demo.c | 7 | ||||
-rw-r--r-- | include/pugl/vulkan.h | 4 | ||||
-rw-r--r-- | src/mac_vulkan.m | 6 | ||||
-rw-r--r-- | src/win_vulkan.c | 6 | ||||
-rw-r--r-- | src/x11_vulkan.c | 6 | ||||
-rw-r--r-- | wscript | 1 |
8 files changed, 24 insertions, 17 deletions
diff --git a/bindings/cxx/include/pugl/vulkan.hpp b/bindings/cxx/include/pugl/vulkan.hpp index 5ce8acd..aaa221f 100644 --- a/bindings/cxx/include/pugl/vulkan.hpp +++ b/bindings/cxx/include/pugl/vulkan.hpp @@ -142,14 +142,14 @@ getInstanceExtensions() noexcept /// @copydoc puglCreateSurface inline VkResult -createSurface(const VulkanLoader& loader, +createSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, View& view, VkInstance instance, const VkAllocationCallbacks* const allocator, VkSurfaceKHR* const surface) noexcept { const VkResult r = puglCreateSurface( - loader.cobj(), view.cobj(), instance, allocator, surface); + vkGetInstanceProcAddr, view.cobj(), instance, allocator, surface); return (!r && !surface) ? VK_ERROR_INITIALIZATION_FAILED : r; } diff --git a/examples/pugl_vulkan_cxx_demo.cpp b/examples/pugl_vulkan_cxx_demo.cpp index 7a4e5cb..6da5e5a 100644 --- a/examples/pugl_vulkan_cxx_demo.cpp +++ b/examples/pugl_vulkan_cxx_demo.cpp @@ -417,8 +417,11 @@ GraphicsDevice::init(const pugl::VulkanLoader& loader, // Create a Vulkan surface for the window using the Pugl API VkSurfaceKHR surfaceHandle = {}; - if ((r = pugl::createSurface( - loader, view, context.instance, nullptr, &surfaceHandle))) { + if ((r = pugl::createSurface(loader.getInstanceProcAddrFunc(), + view, + context.instance, + nullptr, + &surfaceHandle))) { return r; } diff --git a/examples/pugl_vulkan_demo.c b/examples/pugl_vulkan_demo.c index a65731b..3f684fe 100644 --- a/examples/pugl_vulkan_demo.c +++ b/examples/pugl_vulkan_demo.c @@ -1100,8 +1100,11 @@ main(int argc, char** argv) // Create Vulkan surface for Window PuglVulkanLoader* loader = puglNewVulkanLoader(app.world); - if (puglCreateSurface( - loader, app.view, vk->instance, ALLOC_VK, &vk->surface)) { + if (puglCreateSurface(puglGetInstanceProcAddrFunc(loader), + app.view, + vk->instance, + ALLOC_VK, + &vk->surface)) { return logError("Failed to create surface\n"); } diff --git a/include/pugl/vulkan.h b/include/pugl/vulkan.h index 487ecda..05e13e2 100644 --- a/include/pugl/vulkan.h +++ b/include/pugl/vulkan.h @@ -117,7 +117,7 @@ puglGetInstanceExtensions(uint32_t* count); /** Create a Vulkan surface for a Pugl view. - @param loader The loader for Vulkan functions. + @param vkGetInstanceProcAddr Accessor for Vulkan functions. @param view The view the surface is to be displayed on. @param instance The Vulkan instance. @param allocator Vulkan allocation callbacks, may be NULL. @@ -125,7 +125,7 @@ puglGetInstanceExtensions(uint32_t* count); @return `VK_SUCCESS` on success, or a Vulkan error code. */ PUGL_API VkResult -puglCreateSurface(const PuglVulkanLoader* loader, +puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, PuglView* view, VkInstance instance, const VkAllocationCallbacks* allocator, diff --git a/src/mac_vulkan.m b/src/mac_vulkan.m index 39c7f29..2d01fd4 100644 --- a/src/mac_vulkan.m +++ b/src/mac_vulkan.m @@ -194,7 +194,7 @@ puglGetInstanceExtensions(uint32_t* const count) } VkResult -puglCreateSurface(const PuglVulkanLoader* const loader, +puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, PuglView* const view, VkInstance instance, const VkAllocationCallbacks* const allocator, @@ -203,8 +203,8 @@ puglCreateSurface(const PuglVulkanLoader* const loader, PuglInternals* const impl = view->impl; PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK = - (PFN_vkCreateMacOSSurfaceMVK)puglGetInstanceProcAddrFunc( - loader)(instance, "vkCreateMacOSSurfaceMVK"); + (PFN_vkCreateMacOSSurfaceMVK) + vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); const VkMacOSSurfaceCreateInfoMVK info = { VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK, diff --git a/src/win_vulkan.c b/src/win_vulkan.c index eb20698..3d6934a 100644 --- a/src/win_vulkan.c +++ b/src/win_vulkan.c @@ -107,7 +107,7 @@ puglGetInstanceExtensions(uint32_t* const count) } VkResult -puglCreateSurface(const PuglVulkanLoader* const loader, +puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, PuglView* const view, VkInstance instance, const VkAllocationCallbacks* const pAllocator, @@ -116,8 +116,8 @@ puglCreateSurface(const PuglVulkanLoader* const loader, PuglInternals* const impl = view->impl; PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = - (PFN_vkCreateWin32SurfaceKHR)puglGetInstanceProcAddrFunc(loader)( - instance, "vkCreateWin32SurfaceKHR"); + (PFN_vkCreateWin32SurfaceKHR) + vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR"); const VkWin32SurfaceCreateInfoKHR createInfo = { VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, diff --git a/src/x11_vulkan.c b/src/x11_vulkan.c index 7004fd8..c7ae1b0 100644 --- a/src/x11_vulkan.c +++ b/src/x11_vulkan.c @@ -110,7 +110,7 @@ puglGetInstanceExtensions(uint32_t* const count) } VkResult -puglCreateSurface(const PuglVulkanLoader* const loader, +puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, PuglView* const view, VkInstance instance, const VkAllocationCallbacks* const allocator, @@ -120,8 +120,8 @@ puglCreateSurface(const PuglVulkanLoader* const loader, PuglWorldInternals* world_impl = view->world->impl; PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = - (PFN_vkCreateXlibSurfaceKHR)puglGetInstanceProcAddrFunc(loader)( - instance, "vkCreateXlibSurfaceKHR"); + (PFN_vkCreateXlibSurfaceKHR) + vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR"); const VkXlibSurfaceCreateInfoKHR info = { VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, @@ -134,6 +134,7 @@ def configure(conf): '/wd4868', # may not enforce left-to-right evaluation order '/wd5026', # move constructor implicitly deleted '/wd5027', # move assignment operator implicitly deleted + '/wd5039', # pointer to throwing function passed to C function ], }) |