Я получаю приведенную ниже ошибку при попытке использовать DXGI для захвата встроенного экрана на моем ноутбуке, который работает на Intel 630 HD с последней версией драйвера. Код работает, когда я снимаю внешний экран, работающий на моем GTX 1070.
SharpDX.SharpDXException
HResult=0x80070057
Message=HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
Код в моей форме:
desktopDuplicator = new DesktopDuplicatorD11(1,0, DesktopDuplicatorD11.VSyncLevel.None);
Раздел кода, в котором ошибки:
private bool RetrieveFrame()
{
if (desktopImageTexture == null)
desktopImageTexture = new Texture2D(mDevice, mTextureDescription);
frameInfo = new OutputDuplicateFrameInformation();
try
{
mDeskDuplication.AcquireNextFrame(500, out frameInfo, out desktopResource);
}
catch (SharpDXException ex)
{
if (ex.ResultCode.Code == SharpDX.DXGI.ResultCode.WaitTimeout.Result.Code)
{
return true;
}
if (ex.ResultCode.Failure)
{
throw new DesktopDuplicationException("Failed to acquire next frame.");
}
}
using (var tempTexture = desktopResource.QueryInterface<Texture2D>())
{
mDevice.ImmediateContext.CopyResource(tempTexture, desktopImageTexture);
}
return false;
}
Это ошибки конкретно на линии:
desktopImageTexture = new Texture2D(mDevice, mTextureDescription);
Что вызывает ошибку при использовании внутреннего дисплея и intel 630?
Правка # 1: создание mTextureDescription:
this.mTextureDescription = new Texture2DDescription()
{
CpuAccessFlags = CpuAccessFlags.Read,
BindFlags = BindFlags.None,
Format = Format.B8G8R8A8_UNorm,
Width = this.mOutputDescription.DesktopBounds.Right,
Height = this.mOutputDescription.DesktopBounds.Bottom,
OptionFlags = ResourceOptionFlags.None,
MipLevels = 1,
ArraySize = 1,
SampleDescription = { Count = 1, Quality = 0 },
Usage = ResourceUsage.Staging
};
Весь процесс дублирования рабочего стола выполняется в одном и том же потоке.
Обновление № 2: На Intel 630 Width = this.mOutputDescription.DesktopBounds.Right,
возвращается 0, а на моем 1070 - 1920.