'nvk_private.h',
'nvk_sampler.c',
'nvk_sampler.h',
+ 'nvk_wsi.c',
+ 'nvk_wsi.h'
)
nouveau_icd = custom_target(
}
static const struct vk_instance_extension_table instance_extensions = {
+#ifdef NVK_USE_WSI_PLATFORM
+ .KHR_get_surface_capabilities2 = true,
+ .KHR_surface = true,
+ .KHR_surface_protected_capabilities = true,
+#endif
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ .KHR_wayland_surface = true,
+#endif
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ .KHR_xcb_surface = true,
+#endif
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ .KHR_xlib_surface = true,
+#endif
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+ .EXT_acquire_xlib_display = true,
+#endif
.KHR_get_physical_device_properties2 = true,
.EXT_debug_report = true,
.EXT_debug_utils = true,
#include "nvk_entrypoints.h"
#include "nvk_instance.h"
+#include "nvk_wsi.h"
#include "vulkan/runtime/vk_device.h"
#include "vulkan/wsi/wsi_common.h"
struct vk_device_extension_table *ext)
{
*ext = (struct vk_device_extension_table) {
+#ifdef NVK_USE_WSI_PLATFORM
+ .KHR_swapchain = true,
+ .KHR_swapchain_mutable_format = true,
+#endif
.KHR_variable_pointers = true,
};
}
device->instance = instance;
device->dev = ndev;
+ result = nvk_init_wsi(device);
+ if (result != VK_SUCCESS) {
+ vk_error(instance, result);
+ goto fail_alloc;
+ }
+
device->mem_heaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
device->mem_types[0].propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
device->mem_types[0].heapIndex = 0;
void
nvk_physical_device_destroy(struct nvk_physical_device *device)
{
+ nvk_finish_wsi(device);
nouveau_ws_device_destroy(device->dev);
vk_physical_device_finish(&device->vk);
vk_free(&device->instance->vk.alloc, device);
#include "vulkan/runtime/vk_physical_device.h"
+#include "wsi_common.h"
+
struct nvk_instance;
struct nvk_physical_device {
/* Link in nvk_instance::physical_devices */
struct list_head link;
+ struct wsi_device wsi_device;
+
// TODO: add mapable VRAM heap if possible
VkMemoryHeap mem_heaps[2];
VkMemoryType mem_types[2];
void nvk_physical_device_destroy(struct nvk_physical_device *);
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \
+ defined(VK_USE_PLATFORM_XCB_KHR) || \
+ defined(VK_USE_PLATFORM_XLIB_KHR) || \
+ defined(VK_USE_PLATFORM_DISPLAY_KHR)
+#define NVK_USE_WSI_PLATFORM
+#endif
+
#endif
--- /dev/null
+
+#include "nvk_wsi.h"
+#include "nvk_instance.h"
+#include "wsi_common.h"
+
+static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
+nvk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
+{
+ VK_FROM_HANDLE(nvk_physical_device, pdevice, physicalDevice);
+ return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
+}
+
+VkResult
+nvk_init_wsi(struct nvk_physical_device *physical_device)
+{
+ struct wsi_device_options wsi_options = {
+ .sw_device = false
+ };
+ VkResult result =
+ wsi_device_init(&physical_device->wsi_device, nvk_physical_device_to_handle(physical_device),
+ nvk_wsi_proc_addr, &physical_device->instance->vk.alloc,
+ -1, NULL, &wsi_options);
+ if (result != VK_SUCCESS)
+ return result;
+
+ physical_device->vk.wsi_device = &physical_device->wsi_device;
+ return result;
+}
+
+void
+nvk_finish_wsi(struct nvk_physical_device *physical_device)
+{
+ physical_device->vk.wsi_device = NULL;
+ wsi_device_finish(&physical_device->wsi_device, &physical_device->instance->vk.alloc);
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL
+nvk_QueuePresentKHR(VkQueue _queue, const VkPresentInfoKHR *pPresentInfo)
+{
+ return VK_NOT_READY;
+}
--- /dev/null
+#ifndef NVK_WSI_H
+#define NVK_WSI_H 1
+
+#include "nvk_physical_device.h"
+
+VkResult nvk_init_wsi(struct nvk_physical_device *physical_device);
+void nvk_finish_wsi(struct nvk_physical_device *physical_device);
+
+#endif