nvk: Add device and driver UUIDs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:

committed by
Marge Bot

parent
cccc044f51
commit
3d247f447e
@@ -55,7 +55,7 @@ VK_DEFINE_HANDLE_CASTS(nvk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE)
|
||||
VkResult nvk_device_ensure_slm(struct nvk_device *dev,
|
||||
uint32_t bytes_per_thread);
|
||||
|
||||
static struct nvk_physical_device *
|
||||
static inline struct nvk_physical_device *
|
||||
nvk_device_physical(struct nvk_device *device)
|
||||
{
|
||||
return (struct nvk_physical_device *)device->vk.physical;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "nvk_instance.h"
|
||||
|
||||
#include "nvk_physical_device.h"
|
||||
#include "util/build_id.h"
|
||||
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
|
||||
@@ -126,17 +127,40 @@ nvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
||||
|
||||
result = vk_instance_init(&instance->vk, &instance_extensions,
|
||||
&dispatch_table, pCreateInfo, pAllocator);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free(pAllocator, instance);
|
||||
return result;
|
||||
}
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_alloc;
|
||||
|
||||
instance->vk.physical_devices.try_create_for_drm =
|
||||
nvk_create_drm_physical_device;
|
||||
instance->vk.physical_devices.destroy = nvk_physical_device_destroy;
|
||||
|
||||
const struct build_id_note *note =
|
||||
build_id_find_nhdr_for_addr(nvk_CreateInstance);
|
||||
if (!note) {
|
||||
result = vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"Failed to find build-id");
|
||||
goto fail_init;
|
||||
}
|
||||
|
||||
unsigned build_id_len = build_id_length(note);
|
||||
if (build_id_len < 20) {
|
||||
result = vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"build-id too short. It needs to be a SHA");
|
||||
goto fail_init;
|
||||
}
|
||||
|
||||
assert(build_id_len >= VK_UUID_SIZE);
|
||||
memcpy(instance->driver_uuid, build_id_data(note), VK_UUID_SIZE);
|
||||
|
||||
*pInstance = nvk_instance_to_handle(instance);
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail_init:
|
||||
vk_instance_finish(&instance->vk);
|
||||
fail_alloc:
|
||||
vk_free(pAllocator, instance);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
struct nvk_instance {
|
||||
struct vk_instance vk;
|
||||
|
||||
uint8_t driver_uuid[VK_UUID_SIZE];
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(nvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "nvk_shader.h"
|
||||
#include "nvk_wsi.h"
|
||||
#include "git_sha1.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
|
||||
#include "vulkan/runtime/vk_device.h"
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
@@ -164,6 +165,9 @@ nvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
||||
.maxPerSetDescriptors = UINT32_MAX,
|
||||
.maxMemoryAllocationSize = (1u << 31),
|
||||
};
|
||||
memcpy(core_1_1.deviceUUID, pdev->device_uuid, VK_UUID_SIZE);
|
||||
struct nvk_instance *instance = nvk_physical_device_instance(pdev);
|
||||
memcpy(core_1_1.driverUUID, instance->driver_uuid, VK_UUID_SIZE);
|
||||
|
||||
VkPhysicalDeviceVulkan12Properties core_1_2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES,
|
||||
@@ -615,6 +619,17 @@ nvk_physical_device_try_create(struct nvk_instance *instance,
|
||||
device->dev = ndev;
|
||||
device->info = ndev->info;
|
||||
|
||||
const struct {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t pad[12];
|
||||
} dev_uuid = {
|
||||
.vendor_id = NVIDIA_VENDOR_ID,
|
||||
.device_id = device->info.pci_device_id,
|
||||
};
|
||||
STATIC_ASSERT(sizeof(dev_uuid) == VK_UUID_SIZE);
|
||||
memcpy(device->device_uuid, &dev_uuid, VK_UUID_SIZE);
|
||||
|
||||
device->mem_heaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||
device->mem_types[0].propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
device->mem_types[0].heapIndex = 0;
|
||||
|
@@ -19,6 +19,8 @@ struct nvk_physical_device {
|
||||
struct nv_device_info info;
|
||||
struct wsi_device wsi_device;
|
||||
|
||||
uint8_t device_uuid[VK_UUID_SIZE];
|
||||
|
||||
// TODO: add mapable VRAM heap if possible
|
||||
VkMemoryHeap mem_heaps[2];
|
||||
VkMemoryType mem_types[2];
|
||||
@@ -33,6 +35,12 @@ VK_DEFINE_HANDLE_CASTS(nvk_physical_device,
|
||||
VkPhysicalDevice,
|
||||
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
|
||||
static inline struct nvk_instance *
|
||||
nvk_physical_device_instance(struct nvk_physical_device *pdev)
|
||||
{
|
||||
return (struct nvk_instance *)pdev->vk.instance;
|
||||
}
|
||||
|
||||
VkResult nvk_create_drm_physical_device(struct vk_instance *vk_instance,
|
||||
struct _drmDevice *device,
|
||||
struct vk_physical_device **out);
|
||||
|
Reference in New Issue
Block a user