diff options
author | Steven Houston <steven@shouston.net> | 2020-11-04 17:45:10 +0000 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-11-11 08:36:05 +0000 |
commit | d6a8a6ed4ec659068eedd61d0e10f49a78bd5a21 (patch) | |
tree | 562ba5114c39f5cb965624f6ee6c48a1bbf5aa1b /src/broadcom/vulkan/v3dv_device.c | |
parent | d186766c08867d5447e32c427ff092612bd4ba92 (diff) |
v3dv: VK_KHR_display extension support
When VK_KHR_display is enabled it needs to open the primary
node on the vc4/vc5 display device, so pass it to
physical_device_init().
Extension functions call through to the wsi_common_display.c
implementations.
v2: Follow Mesa conventions for comments and char *
Refer to vc4 display device in comments.
v3: Added Copyright © 2020 Raspberry Pi
v4: Test device has primary node when using simulator.
v5: Assert that we have a primary device. Fix trailing blank space.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3692
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7515>
Diffstat (limited to 'src/broadcom/vulkan/v3dv_device.c')
-rw-r--r-- | src/broadcom/vulkan/v3dv_device.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 3e1078d922c..36031caee18 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -446,7 +446,8 @@ init_uuids(struct v3dv_physical_device *device) static VkResult physical_device_init(struct v3dv_physical_device *device, struct v3dv_instance *instance, - drmDevicePtr drm_device) + drmDevicePtr drm_render_device, + drmDevicePtr drm_primary_device) { VkResult result = VK_SUCCESS; int32_t display_fd = -1; @@ -454,7 +455,7 @@ physical_device_init(struct v3dv_physical_device *device, device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = instance; - const char *path = drm_device->nodes[DRM_NODE_RENDER]; + const char *path = drm_render_device->nodes[DRM_NODE_RENDER]; int32_t render_fd = open(path, O_RDWR | O_CLOEXEC); if (render_fd < 0) return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER); @@ -463,23 +464,37 @@ physical_device_init(struct v3dv_physical_device *device, * device so we can allocate winsys BOs for the v3d core to render into. */ #if !using_v3d_simulator + if (instance->enabled_extensions.KHR_display) { + /* Open the primary node on the vc4 display device */ + assert(drm_primary_device); + const char *primary_path = drm_primary_device->nodes[DRM_NODE_PRIMARY]; + display_fd = open(primary_path, O_RDWR | O_CLOEXEC); + } + #ifdef VK_USE_PLATFORM_XCB_KHR - display_fd = create_display_fd_xcb(); + if (display_fd == -1) + display_fd = create_display_fd_xcb(); #endif if (display_fd == -1) { result = VK_ERROR_INCOMPATIBLE_DRIVER; goto fail; } +#else + /* using_v3d_simulator */ + if (instance->enabled_extensions.KHR_display) { + /* There is only one device with primary and render nodes. + * Open its primary node. + */ + const char *primary_path = drm_render_device->nodes[DRM_NODE_PRIMARY]; + display_fd = open(primary_path, O_RDWR | O_CLOEXEC); + } + device->sim_file = v3d_simulator_init(render_fd); #endif device->render_fd = render_fd; /* The v3d render node */ device->display_fd = display_fd; /* The vc4 primary node */ -#if using_v3d_simulator - device->sim_file = v3d_simulator_init(device->render_fd); -#endif - if (!v3d_get_device_info(device->render_fd, &device->devinfo, &v3dv_ioctl)) { result = VK_ERROR_INCOMPATIBLE_DRIVER; goto fail; @@ -565,11 +580,12 @@ enumerate_devices(struct v3dv_instance *instance) for (unsigned i = 0; i < (unsigned)max_devices; i++) { #if using_v3d_simulator /* In the simulator, we look for an Intel render node */ - if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER && - devices[i]->bustype == DRM_BUS_PCI && - devices[i]->deviceinfo.pci->vendor_id == 0x8086) { + const int required_nodes = (1 << DRM_NODE_RENDER) | (1 << DRM_NODE_PRIMARY); + if ((devices[i]->available_nodes & required_nodes) == required_nodes && + devices[i]->bustype == DRM_BUS_PCI && + devices[i]->deviceinfo.pci->vendor_id == 0x8086) { result = physical_device_init(&instance->physicalDevice, instance, - devices[i]); + devices[i], NULL); if (result != VK_ERROR_INCOMPATIBLE_DRIVER) break; } @@ -614,7 +630,7 @@ enumerate_devices(struct v3dv_instance *instance) result = VK_ERROR_INCOMPATIBLE_DRIVER; else result = physical_device_init(&instance->physicalDevice, instance, - devices[v3d_idx]); + devices[v3d_idx], devices[vc4_idx]); #endif drmFreeDevices(devices, max_devices); |