0

我使用此处解释的相同方法来避免通过 RDP 使用D3DImage.SetBackBuffer()方法的问题,但我发现当我断开连接并重新连接到同一个会话时,ASA 我调整了我的控件大小我得到了异常:后台缓冲区的设备是无效

这是我使用的代码

public void Update(SharpDX.Direct3D11.Device device, SharpDX.Direct3D11.DeviceContext context,
    Texture2D wpfSharedSurface, IntPtr sharedSurfacePtr)
{
    // Make sure that Lock/Unlock/SetBackBuffer...etc. are called on the UI thread
    context.ResolveSubresource(Surface.RenderTexture, 0, wpfSharedSurface, 0,
        Surface.RenderTexture.Description.Format);

    // Emits the proper Query.End to track the end of rendering for this BeginDraw/EndDraw pair.
    device.ImmediateContext.End(Surface.QuerySync);
    device.ImmediateContext.Flush();

    while (!device.ImmediateContext.IsDataAvailable(Surface.QuerySync))
    {

    }

    // http://msdn.microsoft.com/en-us/library/system.windows.interop.d3dimage.aspx

    D3DImageInstance.Lock();

    D3DImageInstance.SetBackBuffer(D3DResourceType.IDirect3DSurface9, sharedSurfacePtr, true // allow RDP to work 
        );
    D3DImageInstance.AddDirtyRect(new Int32Rect(0, 0, Width, Height));
    D3DImageInstance.Unlock();
}

下图显示了发生的错误 在此处输入图像描述

我还尝试了在这里这里找到的提示,但没有运气(如预期的那样)

4

0 回答 0