From: Ian Elliott Date: Mon, 22 Jun 2015 21:07:49 +0000 (-0600) Subject: tri/cube: Convert GPA usage/error-checking/reporting to a macro. X-Git-Tag: submit/tizen/20181227.054638~5409 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=673898b8799cb4c21e8cb763e98ec4861f449468;p=platform%2Fupstream%2FVulkan-Tools.git tri/cube: Convert GPA usage/error-checking/reporting to a macro. --- diff --git a/demos/cube.c b/demos/cube.c index 40e18d80..633cc4c7 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -78,6 +78,15 @@ } while (0) #endif // _WIN32 +#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ +{ \ + demo->fp##entrypoint = vkGetDeviceProcAddr(dev, "vk"#entrypoint); \ + if (demo->fp##entrypoint == NULL) { \ + ERR_EXIT("vkGetDeviceProcAddr failed to find vk"#entrypoint, \ + "vkGetDeviceProcAddr Failure"); \ + } \ +} + /* * structure to track all objects related to a texture. */ @@ -1983,22 +1992,11 @@ static void demo_init_vk(struct demo *demo) err = vkCreateDevice(demo->gpu, &device, &demo->device); assert(!err); - demo->fpCreateSwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkCreateSwapChainWSI"); - if (demo->fpCreateSwapChainWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkCreateSwapChainWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpDestroySwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkDestroySwapChainWSI"); - if (demo->fpDestroySwapChainWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkDestroySwapChainWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpGetSwapChainInfoWSI = vkGetDeviceProcAddr(demo->device, "vkGetSwapChainInfoWSI"); - if (demo->fpGetSwapChainInfoWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkGetSwapChainInfoWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpQueuePresentWSI = vkGetDeviceProcAddr(demo->device, "vkQueuePresentWSI"); - if (demo->fpQueuePresentWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkQueuePresentWSI", - "vkGetDeviceProcAddr Failure"); + GET_DEVICE_PROC_ADDR(demo->device, CreateSwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, CreateSwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, DestroySwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, GetSwapChainInfoWSI); + GET_DEVICE_PROC_ADDR(demo->device, QueuePresentWSI); err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, &data_size, NULL); diff --git a/demos/tri.c b/demos/tri.c index 7ab1005f..fd24944e 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -79,6 +79,15 @@ } while (0) #endif // _WIN32 +#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ +{ \ + demo->fp##entrypoint = vkGetDeviceProcAddr(dev, "vk"#entrypoint); \ + if (demo->fp##entrypoint == NULL) { \ + ERR_EXIT("vkGetDeviceProcAddr failed to find vk"#entrypoint, \ + "vkGetDeviceProcAddr Failure"); \ + } \ +} + struct texture_object { VkSampler sampler; @@ -1430,23 +1439,6 @@ static void demo_init_vk(struct demo *demo) "vkCreateInstance Failure"); } - demo->fpCreateSwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkCreateSwapChainWSI"); - if (demo->fpCreateSwapChainWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkCreateSwapChainWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpDestroySwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkDestroySwapChainWSI"); - if (demo->fpDestroySwapChainWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkDestroySwapChainWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpGetSwapChainInfoWSI = vkGetDeviceProcAddr(demo->device, "vkGetSwapChainInfoWSI"); - if (demo->fpGetSwapChainInfoWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkGetSwapChainInfoWSI", - "vkGetDeviceProcAddr Failure"); - demo->fpQueuePresentWSI = vkGetDeviceProcAddr(demo->device, "vkQueuePresentWSI"); - if (demo->fpQueuePresentWSI == NULL) - ERR_EXIT("vkGetDeviceProcAddr failed to find vkQueuePresentWSI", - "vkGetDeviceProcAddr Failure"); - gpu_count = 1; err = vkEnumeratePhysicalDevices(demo->inst, &gpu_count, &demo->gpu); assert(!err && gpu_count == 1); @@ -1454,6 +1446,12 @@ static void demo_init_vk(struct demo *demo) err = vkCreateDevice(demo->gpu, &device, &demo->device); assert(!err); + GET_DEVICE_PROC_ADDR(demo->device, CreateSwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, CreateSwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, DestroySwapChainWSI); + GET_DEVICE_PROC_ADDR(demo->device, GetSwapChainInfoWSI); + GET_DEVICE_PROC_ADDR(demo->device, QueuePresentWSI); + err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, &data_size, NULL); assert(!err);