mesa/src/vulkan/runtime/vk_physical_device.h

68 lines
2.3 KiB
C
Raw Normal View History

/*
* Copyright © 2021 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.
*/
#ifndef VK_PHYSICAL_DEVICE_H
#define VK_PHYSICAL_DEVICE_H
#include "vk_dispatch_table.h"
#include "vk_extensions.h"
#include "vk_object.h"
#ifdef __cplusplus
extern "C" {
#endif
vulkan/wsi: Add common wrappers for most entrypoints For a long time, our Vulkan WSI code has acted as something of a layer. The WSI code calls into various Vulkan entrypoints inside the driver to create images, allocate memory, etc. It then implements the API-facing interface almost entirely. The only thing the driver has to provide is little wrappers that wrap around the WSI calls to expose them through the API. However, now that we have a common dispatch framework, we can implement entrypoints directly in the WSI code. As long as the driver uses vk_instance, vk_physical_device, and vk_device, we can provide common wrappers for the vast majority of entrypoints. The only exceptions are vkAcquireNextImage, vkQueuePresent, vkRegisterDeviceEventEXT, and vkRegisterDisplayEventEXT because those may have to manually poke at synchronization primitives. We provide wrappers for vkAcquireNextImage and vkQueuePresent because some drivers can use the default versions. For now, we're intentionally avoiding any link-time dependencies between WSI and the common code. We only use VK_FROM_HANDLE and associated inline helpers and vk_physical_device has a pointer to a wsi_device. Eventually, we may tie the two together closer, but this lets us get 95% of the way there without reworking the universe. Acked-by: Chia-I Wu <olvaffe@gmail.com> Acked-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-06 17:09:12 +01:00
struct wsi_device;
struct vk_physical_device {
struct vk_object_base base;
struct vk_instance *instance;
struct vk_device_extension_table supported_extensions;
struct vk_physical_device_dispatch_table dispatch_table;
vulkan/wsi: Add common wrappers for most entrypoints For a long time, our Vulkan WSI code has acted as something of a layer. The WSI code calls into various Vulkan entrypoints inside the driver to create images, allocate memory, etc. It then implements the API-facing interface almost entirely. The only thing the driver has to provide is little wrappers that wrap around the WSI calls to expose them through the API. However, now that we have a common dispatch framework, we can implement entrypoints directly in the WSI code. As long as the driver uses vk_instance, vk_physical_device, and vk_device, we can provide common wrappers for the vast majority of entrypoints. The only exceptions are vkAcquireNextImage, vkQueuePresent, vkRegisterDeviceEventEXT, and vkRegisterDisplayEventEXT because those may have to manually poke at synchronization primitives. We provide wrappers for vkAcquireNextImage and vkQueuePresent because some drivers can use the default versions. For now, we're intentionally avoiding any link-time dependencies between WSI and the common code. We only use VK_FROM_HANDLE and associated inline helpers and vk_physical_device has a pointer to a wsi_device. Eventually, we may tie the two together closer, but this lets us get 95% of the way there without reworking the universe. Acked-by: Chia-I Wu <olvaffe@gmail.com> Acked-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13234>
2021-10-06 17:09:12 +01:00
struct wsi_device *wsi_device;
};
VK_DEFINE_HANDLE_CASTS(vk_physical_device, base, VkPhysicalDevice,
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
VkResult MUST_CHECK
vk_physical_device_init(struct vk_physical_device *physical_device,
struct vk_instance *instance,
const struct vk_device_extension_table *supported_extensions,
const struct vk_physical_device_dispatch_table *dispatch_table);
void
vk_physical_device_finish(struct vk_physical_device *physical_device);
VkResult
vk_physical_device_check_device_features(struct vk_physical_device *physical_device,
const VkDeviceCreateInfo *pCreateInfo);
#ifdef __cplusplus
}
#endif
#endif /* VK_PHYSICAL_DEVICE_H */