如何使用Win2D模拟DeviceLost事件? [英] How can I simulate a DeviceLost event with Win2D?

查看:158
本文介绍了如何使用Win2D模拟DeviceLost事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UWP应用程序中有一个CanvasControl,我注意到当我将Surface闲置一会儿并且它会自动进入睡眠状态时,CanvasControl在恢复后将不再起作用.以前绘制的位图现在为空白.

I have a CanvasControl in a UWP app and I've noticed when I leave my Surface alone for a while and it goes to sleep automatically, the CanvasControl no longer works after resuming. The previously drawn bitmap is now blank.

我尝试在Visual Studio 2015中模拟挂起/继续,但这似乎没有引起问题.恢复正常.

I tried to simulate Suspend/Resume in Visual Studio 2015, but that doesn't seem to cause a problem. It resumes fine.

我感觉它与CanvasDevice.DeviceLost事件有关,尽管我通过CanvasControl.CreateResources事件来管理它,但是我找不到一种容易测试的方法.

I have a feeling it has to do with the CanvasDevice.DeviceLost event, and although I manage that with the CanvasControl.CreateResources event, I can't find a way to easily test it.

我尝试了以下操作:

// This throws an exception. Not allowed to do this.
myCanvas.Device.RaiseDeviceLost(); 

// and this doesn't report a device lost, but myCanvas becomes unusable.
myCanvas.Device.Dispose();

是否可以通过编程方式调用CanvasDevice.DeviceLost事件?我该如何伪造?

Is there a way to programmatically invoke a CanvasDevice.DeviceLost event? How can I fake it?

推荐答案

无法使用API​​触发设备丢失事件,但是可以使用命令行工具:

It's not possible to trigger a device lost event with an API, but there is a command line tool you can use:

DXCap.exe -forcetdr

对于Win10 build 10586或更高版本,您需要的DXCap版本是Windows 10图形工具包的一部分. https://msdn.microsoft.com/en-us/library/mt125501 .aspx#InstallGraphicsTools

The version of DXCap you need is part of the Graphics Tools for Windows 10 package, for Win10 build 10586 or later: https://msdn.microsoft.com/en-us/library/mt125501.aspx#InstallGraphicsTools

安装VSGD后,您可以在windows \ system32目录中找到DXCap.

After installing the VSGD, you can find DXCap in the windows\system32 directory.

不幸的是,该选项看起来(尚未)记录在案,而是从命令行记录的:

Unfortunately it looks like this option is not (yet) documented, but from the command line:

  -forcetdr          Don't capture or replay, but simply force a GPU Timeout
                     Detection and Recovery event, then exit.

这篇关于如何使用Win2D模拟DeviceLost事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆