diff options
author | Boris Brezillon <boris.brezillon@collabora.com> | 2022-06-23 04:06:54 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-06-28 13:02:22 +0000 |
commit | b59abbe3d57488e7d86d6c71631647f073839957 (patch) | |
tree | 4835067b6c994633d1f1b39bdee2ba0028b9749d | |
parent | be019e69e2c4df7ab2db17a0320b00cf0c6518d8 (diff) |
dzn: Initialize UUIDs
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
-rw-r--r-- | src/microsoft/vulkan/dzn_device.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c index 9bffdcda0fb..dd03d853c0d 100644 --- a/src/microsoft/vulkan/dzn_device.c +++ b/src/microsoft/vulkan/dzn_device.c @@ -31,8 +31,12 @@ #include "vk_sync_dummy.h" #include "vk_util.h" +#include "git_sha1.h" + #include "util/debug.h" +#include "util/disk_cache.h" #include "util/macros.h" +#include "util/mesa-sha1.h" #include "glsl_types.h" @@ -236,6 +240,47 @@ dzn_DestroyInstance(VkInstance instance, dzn_instance_destroy(dzn_instance_from_handle(instance), pAllocator); } +static void +dzn_physical_device_init_uuids(struct dzn_physical_device *pdev) +{ + const char *mesa_version = "Mesa " PACKAGE_VERSION MESA_GIT_SHA1; + + struct mesa_sha1 sha1_ctx; + uint8_t sha1[SHA1_DIGEST_LENGTH]; + STATIC_ASSERT(VK_UUID_SIZE <= sizeof(sha1)); + + /* The pipeline cache UUID is used for determining when a pipeline cache is + * invalid. Our cache is device-agnostic, but it does depend on the features + * provided by the D3D12 driver, so let's hash the build ID plus some + * caps that might impact our NIR lowering passes. + */ + _mesa_sha1_init(&sha1_ctx); + _mesa_sha1_update(&sha1_ctx, mesa_version, strlen(mesa_version)); + disk_cache_get_function_identifier(dzn_physical_device_init_uuids, &sha1_ctx); + _mesa_sha1_update(&sha1_ctx, &pdev->options, sizeof(pdev->options)); + _mesa_sha1_update(&sha1_ctx, &pdev->options2, sizeof(pdev->options2)); + _mesa_sha1_final(&sha1_ctx, sha1); + memcpy(pdev->pipeline_cache_uuid, sha1, VK_UUID_SIZE); + + /* The driver UUID is used for determining sharability of images and memory + * between two Vulkan instances in separate processes. People who want to + * share memory need to also check the device UUID (below) so all this + * needs to be is the build-id. + */ + _mesa_sha1_compute(mesa_version, strlen(mesa_version), sha1); + memcpy(pdev->driver_uuid, sha1, VK_UUID_SIZE); + + /* The device UUID uniquely identifies the given device within the machine. */ + _mesa_sha1_init(&sha1_ctx); + _mesa_sha1_update(&sha1_ctx, &pdev->adapter_desc.VendorId, sizeof(pdev->adapter_desc.VendorId)); + _mesa_sha1_update(&sha1_ctx, &pdev->adapter_desc.DeviceId, sizeof(pdev->adapter_desc.DeviceId)); + _mesa_sha1_update(&sha1_ctx, &pdev->adapter_desc.SubSysId, sizeof(pdev->adapter_desc.SubSysId)); + _mesa_sha1_update(&sha1_ctx, &pdev->adapter_desc.Revision, sizeof(pdev->adapter_desc.Revision)); + _mesa_sha1_update(&sha1_ctx, &pdev->adapter_desc.AdapterLuid, sizeof(pdev->adapter_desc.AdapterLuid)); + _mesa_sha1_final(&sha1_ctx, sha1); + memcpy(pdev->device_uuid, sha1, VK_UUID_SIZE); +} + static VkResult dzn_physical_device_create(struct dzn_instance *instance, IDXGIAdapter1 *adapter, @@ -273,11 +318,6 @@ dzn_physical_device_create(struct dzn_instance *instance, vk_warn_non_conformant_implementation("dzn"); - /* TODO: correct UUIDs */ - memset(pdev->pipeline_cache_uuid, 0, VK_UUID_SIZE); - memset(pdev->driver_uuid, 0, VK_UUID_SIZE); - memset(pdev->device_uuid, 0, VK_UUID_SIZE); - uint32_t num_sync_types = 0; pdev->sync_types[num_sync_types++] = &dzn_sync_type; pdev->sync_types[num_sync_types++] = &instance->sync_binary_type.sync; @@ -511,6 +551,7 @@ dzn_physical_device_get_d3d12_dev(struct dzn_physical_device *pdev) dzn_physical_device_cache_caps(pdev); dzn_physical_device_init_memory(pdev); + dzn_physical_device_init_uuids(pdev); } mtx_unlock(&pdev->dev_lock); |