vulkan/wsi: Add a wsi_device_init function
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 16 Nov 2017 02:50:44 +0000 (18:50 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 4 Dec 2017 18:04:19 +0000 (10:04 -0800)
This gives the opportunity to collect some function pointers if we'd
like which will be very useful in future.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/amd/vulkan/radv_wsi.c
src/intel/vulkan/anv_wsi.c
src/vulkan/Makefile.sources
src/vulkan/wsi/meson.build
src/vulkan/wsi/wsi_common.c [new file with mode: 0644]
src/vulkan/wsi/wsi_common.h

index f5f9a3fbeba51ce46f285eab6522772a7dec3c78..247f7cce773f39597fb51738ab5fa26d09e78b49 100644 (file)
@@ -34,12 +34,20 @@ MAYBE_UNUSED static const struct wsi_callbacks wsi_cbs = {
        WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 
        WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 
+static PFN_vkVoidFunction
+radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
+{
+       return radv_lookup_entrypoint(pName);
+}
+
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
        VkResult result;
 
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
        VkResult result;
 
-       memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
+       wsi_device_init(&physical_device->wsi_device,
+                       radv_physical_device_to_handle(physical_device),
+                       radv_wsi_proc_addr);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
        result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
        result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
index d8c4885b5b895fb4ad1c38cf2edf2d8417d63742..f898a0759d0d998a5f65598e919053b5307d6677 100644 (file)
@@ -33,12 +33,21 @@ static const struct wsi_callbacks wsi_cbs = {
 };
 #endif
 
 };
 #endif
 
+static PFN_vkVoidFunction
+anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
+{
+   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+   return anv_lookup_entrypoint(&physical_device->info, pName);
+}
+
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
    VkResult result;
 
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
    VkResult result;
 
-   memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
+   wsi_device_init(&physical_device->wsi_device,
+                   anv_physical_device_to_handle(physical_device),
+                   anv_wsi_proc_addr);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
    result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
    result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
index 2cf7218e926d1df02cdf212c1ee378554be9ad9c..44cba8bde3cd273d41d1b097dea798698b27d498 100644 (file)
@@ -1,5 +1,6 @@
 
 VULKAN_WSI_FILES := \
 
 VULKAN_WSI_FILES := \
+       wsi/wsi_common.c \
        wsi/wsi_common.h \
        wsi/wsi_common_queue.h
 
        wsi/wsi_common.h \
        wsi/wsi_common_queue.h
 
index 3aa02d5e63fadd633f17b14d6a648b4ced4dee42..bfec376e9a7073f9f824d3e9cf0f942d836e6fa9 100644 (file)
@@ -22,6 +22,7 @@ vulkan_wsi_args = []
 vulkan_wsi_deps = []
 
 files_vulkan_wsi = files(
 vulkan_wsi_deps = []
 
 files_vulkan_wsi = files(
+  'wsi_common.c',
   'wsi_common.h',
   'wsi_common_queue.h',
 )
   'wsi_common.h',
   'wsi_common_queue.h',
 )
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
new file mode 100644 (file)
index 0000000..8c883b4
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "wsi_common.h"
+
+void
+wsi_device_init(struct wsi_device *wsi,
+                VkPhysicalDevice pdevice,
+                WSI_FN_GetPhysicalDeviceProcAddr proc_addr)
+{
+   memset(wsi, 0, sizeof(*wsi));
+}
index 565219d4e26c0a67f1f6f49f2775ec4c2d31b883..41d2c6d11282e5229d0ca330077f8f59bdc0fda9 100644 (file)
@@ -121,6 +121,13 @@ struct wsi_device {
     struct wsi_interface *                  wsi[VK_ICD_WSI_PLATFORM_MAX];
 };
 
     struct wsi_interface *                  wsi[VK_ICD_WSI_PLATFORM_MAX];
 };
 
+typedef PFN_vkVoidFunction (VKAPI_PTR *WSI_FN_GetPhysicalDeviceProcAddr)(VkPhysicalDevice physicalDevice, const char* pName);
+
+void
+wsi_device_init(struct wsi_device *wsi,
+                VkPhysicalDevice pdevice,
+                WSI_FN_GetPhysicalDeviceProcAddr proc_addr);
+
 #define WSI_CB(cb) PFN_vk##cb cb
 struct wsi_callbacks {
    WSI_CB(GetPhysicalDeviceFormatProperties);
 #define WSI_CB(cb) PFN_vk##cb cb
 struct wsi_callbacks {
    WSI_CB(GetPhysicalDeviceFormatProperties);