aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2016-08-29 14:21:14 -0600
committerMark Lobodzinski <mark@lunarg.com>2016-08-31 13:27:14 -0600
commit8b690b3313d17f47c738971d2a5db5cf6f03acee (patch)
treeecc1985024c503f553130bb75e237e39afd51b81 /loader
parenteaf9285738b554a91ce33c3cb3123d11ca67bbad (diff)
downloadusermoji-8b690b3313d17f47c738971d2a5db5cf6f03acee.tar.xz
loader: Add support for NV instance extension
Added vkGetPhysicalDeviceExternalImageFormat API from the VK_NV_external_memory_capabilities extension to the loader. Change-Id: Ib87df7bae333d7944a4e181556bc2f99e1e19416
Diffstat (limited to 'loader')
-rw-r--r--loader/CMakeLists.txt2
-rw-r--r--loader/extensions.c101
-rw-r--r--loader/extensions.h38
-rw-r--r--loader/gpa_helper.h4
-rw-r--r--loader/loader.c5
-rw-r--r--loader/loader.h2
-rw-r--r--loader/table_ops.h5
-rw-r--r--loader/trampoline.c2
8 files changed, 158 insertions, 1 deletions
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 51a92b22..1b0781c1 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -21,6 +21,8 @@ set(NORMAL_LOADER_SRCS
trampoline.c
wsi.c
wsi.h
+ extensions.c
+ extensions.h
debug_report.c
debug_report.h
table_ops.h
diff --git a/loader/extensions.c b/loader/extensions.c
new file mode 100644
index 00000000..47a3c12c
--- /dev/null
+++ b/loader/extensions.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2015-2016 The Khronos Group Inc.
+ * Copyright (c) 2015-2016 Valve Corporation
+ * Copyright (c) 2015-2016 LunarG, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Mark Lobodzinski <mark@lunarg.com>
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "vk_loader_platform.h"
+#include "loader.h"
+#include "extensions.h"
+#include <vulkan/vk_icd.h>
+
+ // Definitions for the VK_NV_external_memory_capabilities extension
+
+static const VkExtensionProperties
+ nv_external_memory_capabilities_extension_info = {
+ .extensionName = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
+ .specVersion = VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION,
+};
+
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkGetPhysicalDeviceExternalImageFormatPropertiesNV(
+ VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
+ VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
+ VkExternalMemoryHandleTypeFlagsNV externalHandleType,
+ VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
+
+ const VkLayerInstanceDispatchTable *disp;
+ VkPhysicalDevice unwrapped_phys_dev =
+ loader_unwrap_physical_device(physicalDevice);
+ disp = loader_get_instance_dispatch(physicalDevice);
+
+ return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(
+ unwrapped_phys_dev, format, type, tiling, usage, flags,
+ externalHandleType, pExternalImageFormatProperties);
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
+ VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
+ VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
+ VkExternalMemoryHandleTypeFlagsNV externalHandleType,
+ VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
+
+ struct loader_physical_device *phys_dev =
+ (struct loader_physical_device *)physicalDevice;
+ struct loader_icd *icd = phys_dev->this_icd;
+
+ assert(icd->GetPhysicalDeviceExternalImageFormatPropertiesNV &&
+ "loader: null GetPhysicalDeviceExternalImageFormatPropertiesNV ICD "
+ "pointer");
+
+ if (!icd->GetPhysicalDeviceExternalImageFormatPropertiesNV)
+ return VK_ERROR_INITIALIZATION_FAILED;
+
+ return icd->GetPhysicalDeviceExternalImageFormatPropertiesNV(
+ phys_dev->phys_dev, format, type, tiling, usage, flags,
+ externalHandleType, pExternalImageFormatProperties);
+}
+
+bool extension_instance_gpa(struct loader_instance *ptr_instance,
+ const char *name, void **addr) {
+ *addr = NULL;
+
+ // Functions for the VK_NV_external_memory_capabilities extension
+ if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) {
+ *addr = (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
+ return true;
+ }
+
+ return false;
+}
+
+void extensions_create_instance(struct loader_instance *ptr_instance,
+ const VkInstanceCreateInfo *pCreateInfo) {
+
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) == 0) {
+ // Nothing to do;
+ return;
+ }
+ }
+}
diff --git a/loader/extensions.h b/loader/extensions.h
new file mode 100644
index 00000000..bbccc176
--- /dev/null
+++ b/loader/extensions.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015-2016 The Khronos Group Inc.
+ * Copyright (c) 2015-2016 Valve Corporation
+ * Copyright (c) 2015-2016 LunarG, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Mark Lobodzinski <mark@lunarg.com>
+ *
+ */
+
+#include "vk_loader_platform.h"
+#include "loader.h"
+
+bool extension_instance_gpa(struct loader_instance *ptr_instance,
+ const char *name, void **addr);
+
+void extensions_create_instance(struct loader_instance *ptr_instance,
+ const VkInstanceCreateInfo *pCreateInfo);
+
+// Definitions for the VK_NV_external_memory_capabilities extension
+
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
+ VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
+ VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
+ VkExternalMemoryHandleTypeFlagsNV externalHandleType,
+ VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties);
diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h
index fb9abd77..5089b592 100644
--- a/loader/gpa_helper.h
+++ b/loader/gpa_helper.h
@@ -22,6 +22,7 @@
#include <string.h>
#include "debug_report.h"
#include "wsi.h"
+#include "extensions.h"
static inline void *trampolineGetProcAddr(struct loader_instance *inst,
const char *funcName) {
@@ -304,6 +305,9 @@ static inline void *trampolineGetProcAddr(struct loader_instance *inst,
if (wsi_swapchain_instance_gpa(inst, funcName, &addr))
return addr;
+ if (extension_instance_gpa(inst, funcName, &addr))
+ return addr;
+
addr = loader_dev_ext_gpa(inst, funcName);
return addr;
}
diff --git a/loader/loader.c b/loader/loader.c
index 25262397..a519e437 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1,4 +1,4 @@
-/*
+/*
*
* Copyright (c) 2014-2016 The Khronos Group Inc.
* Copyright (c) 2014-2016 Valve Corporation
@@ -42,6 +42,7 @@
#include "table_ops.h"
#include "debug_report.h"
#include "wsi.h"
+#include "extensions.h"
#include "vulkan/vk_icd.h"
#include "cJSON.h"
#include "murmurhash.h"
@@ -117,6 +118,8 @@ const VkLayerInstanceDispatchTable instance_disp = {
.CreateDebugReportCallbackEXT = terminator_CreateDebugReportCallback,
.DestroyDebugReportCallbackEXT = terminator_DestroyDebugReportCallback,
.DebugReportMessageEXT = terminator_DebugReportMessage,
+ .GetPhysicalDeviceExternalImageFormatPropertiesNV =
+ terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV,
#ifdef VK_USE_PLATFORM_MIR_KHR
.CreateMirSurfaceKHR = terminator_CreateMirSurfaceKHR,
.GetPhysicalDeviceMirPresentationSupportKHR =
diff --git a/loader/loader.h b/loader/loader.h
index 5a1515e4..ce78d4df 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -209,6 +209,8 @@ struct loader_icd {
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR
GetPhysicalDeviceSurfacePresentModesKHR;
+ PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV
+ GetPhysicalDeviceExternalImageFormatPropertiesNV;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
GetPhysicalDeviceWin32PresentationSupportKHR;
diff --git a/loader/table_ops.h b/loader/table_ops.h
index 8a5f8df3..f527f6a2 100644
--- a/loader/table_ops.h
+++ b/loader/table_ops.h
@@ -584,6 +584,9 @@ static inline void loader_init_instance_extension_dispatch_table(
table->GetPhysicalDeviceSurfacePresentModesKHR =
(PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa(
inst, "vkGetPhysicalDeviceSurfacePresentModesKHR");
+ table->GetPhysicalDeviceExternalImageFormatPropertiesNV =
+ (PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)gpa(
+ inst, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV");
#ifdef VK_USE_PLATFORM_MIR_KHR
table->CreateMirSurfaceKHR =
(PFN_vkCreateMirSurfaceKHR)gpa(inst, "vkCreateMirSurfaceKHR");
@@ -684,6 +687,8 @@ loader_lookup_instance_dispatch_table(const VkLayerInstanceDispatchTable *table,
return (void *)table->GetPhysicalDeviceSurfaceFormatsKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR"))
return (void *)table->GetPhysicalDeviceSurfacePresentModesKHR;
+ if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV"))
+ return (void *)table->GetPhysicalDeviceExternalImageFormatPropertiesNV;
#ifdef VK_USE_PLATFORM_MIR_KHR
if (!strcmp(name, "CreateMirSurfaceKHR"))
return (void *)table->CreateMirSurfaceKHR;
diff --git a/loader/trampoline.c b/loader/trampoline.c
index b0f61383..54a71057 100644
--- a/loader/trampoline.c
+++ b/loader/trampoline.c
@@ -30,6 +30,7 @@
#include "loader.h"
#include "debug_report.h"
#include "wsi.h"
+#include "extensions.h"
#include "gpa_helper.h"
#include "table_ops.h"
@@ -406,6 +407,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
if (res == VK_SUCCESS) {
wsi_create_instance(ptr_instance, &ici);
debug_report_create_instance(ptr_instance, &ici);
+ extensions_create_instance(ptr_instance, &ici);
*pInstance = created_instance;