Mesa (main): dzn: Hook-up device-lost detection

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 28 09:53:32 UTC 2022


Module: Mesa
Branch: main
Commit: 0371b1707b2ff1b5c60fa2248a1eeea79d977544
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0371b1707b2ff1b5c60fa2248a1eeea79d977544

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Mon Jun 27 10:23:10 2022 +0200

dzn: Hook-up device-lost detection

Provide a vk_device::check_status() implementation so the code can
call it at key moments to detect when a device-lost event (device-removed
in D3D12) has been received.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17249>

---

 src/microsoft/vulkan/dzn_device.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c
index f72a46a8ae0..b08a8683766 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -1898,6 +1898,17 @@ dzn_device_destroy(struct dzn_device *device, const VkAllocationCallbacks *pAllo
    vk_free2(&instance->vk.alloc, pAllocator, device);
 }
 
+static VkResult
+dzn_device_check_status(struct vk_device *dev)
+{
+   struct dzn_device *device = container_of(dev, struct dzn_device, vk);
+
+   if (FAILED(ID3D12Device_GetDeviceRemovedReason(device->dev)))
+      return vk_device_set_lost(&device->vk, "D3D12 device removed");
+
+   return VK_SUCCESS;
+}
+
 static VkResult
 dzn_device_create(struct dzn_physical_device *pdev,
                   const VkDeviceCreateInfo *pCreateInfo,
@@ -1954,6 +1965,7 @@ dzn_device_create(struct dzn_physical_device *pdev,
    device->vk.ref_pipeline_layout = dzn_device_ref_pipeline_layout;
    device->vk.unref_pipeline_layout = dzn_device_unref_pipeline_layout;
    device->vk.create_sync_for_memory = dzn_device_create_sync_for_memory;
+   device->vk.check_status = dzn_device_check_status;
 
    device->dev = dzn_physical_device_get_d3d12_dev(pdev);
    if (!device->dev) {



More information about the mesa-commit mailing list