| 20 | #endif |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | try |
| 25 | { |
| 26 | // three equivalent minimal initializations of the default dispatcher... you just need to use one of them |
| 27 | |
| 28 | // initialize minimal set of function pointers |
| 29 | vk::detail::defaultDispatchLoaderDynamic.init(); |
| 30 | |
| 31 | // the same initialization, now with explicitly providing a DynamicLoader |
| 32 | vk::detail::DynamicLoader dl; |
| 33 | vk::detail::defaultDispatchLoaderDynamic.init( dl ); |
| 34 | |
| 35 | // the same initialization, now with explicitly providing the initial function pointer |
| 36 | PFN_vkGetInstanceProcAddr getInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>( "vkGetInstanceProcAddr" ); |
| 37 | vk::detail::defaultDispatchLoaderDynamic.init( getInstanceProcAddr ); |
| 38 | |
| 39 | vk::Instance instance = vk::createInstance( {}, nullptr ); |
| 40 | |
| 41 | // initialize function pointers for instance |
| 42 | vk::detail::defaultDispatchLoaderDynamic.init( instance ); |
| 43 | |
| 44 | // create a dispatcher, based on additional vkDevice/vkGetDeviceProcAddr |
| 45 | std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices(); |
| 46 | release_assert( !physicalDevices.empty() ); |
| 47 | |
| 48 | vk::Device device = physicalDevices[0].createDevice( {}, nullptr ); |
| 49 | |
| 50 | // optional function pointer specialization for device |
| 51 | vk::detail::defaultDispatchLoaderDynamic.init( device ); |
| 52 | } |
| 53 | catch ( vk::SystemError const & err ) |
| 54 | { |
| 55 | std::cout << "vk::SystemError: " << err.what() << std::endl; |
| 56 | std::exit( -1 ); |
| 57 | } |
| 58 | catch ( ... ) |
| 59 | { |
| 60 | std::cout << "unknown error\n"; |
| 61 | std::exit( -1 ); |
| 62 | } |
| 63 | |
| 64 | return 0; |
| 65 | } |
nothing calls this directly
no test coverage detected