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;
#include "nvk_instance.h"
#include "nvk_physical_device.h"
+#include "util/build_id.h"
#include "vulkan/wsi/wsi_common.h"
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
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)
#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"
.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,
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;
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];
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);