From: Simon Ser Date: Fri, 8 Jan 2021 15:06:51 +0000 (+0100) Subject: radv: implement VK_EXT_physical_device_drm X-Git-Tag: upstream/21.2.3~1548 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7aaa54feb53a9d0cf3277bef31547312ee56b277;p=platform%2Fupstream%2Fmesa.git radv: implement VK_EXT_physical_device_drm This adds support for the Vulkan extension introduced in [1]. The extension allows to get a VkPhysicalDevice's DRM node device IDs. [1]: https://github.com/KhronosGroup/Vulkan-Docs/pull/1356 Signed-off-by: Simon Ser Reviewed-by: Samuel Pitoiset Part-of: --- diff --git a/docs/features.txt b/docs/features.txt index b44cd6e..e70fdb8 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -533,7 +533,7 @@ Khronos extensions that are not part of any Vulkan version: VK_EXT_memory_budget DONE (anv, radv, tu) VK_EXT_memory_priority DONE (radv) VK_EXT_pci_bus_info DONE (anv, radv) - VK_EXT_physical_device_drm DONE (anv) + VK_EXT_physical_device_drm DONE (anv, radv) VK_EXT_pipeline_creation_cache_control DONE (anv, radv) VK_EXT_pipeline_creation_feedback DONE (anv, radv) VK_EXT_post_depth_coverage DONE (anv/gfx10+, lvp, radv) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 00c0e47..15c04e1 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -2,5 +2,6 @@ zink supports GL_ARB_texture_filter_minmax, GL_ARB_shader_clock VK_EXT_provoking_vertex on RADV. VK_EXT_extended_dynamic_state2 on RADV. VK_EXT_global_priority_query on RADV. +VK_EXT_physical_device_drm on RADV. 32-bit x86 builds now default disable x87 math and use sse2. GL ES 3.1 on GT21x hardware. diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 4b8eab2..9e18348 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -29,6 +29,12 @@ #include #include +#ifdef __FreeBSD__ +#include +#elif !defined(_WIN32) +#include +#endif + #include "util/debug.h" #include "util/disk_cache.h" #include "radv_cs.h" @@ -469,6 +475,9 @@ radv_physical_device_get_supported_extensions(const struct radv_physical_device .EXT_memory_budget = true, .EXT_memory_priority = true, .EXT_pci_bus_info = true, +#ifndef _WIN32 + .EXT_physical_device_drm = true, +#endif .EXT_pipeline_creation_cache_control = true, .EXT_pipeline_creation_feedback = true, .EXT_post_depth_coverage = device->rad_info.chip_class >= GFX10, @@ -698,8 +707,30 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm radv_physical_device_get_supported_extensions(device, &device->vk.supported_extensions); #ifndef _WIN32 - if (drm_device) + if (drm_device) { + struct stat primary_stat = {0}, render_stat = {0}; + + device->available_nodes = drm_device->available_nodes; device->bus_info = *drm_device->businfo.pci; + + if ((drm_device->available_nodes & (1 << DRM_NODE_PRIMARY)) && + stat(drm_device->nodes[DRM_NODE_PRIMARY], &primary_stat) != 0) { + result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, + "failed to stat DRM primary node %s", + drm_device->nodes[DRM_NODE_PRIMARY]); + goto fail_disk_cache; + } + device->primary_devid = primary_stat.st_rdev; + + if ((drm_device->available_nodes & (1 << DRM_NODE_RENDER)) && + stat(drm_device->nodes[DRM_NODE_RENDER], &render_stat) != 0) { + result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, + "failed to stat DRM render node %s", + drm_device->nodes[DRM_NODE_RENDER]); + goto fail_disk_cache; + } + device->render_devid = render_stat.st_rdev; + } #endif if ((device->instance->debug_flags & RADV_DEBUG_INFO)) @@ -2308,6 +2339,26 @@ radv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, props->minAccelerationStructureScratchOffsetAlignment = 128; break; } +#ifndef _WIN32 + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT: { + VkPhysicalDeviceDrmPropertiesEXT *props = (VkPhysicalDeviceDrmPropertiesEXT *)ext; + if (pdevice->available_nodes & (1 << DRM_NODE_PRIMARY)) { + props->hasPrimary = true; + props->primaryMajor = (int64_t)major(pdevice->primary_devid); + props->primaryMinor = (int64_t)minor(pdevice->primary_devid); + } else { + props->hasPrimary = false; + } + if (pdevice->available_nodes & (1 << DRM_NODE_RENDER)) { + props->hasRender = true; + props->renderMajor = (int64_t)major(pdevice->render_devid); + props->renderMinor = (int64_t)minor(pdevice->render_devid); + } else { + props->hasRender = false; + } + break; + } +#endif default: break; } diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index bf99e92..d9dd39f 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -304,7 +304,11 @@ struct radv_physical_device { unsigned heaps; #ifndef _WIN32 + int available_nodes; drmPciBusInfo bus_info; + + dev_t primary_devid; + dev_t render_devid; #endif };