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> |
| 29 | |
| 30 | // Definitions for the VK_NV_external_memory_capabilities extension |
| 31 | |
| 32 | static const VkExtensionProperties |
| 33 | nv_external_memory_capabilities_extension_info = { |
| 34 | .extensionName = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, |
| 35 | .specVersion = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION, |
| 36 | }; |
| 37 | |
| 38 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 39 | vkGetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 40 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 41 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 42 | VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
| 43 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
| 44 | |
| 45 | const VkLayerInstanceDispatchTable *disp; |
| 46 | VkPhysicalDevice unwrapped_phys_dev = |
| 47 | loader_unwrap_physical_device(physicalDevice); |
| 48 | disp = loader_get_instance_dispatch(physicalDevice); |
| 49 | |
| 50 | return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 51 | unwrapped_phys_dev, format, type, tiling, usage, flags, |
| 52 | externalHandleType, pExternalImageFormatProperties); |
| 53 | } |
| 54 | |
| 55 | VKAPI_ATTR VkResult VKAPI_CALL |
| 56 | terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 57 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 58 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 59 | VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
| 60 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
| 61 | |
| 62 | struct loader_physical_device *phys_dev = |
| 63 | (struct loader_physical_device *)physicalDevice; |
| 64 | struct loader_icd *icd = phys_dev->this_icd; |
| 65 | |
| 66 | assert(icd->GetPhysicalDeviceExternalImageFormatPropertiesNV && |
| 67 | "loader: null GetPhysicalDeviceExternalImageFormatPropertiesNV ICD " |
| 68 | "pointer"); |
| 69 | |
| 70 | if (!icd->GetPhysicalDeviceExternalImageFormatPropertiesNV) |
| 71 | return VK_ERROR_INITIALIZATION_FAILED; |
| 72 | |
| 73 | return icd->GetPhysicalDeviceExternalImageFormatPropertiesNV( |
| 74 | phys_dev->phys_dev, format, type, tiling, usage, flags, |
| 75 | externalHandleType, pExternalImageFormatProperties); |
| 76 | } |
| 77 | |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame^] | 78 | // Definitions for the VK_AMD_draw_indirect_count extension |
| 79 | |
| 80 | static const VkExtensionProperties amd_draw_indirect_count_extension_info = { |
| 81 | .extensionName = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME, |
| 82 | .specVersion = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_SPEC_VERSION, |
| 83 | }; |
| 84 | |
| 85 | VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( |
| 86 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 87 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 88 | uint32_t stride) { |
| 89 | const VkLayerDispatchTable *disp; |
| 90 | |
| 91 | disp = loader_get_dispatch(commandBuffer); |
| 92 | disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, |
| 93 | countBufferOffset, maxDrawCount, stride); |
| 94 | } |
| 95 | |
| 96 | VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( |
| 97 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 98 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 99 | uint32_t stride) { |
| 100 | const VkLayerDispatchTable *disp; |
| 101 | |
| 102 | disp = loader_get_dispatch(commandBuffer); |
| 103 | disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, |
| 104 | countBuffer, countBufferOffset, |
| 105 | maxDrawCount, stride); |
| 106 | } |
| 107 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 108 | bool extension_instance_gpa(struct loader_instance *ptr_instance, |
| 109 | const char *name, void **addr) { |
| 110 | *addr = NULL; |
| 111 | |
| 112 | // Functions for the VK_NV_external_memory_capabilities extension |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame^] | 113 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 114 | if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) { |
| 115 | *addr = (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV; |
| 116 | return true; |
| 117 | } |
| 118 | |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame^] | 119 | // Functions for the VK_AMD_draw_indirect_count extension |
| 120 | |
| 121 | if (!strcmp("vkCmdDrawIndirectCountAMD", name)) { |
| 122 | *addr = (void *)vkCmdDrawIndirectCountAMD; |
| 123 | return true; |
| 124 | } |
| 125 | |
| 126 | if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) { |
| 127 | *addr = (void *)vkCmdDrawIndexedIndirectCountAMD; |
| 128 | return true; |
| 129 | } |
| 130 | |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 131 | return false; |
| 132 | } |
| 133 | |
| 134 | void extensions_create_instance(struct loader_instance *ptr_instance, |
| 135 | const VkInstanceCreateInfo *pCreateInfo) { |
| 136 | |
| 137 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 138 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 139 | VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) == 0) { |
| 140 | // Nothing to do; |
| 141 | return; |
| 142 | } |
Mark Lobodzinski | 0853ad5 | 2016-08-29 14:54:34 -0600 | [diff] [blame^] | 143 | |
| 144 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 145 | VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME) == 0) { |
| 146 | // Nothing to do; |
| 147 | return; |
| 148 | } |
Mark Lobodzinski | 317574e | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 149 | } |
| 150 | } |