mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 09:18:04 +02:00
nvk: add some initial wsi framework.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
6725804efb
commit
ab4452b9af
6 changed files with 92 additions and 0 deletions
|
|
@ -16,6 +16,8 @@ nvk_files = files(
|
|||
'nvk_private.h',
|
||||
'nvk_sampler.c',
|
||||
'nvk_sampler.h',
|
||||
'nvk_wsi.c',
|
||||
'nvk_wsi.h'
|
||||
)
|
||||
|
||||
nouveau_icd = custom_target(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,23 @@ nvk_EnumerateInstanceVersion(uint32_t *pApiVersion)
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "nvk_entrypoints.h"
|
||||
#include "nvk_instance.h"
|
||||
#include "nvk_wsi.h"
|
||||
|
||||
#include "vulkan/runtime/vk_device.h"
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
|
|
@ -119,6 +120,10 @@ nvk_get_device_extensions(const struct nvk_physical_device *device,
|
|||
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,
|
||||
};
|
||||
}
|
||||
|
|
@ -180,6 +185,12 @@ nvk_physical_device_try_create(struct nvk_instance *instance,
|
|||
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;
|
||||
|
|
@ -221,6 +232,7 @@ fail_fd:
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "vulkan/runtime/vk_physical_device.h"
|
||||
|
||||
#include "wsi_common.h"
|
||||
|
||||
struct nvk_instance;
|
||||
|
||||
struct nvk_physical_device {
|
||||
|
|
@ -17,6 +19,8 @@ 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];
|
||||
|
|
@ -31,4 +35,11 @@ VK_DEFINE_HANDLE_CASTS(nvk_physical_device,
|
|||
|
||||
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
|
||||
|
|
|
|||
41
src/nouveau/vulkan/nvk_wsi.c
Normal file
41
src/nouveau/vulkan/nvk_wsi.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
#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;
|
||||
}
|
||||
9
src/nouveau/vulkan/nvk_wsi.h
Normal file
9
src/nouveau/vulkan/nvk_wsi.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#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
|
||||
Loading…
Add table
Reference in a new issue