From 993b3f63c3f79a69ca3c9fe39d00ab4ec1efc064 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sun, 4 Jul 2021 17:08:34 -0600 Subject: [PATCH] Fix error on older GPUs --- Wabbajack.ImageHashing/DX11Device.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Wabbajack.ImageHashing/DX11Device.cs b/Wabbajack.ImageHashing/DX11Device.cs index 77384292..c27af5ae 100644 --- a/Wabbajack.ImageHashing/DX11Device.cs +++ b/Wabbajack.ImageHashing/DX11Device.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using DirectXTexNet; using Silk.NET.Core.Native; using Silk.NET.Direct3D11; @@ -7,7 +8,7 @@ namespace Wabbajack.ImageHashing { public unsafe class DX11Device { - private readonly ID3D11Device* _device; + private ID3D11Device* _device; public DX11Device() { @@ -52,12 +53,17 @@ namespace Wabbajack.ImageHashing { if (_device != null) { - return input.Compress((IntPtr)_device, format, compress, threshold); - } - else - { - return input.Compress(format, compress, threshold); + try + { + return input.Compress((IntPtr)_device, format, compress, threshold); + } + catch (COMException _) + { + _device->Release(); + _device = null; + } } + return input.Compress(format, compress, threshold); } }