From 701c88983ce70508725abc2cf2fb24a65c90aacf Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 15 Jul 2022 16:19:08 +0200 Subject: [PATCH] Add DeviceLostReason.AccessDenied value --- src/ComputeSharp/Graphics/DeviceLostReason.cs | 23 +++++++++++++------ .../Graphics/GraphicsDevice.DeviceLost.cs | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ComputeSharp/Graphics/DeviceLostReason.cs b/src/ComputeSharp/Graphics/DeviceLostReason.cs index 3161ec7e..b27f1132 100644 --- a/src/ComputeSharp/Graphics/DeviceLostReason.cs +++ b/src/ComputeSharp/Graphics/DeviceLostReason.cs @@ -1,4 +1,7 @@ -namespace ComputeSharp; +using TerraFX.Interop.DirectX; +using TerraFX.Interop.Windows; + +namespace ComputeSharp; /// /// Indicates a reason a instance was lost. @@ -9,33 +12,39 @@ public enum DeviceLostReason /// The application's device failed due to badly formed commands sent by the application. /// This is an design-time issue that should be investigated and fixed. /// - DeviceHung = unchecked((int)0x887A0006), + DeviceHung = DXGI.DXGI_ERROR_DEVICE_HUNG, /// /// The video card has been physically removed from the system, or a driver upgrade for /// the video card has occurred. The application should destroy and recreate the device. /// - DeviceRemoved = unchecked((int)0x887A0005), + DeviceRemoved = DXGI.DXGI_ERROR_DEVICE_REMOVED, /// /// The device failed due to a badly formed command. This is a run-time issue. /// The application should destroy and recreate the device. /// - DeviceReset = unchecked((int)0x887A0007), + DeviceReset = DXGI.DXGI_ERROR_DEVICE_RESET, /// /// The driver encountered a problem and was put into the device removed state. /// - DriverInternalError = unchecked((int)0x887A0020), + DriverInternalError = DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR, /// /// The application provided invalid parameter data. /// This must be debugged and fixed before the application is released. /// - InvalidCall = unchecked((int)0x887A0001), + InvalidCall = DXGI.DXGI_ERROR_INVALID_CALL, + + /// + /// The device was removed after attempting an invalid operation (eg. trying to write to the wrong swapchain buffer). + /// The application should destroy and recreate the device. This also likely indicates an application bug. + /// + AccessDenied = DXGI.DXGI_ERROR_ACCESS_DENIED, /// /// The device was lost for an unspecified reason. /// - UnspecifiedError = unchecked((int)0x80004005) + UnspecifiedError = E.E_FAIL } diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs index 27266a2d..c6febdb6 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs @@ -90,6 +90,7 @@ unsafe partial class GraphicsDevice DXGI.DXGI_ERROR_DEVICE_RESET => DeviceLostReason.DeviceReset, DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => DeviceLostReason.DriverInternalError, DXGI.DXGI_ERROR_INVALID_CALL => DeviceLostReason.InvalidCall, + DXGI.DXGI_ERROR_ACCESS_DENIED => DeviceLostReason.AccessDenied, _ => DeviceLostReason.UnspecifiedError };