DXGI_ERROR_ACCESS_LOST #798
Description
Hello,
I have a problem with SharpDX and the fullscreen apps. In mode windowed, there aren't exceptions.
`{SharpDX.SharpDXException: HRESULT: [0x887A0026], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_ACCESS_LOST/AccessLost], Message: Le mutex indexé a été abandonné.
à SharpDX.Result.CheckError()
à SharpDX.DXGI.OutputDuplication.AcquireNextFrame(Int32 timeoutInMilliseconds, OutputDuplicateFrameInformation& frameInfoRef, Resource& desktopResourceOut)
à KMPP.DxScreenCapture.CaptureScreen(DataStream& dataStreamCapture) dans C:\Users\Axwel\Documents\TonidoSync\Visual Studio 2015\Projects\ScreenAmbilightConsole\ScreenAmbilightConsole\DxScreenCapture.cs:ligne 71}`
`public Device DeviceComputer;
public Texture2DDescription Texture2DDescriptionObject;
public OutputDuplication DuplicatedOutputObject;
public Texture2D Texture2DObject;
public DxScreenCapture()
{
// # of graphics card adapter
const int numAdapter = 0;
// # of output device (i.e. monitor)
const int numOutput = 0;
// Create DXGI Factory1
var factory = new Factory1();
var adapter = factory.GetAdapter1(numAdapter);
// Create device from Adapter
DeviceComputer = new Device(DriverType.Hardware, DeviceCreationFlags.PreventThreadingOptimizations);
// Get DXGI.Output
var output = adapter.GetOutput(numOutput);
var output1 = output.QueryInterface<Output1>();
// Width/Height of desktop to capture
int width = Program.IniFile.Configs["screen_config"].GetInt("width");
int height = Program.IniFile.Configs["screen_config"].GetInt("height");
// Create Staging texture CPU-accessible
Texture2DDescriptionObject = new Texture2DDescription
{
CpuAccessFlags = CpuAccessFlags.Read,
BindFlags = BindFlags.None,
Format = Format.B8G8R8A8_UNorm,
Width = width,
Height = height,
OptionFlags = ResourceOptionFlags.None,
MipLevels = 1,
ArraySize = 1,
SampleDescription = { Count = 1, Quality = 0 },
Usage = ResourceUsage.Staging
};
Texture2DObject = new Texture2D(DeviceComputer, Texture2DDescriptionObject);
// Duplicate the output
DuplicatedOutputObject = output1.DuplicateOutput(DeviceComputer);
}
public bool CaptureScreen(out DataStream dataStreamCapture)
{
dataStreamCapture = null;
try
{
SharpDX.DXGI.Resource screenResource;
OutputDuplicateFrameInformation duplicateFrameInformation;
// Try to get duplicated frame within given time
DuplicatedOutputObject.AcquireNextFrame(10000, out duplicateFrameInformation, out screenResource);
// copy resource into memory that can be accessed by the CPU
using (var screenTexture2D = screenResource.QueryInterface<Texture2D>())
DeviceComputer.ImmediateContext.CopyResource(screenTexture2D, Texture2DObject);
// Get the desktop capture texture
DeviceComputer.ImmediateContext.MapSubresource(Texture2DObject, 0, MapMode.Read, MapFlags.None, out dataStreamCapture);
screenResource.Dispose();
DuplicatedOutputObject.ReleaseFrame();
return true;
}
catch (SharpDXException e)
{
return false;
}
}`
What the problem ?