mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
panvk: Generate proper device and driver UUIDs
This follows what NVK, ANV and V3DV does. Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29161>
This commit is contained in:
parent
886c054691
commit
8ea2931ed1
4 changed files with 37 additions and 22 deletions
|
|
@ -9,6 +9,9 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "util/build_id.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
|
||||
#include "vk_alloc.h"
|
||||
#include "vk_log.h"
|
||||
|
||||
|
|
@ -126,6 +129,19 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
|
||||
|
||||
const struct build_id_note *note =
|
||||
build_id_find_nhdr_for_addr(panvk_CreateInstance);
|
||||
if (!note) {
|
||||
return vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"Failed to find build-id");
|
||||
}
|
||||
|
||||
unsigned build_id_len = build_id_length(note);
|
||||
if (build_id_len < SHA1_DIGEST_LENGTH) {
|
||||
return vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"build-id too short. It needs to be a SHA");
|
||||
}
|
||||
|
||||
pAllocator = pAllocator ?: vk_default_allocator();
|
||||
instance = vk_zalloc(pAllocator, sizeof(*instance), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||
|
|
@ -163,6 +179,9 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
|
||||
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
|
||||
|
||||
STATIC_ASSERT(sizeof(instance->driver_build_sha) == SHA1_DIGEST_LENGTH);
|
||||
memcpy(instance->driver_build_sha, build_id_data(note), SHA1_DIGEST_LENGTH);
|
||||
|
||||
*pInstance = panvk_instance_to_handle(instance);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ struct panvk_instance {
|
|||
|
||||
enum panvk_debug_flags debug_flags;
|
||||
|
||||
uint8_t driver_build_sha[20];
|
||||
|
||||
struct {
|
||||
struct pan_kmod_allocator allocator;
|
||||
} kmod;
|
||||
|
|
|
|||
|
|
@ -57,19 +57,6 @@ get_cache_uuid(uint16_t family, void *uuid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
get_driver_uuid(void *uuid)
|
||||
{
|
||||
memset(uuid, 0, VK_UUID_SIZE);
|
||||
snprintf(uuid, VK_UUID_SIZE, "panfrost");
|
||||
}
|
||||
|
||||
static void
|
||||
get_device_uuid(void *uuid)
|
||||
{
|
||||
memset(uuid, 0, VK_UUID_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
get_device_extensions(const struct panvk_physical_device *device,
|
||||
struct vk_device_extension_table *ext)
|
||||
|
|
@ -231,7 +218,8 @@ get_features(const struct panvk_physical_device *device,
|
|||
}
|
||||
|
||||
static void
|
||||
get_device_properties(const struct panvk_physical_device *device,
|
||||
get_device_properties(const struct panvk_instance *instance,
|
||||
const struct panvk_physical_device *device,
|
||||
struct vk_properties *properties)
|
||||
{
|
||||
/* HW supports MSAA 4, 8 and 16, but we limit ourselves to MSAA 4 for now. */
|
||||
|
|
@ -585,8 +573,19 @@ get_device_properties(const struct panvk_physical_device *device,
|
|||
|
||||
memcpy(properties->pipelineCacheUUID, device->cache_uuid, VK_UUID_SIZE);
|
||||
|
||||
memcpy(properties->driverUUID, device->driver_uuid, VK_UUID_SIZE);
|
||||
memcpy(properties->deviceUUID, device->device_uuid, VK_UUID_SIZE);
|
||||
const struct {
|
||||
uint16_t vendor_id;
|
||||
uint32_t device_id;
|
||||
uint8_t pad[8];
|
||||
} dev_uuid = {
|
||||
.vendor_id = ARM_VENDOR_ID,
|
||||
.device_id = device->model->gpu_id,
|
||||
};
|
||||
|
||||
STATIC_ASSERT(sizeof(dev_uuid) == VK_UUID_SIZE);
|
||||
memcpy(properties->deviceUUID, &dev_uuid, VK_UUID_SIZE);
|
||||
STATIC_ASSERT(sizeof(instance->driver_build_sha) >= VK_UUID_SIZE);
|
||||
memcpy(properties->driverUUID, instance->driver_build_sha, VK_UUID_SIZE);
|
||||
|
||||
snprintf(properties->driverName, VK_MAX_DRIVER_NAME_SIZE, "panvk");
|
||||
snprintf(properties->driverInfo, VK_MAX_DRIVER_INFO_SIZE,
|
||||
|
|
@ -687,9 +686,6 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
|
||||
vk_warn_non_conformant_implementation("panvk");
|
||||
|
||||
get_driver_uuid(&device->driver_uuid);
|
||||
get_device_uuid(&device->device_uuid);
|
||||
|
||||
device->drm_syncobj_type = vk_drm_syncobj_get_type(device->kmod.dev->fd);
|
||||
/* We don't support timelines in the uAPI yet and we don't want it getting
|
||||
* suddenly turned on by vk_drm_syncobj_get_type() without us adding panvk
|
||||
|
|
@ -704,7 +700,7 @@ panvk_physical_device_init(struct panvk_physical_device *device,
|
|||
get_features(device, &supported_features);
|
||||
|
||||
struct vk_properties properties;
|
||||
get_device_properties(device, &properties);
|
||||
get_device_properties(instance, device, &properties);
|
||||
|
||||
struct vk_physical_device_dispatch_table dispatch_table;
|
||||
vk_physical_device_dispatch_table_from_entrypoints(
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ struct panvk_physical_device {
|
|||
} formats;
|
||||
|
||||
char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
|
||||
uint8_t driver_uuid[VK_UUID_SIZE];
|
||||
uint8_t device_uuid[VK_UUID_SIZE];
|
||||
uint8_t cache_uuid[VK_UUID_SIZE];
|
||||
|
||||
struct vk_sync_type drm_syncobj_type;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue