| 1 | #include <stdexcept> |
| 2 | |
| 3 | #define DECLARE(func) PFN_vk##func func = (PFN_vk##func)GetInstanceProcAddr(*pInstance, "vk" #func); |
| 4 | //#define FORWARD(func) dispatchTable.func = (PFN_vk##func)gpa(*pInstance, "vk" #func); |
| 5 | |
| 6 | struct PvkInstanceDispatchTable { |
| 7 | VkInstance *pInstance; |
| 8 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
| 9 | PvkInstanceDispatchTable(VkInstance *pInstance, PFN_vkGetInstanceProcAddr gpa): |
| 10 | pInstance(pInstance), GetInstanceProcAddr(gpa) { |
| 11 | } |
| 12 | PvkInstanceDispatchTable() { |
| 13 | throw std::logic_error("Accessing un-fetched instance dispatch table"); |
| 14 | } |
| 15 | DECLARE(EnumeratePhysicalDevices); |
| 16 | DECLARE(DestroyInstance); |
| 17 | DECLARE(EnumerateDeviceExtensionProperties); |
| 18 | DECLARE(GetPhysicalDeviceProperties); |
| 19 | DECLARE(GetPhysicalDeviceMemoryProperties); |
| 20 | DECLARE(GetPhysicalDeviceQueueFamilyProperties); |
| 21 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 22 | DECLARE(GetPhysicalDeviceXcbPresentationSupportKHR); |
| 23 | #endif |
| 24 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 25 | DECLARE(GetPhysicalDeviceXlibPresentationSupportKHR); |
| 26 | #endif |
| 27 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 28 | DECLARE(GetPhysicalDeviceWaylandPresentationSupportKHR); |
| 29 | #endif |
| 30 | DECLARE(GetPhysicalDeviceSurfaceSupportKHR); |
| 31 | #define FORWARD(func) DECLARE(func) |
| 32 | #include "primus_vk_forwarding.h" |
| 33 | #undef FORWARD |
| 34 | |
| 35 | }; |
| 36 | #undef DECLARE |
| 37 | |
| 38 | #define DECLARE(func) PFN_vk##func func = (PFN_vk##func)GetDeviceProcAddr(*pDevice, "vk" #func); |
| 39 | struct PvkDispatchTable { |
| 40 | VkDevice *pDevice; |
| 41 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
| 42 | |
| 43 | PvkDispatchTable(VkDevice *pDevice, PFN_vkGetDeviceProcAddr gdpa): |
| 44 | pDevice(pDevice), GetDeviceProcAddr(gdpa){ |
| 45 | } |
| 46 | PvkDispatchTable() { |
| 47 | throw std::logic_error("Accessing un-fetched dispatch table"); |
| 48 | } |
| 49 | |
| 50 | DECLARE(DestroyDevice); |
| 51 | |
| 52 | DECLARE(CreateSwapchainKHR); |
| 53 | DECLARE(DestroySwapchainKHR); |
| 54 | DECLARE(GetSwapchainImagesKHR); |
| 55 | DECLARE(AcquireNextImageKHR); |
| 56 | DECLARE(GetSwapchainStatusKHR); |
| 57 | DECLARE(QueuePresentKHR); |
| 58 | |
| 59 | DECLARE(CreateImage); |
| 60 | DECLARE(GetImageMemoryRequirements); |
| 61 | DECLARE(AllocateMemory); |
| 62 | DECLARE(BindImageMemory); |
| 63 | DECLARE(GetImageSubresourceLayout); |
| 64 | DECLARE(FreeMemory); |
| 65 | DECLARE(DestroyImage); |
| 66 | DECLARE(MapMemory); |
| 67 | DECLARE(UnmapMemory); |
| 68 | |
| 69 | |
| 70 | DECLARE(AllocateCommandBuffers); |
| 71 | DECLARE(BeginCommandBuffer); |
| 72 | DECLARE(CmdDraw); |
| 73 | DECLARE(CmdDrawIndexed); |
| 74 | DECLARE(CmdCopyImage); |
| 75 | DECLARE(CmdPipelineBarrier); |
| 76 | DECLARE(CreateCommandPool); |
| 77 | //DECLARE(CreateDevice); |
| 78 | DECLARE(EndCommandBuffer); |
| 79 | //DECLARE(EnumeratePhysicalDevices); |
| 80 | DECLARE(FreeCommandBuffers); |
| 81 | DECLARE(DestroyCommandPool); |
| 82 | //DECLARE(GetPhysicalDeviceMemoryProperties); |
| 83 | DECLARE(QueueSubmit); |
| 84 | DECLARE(DeviceWaitIdle); |
| 85 | DECLARE(QueueWaitIdle); |
| 86 | |
| 87 | DECLARE(GetDeviceQueue); |
| 88 | |
| 89 | DECLARE(CreateFence); |
| 90 | DECLARE(WaitForFences); |
| 91 | DECLARE(ResetFences); |
| 92 | DECLARE(DestroyFence); |
| 93 | |
| 94 | DECLARE(CreateSemaphore); |
| 95 | DECLARE(DestroySemaphore); |
| 96 | |
| 97 | DECLARE(InvalidateMappedMemoryRanges); |
| 98 | |
| 99 | }; |
| 100 | |
| 101 | #undef DECLARE |