Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 19 | */ |
| 20 | |
| 21 | #define _GNU_SOURCE |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | #include "vk_loader_platform.h" |
| 26 | #include "loader.h" |
| 27 | #include "extensions.h" |
| 28 | #include <vulkan/vk_icd.h> |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 29 | #include "wsi.h" |
| 30 | |
| 31 | // Definitions for the VK_EXT_debug_marker extension commands which |
| 32 | // need to have a terminator function |
| 33 | |
| 34 | VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( |
| 35 | VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { |
| 36 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 37 | // If this is a physical device, we have to replace it with the proper one |
| 38 | // for the next call. |
| 39 | if (pTagInfo->objectType == |
| 40 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { |
| 41 | struct loader_physical_device_tramp *phys_dev_tramp = |
Karl Schultz | 9497129 | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 42 | (struct loader_physical_device_tramp *)(uintptr_t)pTagInfo->object; |
| 43 | pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 44 | } |
| 45 | return disp->DebugMarkerSetObjectTagEXT(device, pTagInfo); |
| 46 | } |
| 47 | |
| 48 | VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT( |
| 49 | VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { |
| 50 | uint32_t icd_index = 0; |
| 51 | struct loader_device *dev; |
| 52 | struct loader_icd_term *icd_term = |
| 53 | loader_get_icd_and_device(device, &dev, &icd_index); |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 54 | if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectTagEXT) { |
| 55 | // If this is a physical device, we have to replace it with the proper |
| 56 | // one for the next call. |
| 57 | if (pTagInfo->objectType == |
| 58 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { |
| 59 | struct loader_physical_device_term *phys_dev_term = |
| 60 | (struct loader_physical_device_term *)(uintptr_t) |
| 61 | pTagInfo->object; |
| 62 | pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 63 | |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 64 | // If this is a KHR_surface, and the ICD has created its own, we |
| 65 | // have to replace it with the proper one for the next call. |
| 66 | } else if (pTagInfo->objectType == |
| 67 | VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { |
| 68 | if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { |
| 69 | VkIcdSurface *icd_surface = |
| 70 | (VkIcdSurface *)(uintptr_t)pTagInfo->object; |
| 71 | if (NULL != icd_surface->real_icd_surfaces) { |
| 72 | pTagInfo->object = |
| 73 | (uint64_t)icd_surface->real_icd_surfaces[icd_index]; |
| 74 | } |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 77 | return icd_term->DebugMarkerSetObjectTagEXT(device, pTagInfo); |
| 78 | } else { |
| 79 | return VK_SUCCESS; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 80 | } |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( |
| 84 | VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
| 85 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 86 | // If this is a physical device, we have to replace it with the proper one |
| 87 | // for the next call. |
| 88 | if (pNameInfo->objectType == |
| 89 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { |
| 90 | struct loader_physical_device_tramp *phys_dev_tramp = |
Karl Schultz | 9497129 | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 91 | (struct loader_physical_device_tramp *)(uintptr_t)pNameInfo->object; |
| 92 | pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 93 | } |
| 94 | return disp->DebugMarkerSetObjectNameEXT(device, pNameInfo); |
| 95 | } |
| 96 | |
| 97 | VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT( |
| 98 | VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
| 99 | uint32_t icd_index = 0; |
| 100 | struct loader_device *dev; |
| 101 | struct loader_icd_term *icd_term = |
| 102 | loader_get_icd_and_device(device, &dev, &icd_index); |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 103 | if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectNameEXT) { |
| 104 | // If this is a physical device, we have to replace it with the proper |
| 105 | // one for the next call. |
| 106 | if (pNameInfo->objectType == |
| 107 | VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { |
| 108 | struct loader_physical_device_term *phys_dev_term = |
| 109 | (struct loader_physical_device_term *)(uintptr_t) |
| 110 | pNameInfo->object; |
| 111 | pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 112 | |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 113 | // If this is a KHR_surface, and the ICD has created its own, we |
| 114 | // have to replace it with the proper one for the next call. |
| 115 | } else if (pNameInfo->objectType == |
| 116 | VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { |
| 117 | if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { |
| 118 | VkIcdSurface *icd_surface = |
| 119 | (VkIcdSurface *)(uintptr_t)pNameInfo->object; |
| 120 | if (NULL != icd_surface->real_icd_surfaces) { |
| 121 | pNameInfo->object = |
| 122 | (uint64_t)( |
| 123 | uintptr_t)icd_surface->real_icd_surfaces[icd_index]; |
| 124 | } |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 125 | } |
| 126 | } |
Mark Young | a095cca | 2016-12-02 15:02:52 -0700 | [diff] [blame] | 127 | return icd_term->DebugMarkerSetObjectNameEXT(device, pNameInfo); |
| 128 | } else { |
| 129 | return VK_SUCCESS; |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 130 | } |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 131 | } |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 132 | |
Mark Young | 35159af | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 133 | // Definitions for the VK_NV_external_memory_capabilities extension |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 134 | |
| 135 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 136 | vkGetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 137 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 138 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 139 | VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
| 140 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 141 | const VkLayerInstanceDispatchTable *disp; |
| 142 | VkPhysicalDevice unwrapped_phys_dev = |
| 143 | loader_unwrap_physical_device(physicalDevice); |
| 144 | disp = loader_get_instance_dispatch(physicalDevice); |
| 145 | |
Mark Young | 5210abc | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 146 | return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 147 | unwrapped_phys_dev, format, type, tiling, usage, flags, |
| 148 | externalHandleType, pExternalImageFormatProperties); |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | VKAPI_ATTR VkResult VKAPI_CALL |
| 152 | terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 153 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 154 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 155 | VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
| 156 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
Mark Young | 0153e0b | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 157 | struct loader_physical_device_term *phys_dev_term = |
| 158 | (struct loader_physical_device_term *)physicalDevice; |
| 159 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 160 | |
Mark Young | 0153e0b | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 161 | if (!icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV) { |
James Jones | 389dc0c | 2016-08-18 23:41:19 +0100 | [diff] [blame] | 162 | if (externalHandleType) { |
| 163 | return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 164 | } |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 165 | |
Mark Young | 0153e0b | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 166 | if (!icd_term->GetPhysicalDeviceImageFormatProperties) { |
James Jones | 389dc0c | 2016-08-18 23:41:19 +0100 | [diff] [blame] | 167 | return VK_ERROR_INITIALIZATION_FAILED; |
| 168 | } |
| 169 | |
| 170 | pExternalImageFormatProperties->externalMemoryFeatures = 0; |
| 171 | pExternalImageFormatProperties->exportFromImportedHandleTypes = 0; |
| 172 | pExternalImageFormatProperties->compatibleHandleTypes = 0; |
| 173 | |
Mark Young | 0153e0b | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 174 | return icd_term->GetPhysicalDeviceImageFormatProperties( |
| 175 | phys_dev_term->phys_dev, format, type, tiling, usage, flags, |
James Jones | 389dc0c | 2016-08-18 23:41:19 +0100 | [diff] [blame] | 176 | &pExternalImageFormatProperties->imageFormatProperties); |
| 177 | } |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 178 | |
Mark Young | 0153e0b | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 179 | return icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 180 | phys_dev_term->phys_dev, format, type, tiling, usage, flags, |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 181 | externalHandleType, pExternalImageFormatProperties); |
| 182 | } |
| 183 | |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame] | 184 | // Definitions for the VK_AMD_draw_indirect_count extension |
| 185 | |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame] | 186 | VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( |
| 187 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 188 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 189 | uint32_t stride) { |
Mark Young | 5210abc | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 190 | const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); |
| 191 | disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, |
| 192 | countBufferOffset, maxDrawCount, stride); |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( |
| 196 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 197 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 198 | uint32_t stride) { |
Mark Young | 5210abc | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 199 | const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); |
| 200 | disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, |
| 201 | countBuffer, countBufferOffset, |
| 202 | maxDrawCount, stride); |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame] | 203 | } |
| 204 | |
Mark Lobodzinski | 5f20852 | 2016-08-29 15:36:23 -0600 | [diff] [blame] | 205 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 206 | |
| 207 | // Definitions for the VK_NV_external_memory_win32 extension |
| 208 | |
Mark Lobodzinski | 5f20852 | 2016-08-29 15:36:23 -0600 | [diff] [blame] | 209 | VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( |
| 210 | VkDevice device, VkDeviceMemory memory, |
| 211 | VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) { |
Mark Young | 5210abc | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 212 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 213 | return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); |
Mark Lobodzinski | 5f20852 | 2016-08-29 15:36:23 -0600 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 217 | |
Mark Young | fa55278 | 2016-12-12 16:14:55 -0700 | [diff] [blame] | 218 | // Definitions for the VK_NVX_device_generated_commands |
| 219 | |
| 220 | VKAPI_ATTR void VKAPI_CALL vkCmdProcessCommandsNVX( |
| 221 | VkCommandBuffer commandBuffer, |
| 222 | const VkCmdProcessCommandsInfoNVX *pProcessCommandsInfo) { |
| 223 | const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); |
| 224 | disp->CmdProcessCommandsNVX(commandBuffer, pProcessCommandsInfo); |
| 225 | } |
| 226 | |
| 227 | VKAPI_ATTR void VKAPI_CALL vkCmdReserveSpaceForCommandsNVX( |
| 228 | VkCommandBuffer commandBuffer, |
| 229 | const VkCmdReserveSpaceForCommandsInfoNVX *pReserveSpaceInfo) { |
| 230 | const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); |
| 231 | disp->CmdReserveSpaceForCommandsNVX(commandBuffer, pReserveSpaceInfo); |
| 232 | } |
| 233 | |
| 234 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNVX( |
| 235 | VkDevice device, const VkIndirectCommandsLayoutCreateInfoNVX *pCreateInfo, |
| 236 | const VkAllocationCallbacks *pAllocator, |
| 237 | VkIndirectCommandsLayoutNVX *pIndirectCommandsLayout) { |
| 238 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 239 | return disp->CreateIndirectCommandsLayoutNVX( |
| 240 | device, pCreateInfo, pAllocator, pIndirectCommandsLayout); |
| 241 | } |
| 242 | |
| 243 | VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNVX( |
| 244 | VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, |
| 245 | const VkAllocationCallbacks *pAllocator) { |
| 246 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 247 | disp->DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, |
| 248 | pAllocator); |
| 249 | } |
| 250 | |
| 251 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateObjectTableNVX( |
| 252 | VkDevice device, const VkObjectTableCreateInfoNVX *pCreateInfo, |
| 253 | const VkAllocationCallbacks *pAllocator, VkObjectTableNVX *pObjectTable) { |
| 254 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 255 | return disp->CreateObjectTableNVX(device, pCreateInfo, pAllocator, |
| 256 | pObjectTable); |
| 257 | } |
| 258 | |
| 259 | VKAPI_ATTR void VKAPI_CALL |
| 260 | vkDestroyObjectTableNVX(VkDevice device, VkObjectTableNVX objectTable, |
| 261 | const VkAllocationCallbacks *pAllocator) { |
| 262 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 263 | disp->DestroyObjectTableNVX(device, objectTable, pAllocator); |
| 264 | } |
| 265 | |
| 266 | VKAPI_ATTR VkResult VKAPI_CALL vkRegisterObjectsNVX( |
| 267 | VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, |
| 268 | const VkObjectTableEntryNVX *const *ppObjectTableEntries, |
| 269 | const uint32_t *pObjectIndices) { |
| 270 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 271 | return disp->RegisterObjectsNVX(device, objectTable, objectCount, |
| 272 | ppObjectTableEntries, pObjectIndices); |
| 273 | } |
| 274 | |
| 275 | VKAPI_ATTR VkResult VKAPI_CALL vkUnregisterObjectsNVX( |
| 276 | VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, |
| 277 | const VkObjectEntryTypeNVX *pObjectEntryTypes, |
| 278 | const uint32_t *pObjectIndices) { |
| 279 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 280 | return disp->UnregisterObjectsNVX(device, objectTable, objectCount, |
| 281 | pObjectEntryTypes, pObjectIndices); |
| 282 | } |
| 283 | |
| 284 | VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX( |
| 285 | VkPhysicalDevice physicalDevice, |
| 286 | VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, |
| 287 | VkDeviceGeneratedCommandsLimitsNVX *pLimits) { |
| 288 | const VkLayerInstanceDispatchTable *disp; |
| 289 | VkPhysicalDevice unwrapped_phys_dev = |
| 290 | loader_unwrap_physical_device(physicalDevice); |
| 291 | disp = loader_get_instance_dispatch(physicalDevice); |
| 292 | disp->GetPhysicalDeviceGeneratedCommandsPropertiesNVX(unwrapped_phys_dev, |
| 293 | pFeatures, pLimits); |
| 294 | } |
| 295 | |
| 296 | VKAPI_ATTR void VKAPI_CALL |
| 297 | terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX( |
| 298 | VkPhysicalDevice physicalDevice, |
| 299 | VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, |
| 300 | VkDeviceGeneratedCommandsLimitsNVX *pLimits) { |
| 301 | struct loader_physical_device_term *phys_dev_term = |
| 302 | (struct loader_physical_device_term *)physicalDevice; |
| 303 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 304 | if (NULL == icd_term->GetPhysicalDeviceGeneratedCommandsPropertiesNVX) { |
| 305 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 306 | "ICD associated with VkPhysicalDevice does not support " |
| 307 | "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX"); |
Karl Schultz | e2ef9e6 | 2017-01-13 14:01:35 -0700 | [diff] [blame] | 308 | } else { |
| 309 | icd_term->GetPhysicalDeviceGeneratedCommandsPropertiesNVX( |
| 310 | phys_dev_term->phys_dev, pFeatures, pLimits); |
Mark Young | fa55278 | 2016-12-12 16:14:55 -0700 | [diff] [blame] | 311 | } |
Mark Young | fa55278 | 2016-12-12 16:14:55 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Mark Lobodzinski | 5f20852 | 2016-08-29 15:36:23 -0600 | [diff] [blame] | 314 | // GPA helpers for non-KHR extensions |
| 315 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 316 | bool extension_instance_gpa(struct loader_instance *ptr_instance, |
| 317 | const char *name, void **addr) { |
| 318 | *addr = NULL; |
| 319 | |
Mark Young | 65cb366 | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 320 | // Definitions for the VK_EXT_debug_marker extension commands which |
| 321 | // need to have a terminator function. Since these are device |
| 322 | // commands, we always need to return a valid value for them. |
| 323 | |
| 324 | if (!strcmp("vkDebugMarkerSetObjectTagEXT", name)) { |
| 325 | *addr = (void *)vkDebugMarkerSetObjectTagEXT; |
| 326 | return true; |
| 327 | } |
| 328 | if (!strcmp("vkDebugMarkerSetObjectNameEXT", name)) { |
| 329 | *addr = (void *)vkDebugMarkerSetObjectNameEXT; |
| 330 | return true; |
| 331 | } |
| 332 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 333 | // Functions for the VK_NV_external_memory_capabilities extension |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame] | 334 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 335 | if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) { |
Mark Young | 35159af | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 336 | *addr = (ptr_instance->enabled_known_extensions |
| 337 | .nv_external_memory_capabilities == 1) |
| 338 | ? (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV |
| 339 | : NULL; |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 340 | return true; |
| 341 | } |
| 342 | |
Mark Young | 3ea0ff5 | 2016-09-09 07:26:48 -0600 | [diff] [blame] | 343 | // Functions for the VK_AMD_draw_indirect_count extension |
| 344 | |
| 345 | if (!strcmp("vkCmdDrawIndirectCountAMD", name)) { |
| 346 | *addr = (void *)vkCmdDrawIndirectCountAMD; |
| 347 | return true; |
| 348 | } |
| 349 | |
| 350 | if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) { |
| 351 | *addr = (void *)vkCmdDrawIndexedIndirectCountAMD; |
| 352 | return true; |
| 353 | } |
| 354 | |
| 355 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 356 | |
| 357 | // Functions for the VK_NV_external_memory_win32 extension |
| 358 | |
| 359 | if (!strcmp("vkGetMemoryWin32HandleNV", name)) { |
| 360 | *addr = (void *)vkGetMemoryWin32HandleNV; |
| 361 | return true; |
| 362 | } |
| 363 | |
| 364 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 365 | |
Mark Young | fa55278 | 2016-12-12 16:14:55 -0700 | [diff] [blame] | 366 | // Functions for the VK_NVX_device_generated_commands extension |
| 367 | |
| 368 | if (!strcmp("vkCmdProcessCommandsNVX", name)) { |
| 369 | *addr = (void *)vkCmdProcessCommandsNVX; |
| 370 | return true; |
| 371 | } |
| 372 | if (!strcmp("vkCmdReserveSpaceForCommandsNVX", name)) { |
| 373 | *addr = (void *)vkCmdReserveSpaceForCommandsNVX; |
| 374 | return true; |
| 375 | } |
| 376 | if (!strcmp("vkCreateIndirectCommandsLayoutNVX", name)) { |
| 377 | *addr = (void *)vkCreateIndirectCommandsLayoutNVX; |
| 378 | return true; |
| 379 | } |
| 380 | if (!strcmp("vkDestroyIndirectCommandsLayoutNVX", name)) { |
| 381 | *addr = (void *)vkDestroyIndirectCommandsLayoutNVX; |
| 382 | return true; |
| 383 | } |
| 384 | if (!strcmp("vkCreateObjectTableNVX", name)) { |
| 385 | *addr = (void *)vkCreateObjectTableNVX; |
| 386 | return true; |
| 387 | } |
| 388 | if (!strcmp("vkDestroyObjectTableNVX", name)) { |
| 389 | *addr = (void *)vkDestroyObjectTableNVX; |
| 390 | return true; |
| 391 | } |
| 392 | if (!strcmp("vkRegisterObjectsNVX", name)) { |
| 393 | *addr = (void *)vkRegisterObjectsNVX; |
| 394 | return true; |
| 395 | } |
| 396 | if (!strcmp("vkUnregisterObjectsNVX", name)) { |
| 397 | *addr = (void *)vkUnregisterObjectsNVX; |
| 398 | return true; |
| 399 | } |
| 400 | if (!strcmp("vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX", name)) { |
| 401 | *addr = (void *)vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX; |
| 402 | return true; |
| 403 | } |
| 404 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 405 | return false; |
| 406 | } |
| 407 | |
| 408 | void extensions_create_instance(struct loader_instance *ptr_instance, |
| 409 | const VkInstanceCreateInfo *pCreateInfo) { |
Mark Young | 35159af | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 410 | ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 0; |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 411 | |
| 412 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 413 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 414 | VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) == 0) { |
Mark Young | 35159af | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 415 | ptr_instance->enabled_known_extensions |
| 416 | .nv_external_memory_capabilities = 1; |
| 417 | return; |
| 418 | } |
| 419 | } |
| 420 | } |