summaryrefslogtreecommitdiffstats
path: root/src/vulkan/wsi/wsi_common.h
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2017-01-10 13:23:06 -0800
committerChad Versace <[email protected]>2017-01-12 09:42:32 -0800
commitc085bfcec9915879e97a33c5235cf21607c72318 (patch)
treee584bf514b0c4856f8b5c5f0c4ebfdb6a2af0b3f /src/vulkan/wsi/wsi_common.h
parenta61528fa33f8d7f39167e62da6d9317ed84c43b8 (diff)
vulkan: Add new cast macros for VkIcd types
We can't import the latest vk_icd.h because the new header breaks the Mesa build. This patch defines new casting macros, ICD_DEFINE_NONDISP_HANDLE_CASTS() and ICD_FROM_HANDLE(), which can handle both the old and new vk_icd.h, and will prevent the build from breaking when we update the header. In the old vk_icd.h, types were defined as: typedef struct _VkIcdFoo { ... } VkIcdFoo; Commit 6ebba1f6 in the Vulkan loader changed the above to typedef { ... } VkIcdFoo; because the old definitions violated the C and C++ specs. According to the specs, identifiers that begins with an underscore followed by an uppercase letter are reserved. (It's pedantic, I know), See the Github issue referenced below. References: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/7 References: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/commit/6ebba1f630015af7a78767a15c1e74ba9b23601c Reviewed-by: Emil Velikov <[email protected]> Cc: [email protected]
Diffstat (limited to 'src/vulkan/wsi/wsi_common.h')
-rw-r--r--src/vulkan/wsi/wsi_common.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index a1f5a40186c..394b8fa1914 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -116,9 +116,27 @@ struct wsi_callbacks {
return (__VkType)(uintptr_t) _obj; \
}
-WSI_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, VkSwapchainKHR)
+#define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType) \
+ \
+ static inline __VkIcdType * \
+ __VkIcdType ## _from_handle(__VkType _handle) \
+ { \
+ return (__VkIcdType *)(uintptr_t) _handle; \
+ } \
+ \
+ static inline __VkType \
+ __VkIcdType ## _to_handle(__VkIcdType *_obj) \
+ { \
+ return (__VkType)(uintptr_t) _obj; \
+ }
+
+#define ICD_FROM_HANDLE(__VkIcdType, __name, __handle) \
+ __VkIcdType *__name = __VkIcdType ## _from_handle(__handle)
+
+ICD_DEFINE_NONDISP_HANDLE_CASTS(VkIcdSurfaceBase, VkSurfaceKHR)
+
VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
void wsi_x11_finish_wsi(struct wsi_device *wsi_device,