panvk: query device ids of drm device nodes
They are needed for VK_EXT_physical_device_drm. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31635>
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#include "util/disk_cache.h"
|
||||
#include "git_sha1.h"
|
||||
@@ -96,6 +98,32 @@ create_kmod_dev(struct panvk_physical_device *device,
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_drm_device_ids(struct panvk_physical_device *device,
|
||||
const struct panvk_instance *instance,
|
||||
drmDevicePtr drm_device)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(drm_device->nodes[DRM_NODE_RENDER], &st)) {
|
||||
return vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"failed to query render node stat");
|
||||
}
|
||||
|
||||
device->drm.render_rdev = st.st_rdev;
|
||||
|
||||
if (drm_device->available_nodes & (1 << DRM_NODE_PRIMARY)) {
|
||||
if (stat(drm_device->nodes[DRM_NODE_PRIMARY], &st)) {
|
||||
return vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"failed to query primary node stat");
|
||||
}
|
||||
|
||||
device->drm.primary_rdev = st.st_rdev;
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
get_cache_uuid(uint16_t family, void *uuid)
|
||||
{
|
||||
@@ -688,6 +716,18 @@ get_device_properties(const struct panvk_instance *instance,
|
||||
snprintf(properties->driverInfo, VK_MAX_DRIVER_INFO_SIZE,
|
||||
"Mesa " PACKAGE_VERSION MESA_GIT_SHA1);
|
||||
|
||||
/* VK_EXT_physical_device_drm */
|
||||
if (device->drm.primary_rdev) {
|
||||
properties->drmHasPrimary = true;
|
||||
properties->drmPrimaryMajor = major(device->drm.primary_rdev);
|
||||
properties->drmPrimaryMinor = minor(device->drm.primary_rdev);
|
||||
}
|
||||
if (device->drm.render_rdev) {
|
||||
properties->drmHasRender = true;
|
||||
properties->drmRenderMajor = major(device->drm.render_rdev);
|
||||
properties->drmRenderMinor = minor(device->drm.render_rdev);
|
||||
}
|
||||
|
||||
/* VK_EXT_shader_module_identifier */
|
||||
STATIC_ASSERT(sizeof(vk_shaderModuleIdentifierAlgorithmUUID) ==
|
||||
sizeof(properties->shaderModuleIdentifierAlgorithmUUID));
|
||||
@@ -736,6 +776,10 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
result = get_drm_device_ids(device, instance, drm_device);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
device->formats.all = panfrost_format_table(arch);
|
||||
device->formats.blendable = panfrost_blendable_format_table(arch);
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#define PANVK_PHYSICAL_DEVICE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "panvk_instance.h"
|
||||
|
||||
@@ -31,6 +32,12 @@ struct panvk_physical_device {
|
||||
} kmod;
|
||||
|
||||
const struct panfrost_model *model;
|
||||
|
||||
struct {
|
||||
dev_t primary_rdev;
|
||||
dev_t render_rdev;
|
||||
} drm;
|
||||
|
||||
struct {
|
||||
const struct pan_blendable_format *blendable;
|
||||
const struct panfrost_format *all;
|
||||
|
Reference in New Issue
Block a user