Mesa (main): turnip: Implement VK_EXT_physical_device_drm
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 1 07:34:29 UTC 2022
Module: Mesa
Branch: main
Commit: 549e861dc1f9e9fed5b6b5897c154273e2233658
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=549e861dc1f9e9fed5b6b5897c154273e2233658
Author: Danylo Piliaiev <dpiliaiev at igalia.com>
Date: Thu Feb 10 15:35:59 2022 +0200
turnip: Implement VK_EXT_physical_device_drm
Copied from ANV and V3DV.
v1. Fix a build error for clang "unannotated fall-through between switch labels"
( Hyunjun Ko <zzoon.ko at igalia.com> )
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6011
Signed-off-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14971>
---
docs/features.txt | 2 +-
src/freedreno/vulkan/tu_device.c | 15 +++++++++++++++
src/freedreno/vulkan/tu_drm.c | 33 +++++++++++++++++++++++++++++++--
src/freedreno/vulkan/tu_private.h | 6 ++++++
4 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/docs/features.txt b/docs/features.txt
index 52b4b834bce..e380cc4f1f6 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -555,7 +555,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_memory_priority DONE (radv)
VK_EXT_multi_draw DONE (anv, lvp, radv)
VK_EXT_pci_bus_info DONE (anv, radv)
- VK_EXT_physical_device_drm DONE (anv, radv, v3dv)
+ VK_EXT_physical_device_drm DONE (anv, radv, tu, v3dv)
VK_EXT_post_depth_coverage DONE (anv/gfx10+, lvp, radv/gfx10+)
VK_EXT_primitive_topology_list_restart DONE (anv, lvp, radv, tu)
VK_EXT_provoking_vertex DONE (anv, lvp, radv, tu, v3dv)
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 49f623590dc..e5f35a1ecb2 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -203,6 +203,9 @@ get_device_extensions(const struct tu_physical_device *device,
.EXT_line_rasterization = true,
.EXT_subgroup_size_control = true,
.EXT_image_robustness = true,
+#ifndef TU_USE_KGSL
+ .EXT_physical_device_drm = true,
+#endif
/* For Graphics Flight Recorder (GFR) */
.AMD_buffer_marker = true,
.ARM_rasterization_order_attachment_access = true,
@@ -1252,6 +1255,18 @@ tu_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
props->lineSubPixelPrecisionBits = 8;
break;
}
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT: {
+ VkPhysicalDeviceDrmPropertiesEXT *props =
+ (VkPhysicalDeviceDrmPropertiesEXT *)ext;
+ props->hasPrimary = pdevice->has_master;
+ props->primaryMajor = pdevice->master_major;
+ props->primaryMinor = pdevice->master_minor;
+
+ props->hasRender = pdevice->has_local;
+ props->renderMajor = pdevice->local_major;
+ props->renderMinor = pdevice->local_minor;
+ break;
+ }
default:
break;
diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c
index bd6f5289c64..92ff8755c1e 100644
--- a/src/freedreno/vulkan/tu_drm.c
+++ b/src/freedreno/vulkan/tu_drm.c
@@ -29,6 +29,13 @@
#include <sys/mman.h>
#include <xf86drm.h>
+#ifdef MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include <sys/sysmacros.h>
+#endif
+
#include "vk_util.h"
#include "drm-uapi/msm_drm.h"
@@ -609,6 +616,7 @@ tu_drm_device_init(struct tu_physical_device *device,
struct tu_instance *instance,
drmDevicePtr drm_device)
{
+ const char *primary_path = drm_device->nodes[DRM_NODE_PRIMARY];
const char *path = drm_device->nodes[DRM_NODE_RENDER];
VkResult result = VK_SUCCESS;
drmVersionPtr version;
@@ -665,8 +673,7 @@ tu_drm_device_init(struct tu_physical_device *device,
device->instance = instance;
if (instance->vk.enabled_extensions.KHR_display) {
- master_fd =
- open(drm_device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC);
+ master_fd = open(primary_path, O_RDWR | O_CLOEXEC);
if (master_fd >= 0) {
/* TODO: free master_fd is accel is not working? */
}
@@ -700,6 +707,28 @@ tu_drm_device_init(struct tu_physical_device *device,
goto fail;
}
+ struct stat st;
+
+ if (stat(primary_path, &st) == 0) {
+ device->has_master = true;
+ device->master_major = major(st.st_rdev);
+ device->master_minor = minor(st.st_rdev);
+ } else {
+ device->has_master = false;
+ device->master_major = 0;
+ device->master_minor = 0;
+ }
+
+ if (stat(path, &st) == 0) {
+ device->has_local = true;
+ device->local_major = major(st.st_rdev);
+ device->local_minor = minor(st.st_rdev);
+ } else {
+ result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
+ "failed to stat DRM render node %s", path);
+ goto fail;
+ }
+
device->syncobj_type = vk_drm_syncobj_get_type(fd);
device->timeline_type = vk_sync_timeline_get_type(&tu_timeline_sync_type);
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index b3e7d488e62..1bd88a34782 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -215,7 +215,13 @@ struct tu_physical_device
struct wsi_device wsi_device;
int local_fd;
+ bool has_local;
+ int64_t local_major;
+ int64_t local_minor;
int master_fd;
+ bool has_master;
+ int64_t master_major;
+ int64_t master_minor;
uint32_t gmem_size;
uint64_t gmem_base;
More information about the mesa-commit
mailing list