本文介绍了WACK测试失败,并显示错误,表示未调用Trim方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好,  我正在研究Winodws 8.1的D3D + XAML应用程序,我正在尝试全面了解WACK测试。一切顺利,但一次测试" Direct3D功能测试"。错误消息是:"包中的一个或多个应用程序在暂停时未在其DXGI设备上调用Trim()。" 我相信我正在呼叫正确的修剪方法。我正在关注示例应用程序代码。该示例应用程序可以使用名称"DirectX 3D射击游戏样本"来获得。在"Windows 8.1 app samples"中可以在MSDN上找到。 下面是一个小代码片段。 void App :: OnLaunched(LaunchActivatedEventArgs ^ args) {暂停+ = ref new SuspendingEventHandler(this,& App :: OnSuspending); 恢复+ = ref新的EventHandler< Object ^>(这个& App :: OnResuming); ..... } void App :: OnSuspending(Object ^ sender,SuspendingEventArgs ^ args) { SuspendingDeferral ^ deferral = args-> SuspendingOperation-> GetDeferral(); create_task([this,deferral]() { m_deviceResources-> Trim(); deferral-> Complete(); }); } //并且在DeviceResources实现中 void DX :: DeviceResources :: Trim() { ComPtr< IDXGIDevice3> dxgiDevice; DX :: ThrowIfFailed(m_d3dDevice.As(& dxgiDevice)); dxgiDevice-> Trim(); } // m_d3dDevice的声明 Microsoft :: WRL :: ComPtr< ID3D11Device2> m_d3dDevice; 有人可以指导我可能缺少的东西吗?也许,一些额外的暂停事件处理程序注册或调用Trim()的不同实现/方式? 解决方案 void SimpleSample :: OnSuspending(Platform :: Object ^ sender,SuspendingEventArgs ^ args) { //请求延迟后异步保存应用程序状态。持有延迟 //表示应用程序正忙于执行挂起操作。请 //意识到延期可能无法无限期延期。大约五秒后, //应用程序将被强制退出。 SuspendingDeferral ^ deferral = args-> SuspendingOperation-> GetDeferral(); create_task([this,deferral]() { Direct3DBase :: Trimmer(); deferral-> Complete(); } ); } ///////////////////////////////////// ///////////////// void Direct3DBase :: Trimmer() { IDXGIDevice3 * pDXGIDevice; HRESULT hr = pDXGIDevice-> QueryInterface(__ uuidof(dxgiDevice),(void **)& pDXGIDevice); pDXGIDevice-> Trim(); } Hi all, I am working on D3D + XAML application for Winodws 8.1 and I am trying to get an all clear on the WACK test. Everything goes fine but one test "Direct3D Feature Test". The error message is: "One or more applications in the package did not call Trim() on their DXGI Devices while being suspended."I believe I am calling the Trim method properly. I was following a sample application code. This sample application is available with the name "DirectX 3D shooting game sample" in the "Windows 8.1 app samples" available on MSDN.Below is a little code snippet.void App::OnLaunched(LaunchActivatedEventArgs^ args){ Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); Resuming += ref new EventHandler<Object^>(this, &App::OnResuming);.....}void App::OnSuspending(Object^ sender, SuspendingEventArgs^ args){SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();create_task([this, deferral](){m_deviceResources->Trim();deferral->Complete();});}//And inside the DeviceResources implementationvoid DX::DeviceResources::Trim(){ComPtr<IDXGIDevice3> dxgiDevice;DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice));dxgiDevice->Trim();}//declaration of m_d3dDeviceMicrosoft::WRL::ComPtr<ID3D11Device2> m_d3dDevice;Can someone please guide to what I might be missing? Perhaps, some additional suspend event handler registration or a different implementation/way of calling Trim() ? 解决方案 void SimpleSample::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args){// Save app state asynchronously after requesting a deferral. Holding a deferral// indicates that the application is busy performing suspending operations. Be// aware that a deferral may not be held indefinitely. After about five seconds,// the app will be forced to exit.SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();create_task([this, deferral](){Direct3DBase::Trimmer();deferral->Complete();});}//////////////////////////////////////////////////////void Direct3DBase::Trimmer(){IDXGIDevice3 * pDXGIDevice;HRESULT hr = pDXGIDevice->QueryInterface(__uuidof(dxgiDevice), (void **) &pDXGIDevice);pDXGIDevice->Trim();} 这篇关于WACK测试失败,并显示错误,表示未调用Trim方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 09:12