Timo Aaltonen pushed to branch upstream-unstable at X Strike Force / vulkan / vulkan-loader
Commits:
-
899db919
by Kevin McCullough at 2022-02-16T13:51:52-07:00
-
f3e99513
by Kevin McCullough at 2022-02-16T13:52:00-07:00
6 changed files:
- loader/generated/vk_loader_extensions.c
- loader/generated/vk_loader_extensions.h
- loader/loader_common.h
- loader/wsi.c
- loader/wsi.h
- scripts/loader_extension_generator.py
Changes:
... | ... | @@ -4113,42 +4113,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV( |
4113 | 4113 | |
4114 | 4114 | #endif // VK_USE_PLATFORM_WIN32_KHR
|
4115 | 4115 | |
4116 | -// ---- VK_NN_vi_surface extension trampoline/terminators
|
|
4117 | - |
|
4118 | -#ifdef VK_USE_PLATFORM_VI_NN
|
|
4119 | -VKAPI_ATTR VkResult VKAPI_CALL CreateViSurfaceNN(
|
|
4120 | - VkInstance instance,
|
|
4121 | - const VkViSurfaceCreateInfoNN* pCreateInfo,
|
|
4122 | - const VkAllocationCallbacks* pAllocator,
|
|
4123 | - VkSurfaceKHR* pSurface) {
|
|
4124 | - struct loader_instance *inst = loader_get_instance(instance);
|
|
4125 | - if (NULL == inst) {
|
|
4126 | - loader_log(
|
|
4127 | - NULL, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
|
|
4128 | - "vkCreateViSurfaceNN: Invalid instance [VUID-vkCreateViSurfaceNN-instance-parameter]");
|
|
4129 | - abort(); /* Intentionally fail so user can correct issue. */
|
|
4130 | - }
|
|
4131 | -#error("Not implemented. Likely needs to be manually generated!");
|
|
4132 | - return inst->disp->CreateViSurfaceNN(instance, pCreateInfo, pAllocator, pSurface);
|
|
4133 | -}
|
|
4134 | - |
|
4135 | -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(
|
|
4136 | - VkInstance instance,
|
|
4137 | - const VkViSurfaceCreateInfoNN* pCreateInfo,
|
|
4138 | - const VkAllocationCallbacks* pAllocator,
|
|
4139 | - VkSurfaceKHR* pSurface) {
|
|
4140 | - struct loader_instance *inst = loader_get_instance(instance);
|
|
4141 | - if (NULL == inst) {
|
|
4142 | - loader_log(
|
|
4143 | - NULL, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
|
|
4144 | - "vkCreateViSurfaceNN: Invalid instance [VUID-vkCreateViSurfaceNN-instance-parameter]");
|
|
4145 | - abort(); /* Intentionally fail so user can correct issue. */
|
|
4146 | - }
|
|
4147 | -#error("Not implemented. Likely needs to be manually generated!");
|
|
4148 | -}
|
|
4149 | - |
|
4150 | -#endif // VK_USE_PLATFORM_VI_NN
|
|
4151 | - |
|
4152 | 4116 | // ---- VK_EXT_conditional_rendering extension trampoline/terminators
|
4153 | 4117 | |
4154 | 4118 | VKAPI_ATTR void VKAPI_CALL CmdBeginConditionalRenderingEXT(
|
... | ... | @@ -7315,16 +7279,6 @@ bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *na |
7315 | 7279 | }
|
7316 | 7280 | #endif // VK_USE_PLATFORM_WIN32_KHR
|
7317 | 7281 | |
7318 | - // ---- VK_NN_vi_surface extension commands
|
|
7319 | -#ifdef VK_USE_PLATFORM_VI_NN
|
|
7320 | - if (!strcmp("vkCreateViSurfaceNN", name)) {
|
|
7321 | - *addr = (ptr_instance->enabled_known_extensions.nn_vi_surface == 1)
|
|
7322 | - ? (void *)CreateViSurfaceNN
|
|
7323 | - : NULL;
|
|
7324 | - return true;
|
|
7325 | - }
|
|
7326 | -#endif // VK_USE_PLATFORM_VI_NN
|
|
7327 | - |
|
7328 | 7282 | // ---- VK_EXT_conditional_rendering extension commands
|
7329 | 7283 | if (!strcmp("vkCmdBeginConditionalRenderingEXT", name)) {
|
7330 | 7284 | *addr = (void *)CmdBeginConditionalRenderingEXT;
|
... | ... | @@ -8121,12 +8075,6 @@ void extensions_create_instance(struct loader_instance *ptr_instance, const VkIn |
8121 | 8075 | } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) {
|
8122 | 8076 | ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 1;
|
8123 | 8077 | |
8124 | - // ---- VK_NN_vi_surface extension commands
|
|
8125 | -#ifdef VK_USE_PLATFORM_VI_NN
|
|
8126 | - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NN_VI_SURFACE_EXTENSION_NAME)) {
|
|
8127 | - ptr_instance->enabled_known_extensions.nn_vi_surface = 1;
|
|
8128 | -#endif // VK_USE_PLATFORM_VI_NN
|
|
8129 | - |
|
8130 | 8078 | // ---- VK_EXT_direct_mode_display extension commands
|
8131 | 8079 | } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME)) {
|
8132 | 8080 | ptr_instance->enabled_known_extensions.ext_direct_mode_display = 1;
|
... | ... | @@ -482,7 +482,6 @@ union loader_instance_extension_enables { |
482 | 482 | uint8_t khr_external_fence_capabilities : 1;
|
483 | 483 | uint8_t ext_debug_report : 1;
|
484 | 484 | uint8_t nv_external_memory_capabilities : 1;
|
485 | - uint8_t nn_vi_surface : 1;
|
|
486 | 485 | uint8_t ext_direct_mode_display : 1;
|
487 | 486 | uint8_t ext_acquire_xlib_display : 1;
|
488 | 487 | uint8_t ext_display_surface_counter : 1;
|
... | ... | @@ -329,6 +329,9 @@ struct loader_instance { |
329 | 329 | #endif
|
330 | 330 | #ifdef VK_USE_PLATFORM_SCREEN_QNX
|
331 | 331 | bool wsi_screen_surface_enabled;
|
332 | +#endif
|
|
333 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
334 | + bool wsi_vi_surface_enabled;
|
|
332 | 335 | #endif
|
333 | 336 | bool wsi_display_enabled;
|
334 | 337 | bool wsi_display_props2_enabled;
|
... | ... | @@ -120,6 +120,12 @@ void wsi_create_instance(struct loader_instance *loader_inst, const VkInstanceCr |
120 | 120 | continue;
|
121 | 121 | }
|
122 | 122 | #endif // VK_USE_PLATFORM_SCREEN_QNX
|
123 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
124 | + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NN_VI_SURFACE_EXTENSION_NAME) == 0) {
|
|
125 | + loader_inst->wsi_vi_surface_enabled = true;
|
|
126 | + continue;
|
|
127 | + }
|
|
128 | +#endif // VK_USE_PLATFORM_VI_NN
|
|
123 | 129 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
|
124 | 130 | loader_inst->wsi_display_enabled = true;
|
125 | 131 | continue;
|
... | ... | @@ -1655,6 +1661,85 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceScreenPresentationSup |
1655 | 1661 | }
|
1656 | 1662 | #endif // VK_USE_PLATFORM_SCREEN_QNX
|
1657 | 1663 | |
1664 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
1665 | + |
|
1666 | +// Functions for the VK_NN_vi_surface extension:
|
|
1667 | + |
|
1668 | +// This is the trampoline entrypoint for CreateViSurfaceNN
|
|
1669 | +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(VkInstance instance,
|
|
1670 | + const VkViSurfaceCreateInfoNN* pCreateInfo,
|
|
1671 | + const VkAllocationCallbacks* pAllocator,
|
|
1672 | + VkSurfaceKHR* pSurface) {
|
|
1673 | + struct loader_instance* loader_inst = loader_get_instance(instance);
|
|
1674 | + if (NULL == loader_inst) {
|
|
1675 | + loader_log(NULL, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
|
|
1676 | + "vkCreateViSurfaceNN: Invalid instance [VUID-vkCreateViSurfaceNN-instance-parameter]");
|
|
1677 | + abort(); /* Intentionally fail so user can correct issue. */
|
|
1678 | + }
|
|
1679 | + return loader_inst->disp->layer_inst_disp.CreateViSurfaceNN(loader_inst->instance, pCreateInfo, pAllocator, pSurface);
|
|
1680 | +}
|
|
1681 | + |
|
1682 | +// This is the instance chain terminator function for CreateViSurfaceNN
|
|
1683 | +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo,
|
|
1684 | + const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
|
|
1685 | + VkResult vkRes = VK_SUCCESS;
|
|
1686 | + VkIcdSurface *pIcdSurface = NULL;
|
|
1687 | + uint32_t i = 0;
|
|
1688 | + |
|
1689 | + // First, check to ensure the appropriate extension was enabled:
|
|
1690 | + struct loader_instance *loader_inst = loader_get_instance(instance);
|
|
1691 | + if (!loader_inst->wsi_vi_surface_enabled) {
|
|
1692 | + loader_log(loader_inst, VULKAN_LOADER_ERROR_BIT, 0,
|
|
1693 | + "VK_NN_vi_surface extension not enabled. vkCreateViSurfaceNN not executed!\n");
|
|
1694 | + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
1695 | + goto out;
|
|
1696 | + }
|
|
1697 | + |
|
1698 | + // Next, if so, proceed with the implementation of this function:
|
|
1699 | + pIcdSurface = AllocateIcdSurfaceStruct(loader_inst, sizeof(pIcdSurface->vi_surf.base), sizeof(pIcdSurface->vi_surf));
|
|
1700 | + if (pIcdSurface == NULL) {
|
|
1701 | + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
1702 | + goto out;
|
|
1703 | + }
|
|
1704 | + |
|
1705 | + pIcdSurface->vi_surf.base.platform = VK_ICD_WSI_PLATFORM_VI;
|
|
1706 | + pIcdSurface->vi_surf.window = pCreateInfo->window;
|
|
1707 | + |
|
1708 | + // Loop through each ICD and determine if they need to create a surface
|
|
1709 | + for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) {
|
|
1710 | + if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
|
|
1711 | + if (NULL != icd_term->dispatch.CreateViSurfaceNN) {
|
|
1712 | + vkRes = icd_term->dispatch.CreateViSurfaceNN(icd_term->instance, pCreateInfo, pAllocator,
|
|
1713 | + &pIcdSurface->real_icd_surfaces[i]);
|
|
1714 | + if (VK_SUCCESS != vkRes) {
|
|
1715 | + goto out;
|
|
1716 | + }
|
|
1717 | + }
|
|
1718 | + }
|
|
1719 | + }
|
|
1720 | + |
|
1721 | + *pSurface = (VkSurfaceKHR)pIcdSurface;
|
|
1722 | + |
|
1723 | +out:
|
|
1724 | + |
|
1725 | + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
|
|
1726 | + if (NULL != pIcdSurface->real_icd_surfaces) {
|
|
1727 | + i = 0;
|
|
1728 | + for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) {
|
|
1729 | + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) {
|
|
1730 | + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
|
|
1731 | + }
|
|
1732 | + }
|
|
1733 | + loader_instance_heap_free(loader_inst, pIcdSurface->real_icd_surfaces);
|
|
1734 | + }
|
|
1735 | + loader_instance_heap_free(loader_inst, pIcdSurface);
|
|
1736 | + }
|
|
1737 | + |
|
1738 | + return vkRes;
|
|
1739 | +}
|
|
1740 | + |
|
1741 | +#endif // VK_USE_PLATFORM_VI_NN
|
|
1742 | + |
|
1658 | 1743 | // Functions for the VK_KHR_display instance extension:
|
1659 | 1744 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
|
1660 | 1745 | uint32_t *pPropertyCount,
|
... | ... | @@ -2760,6 +2845,15 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *loader_inst, const char |
2760 | 2845 | }
|
2761 | 2846 | #endif // VK_USE_PLATFORM_SCREEN_QNX
|
2762 | 2847 | |
2848 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
2849 | + |
|
2850 | + // Functions for the VK_NN_vi_surface extension:
|
|
2851 | + if (!strcmp("vkCreateViSurfaceNN", name)) {
|
|
2852 | + *addr = loader_inst->wsi_vi_surface_enabled ? (void *)vkCreateViSurfaceNN : NULL;
|
|
2853 | + return true;
|
|
2854 | + }
|
|
2855 | +#endif // VK_USE_PLATFORM_VI_NN
|
|
2856 | + |
|
2763 | 2857 | // Functions for VK_KHR_display extension:
|
2764 | 2858 | if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
|
2765 | 2859 | *addr = loader_inst->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR : NULL;
|
... | ... | @@ -56,6 +56,9 @@ typedef struct { |
56 | 56 | #ifdef VK_USE_PLATFORM_SCREEN_QNX
|
57 | 57 | VkIcdSurfaceScreen screen_surf;
|
58 | 58 | #endif // VK_USE_PLATFORM_SCREEN_QNX
|
59 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
60 | + VkIcdSurfaceVi vi_surf;
|
|
61 | +#endif // VK_USE_PLATFORM_VI_NN
|
|
59 | 62 | VkIcdSurfaceDisplay display_surf;
|
60 | 63 | VkIcdSurfaceHeadless headless_surf;
|
61 | 64 | };
|
... | ... | @@ -163,6 +166,10 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceScreenPresentationSup |
163 | 166 | uint32_t queueFamilyIndex,
|
164 | 167 | struct _screen_window *window);
|
165 | 168 | #endif // VK_USE_PLATFORM_SCREEN_QNX
|
169 | +#ifdef VK_USE_PLATFORM_VI_NN
|
|
170 | +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(VkInstance instance, const VkViSurfaceCreateInfoNN *pCreateInfo,
|
|
171 | + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
|
|
172 | +#endif // VK_USE_PLATFORM_VI_NN
|
|
166 | 173 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
|
167 | 174 | uint32_t *pPropertyCount,
|
168 | 175 | VkDisplayPropertiesKHR *pProperties);
|
... | ... | @@ -45,7 +45,8 @@ WSI_EXT_NAMES = ['VK_KHR_surface', |
45 | 45 | 'VK_KHR_display_swapchain',
|
46 | 46 | 'VK_KHR_get_display_properties2',
|
47 | 47 | 'VK_KHR_get_surface_capabilities2',
|
48 | - 'VK_QNX_screen_surface']
|
|
48 | + 'VK_QNX_screen_surface',
|
|
49 | + 'VK_NN_vi_surface']
|
|
49 | 50 | |
50 | 51 | ADD_INST_CMDS = ['vkCreateInstance',
|
51 | 52 | 'vkEnumerateInstanceExtensionProperties',
|