locked
WACK test fails with an error saying the Trim method was not called RRS feed

  • Question

  • 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 implementation
    void DX::DeviceResources::Trim()
    {
    	ComPtr<IDXGIDevice3> dxgiDevice;
    	DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice));
    
    	dxgiDevice->Trim();
    }
    
    //declaration of m_d3dDevice
    Microsoft::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() ?

    Monday, December 30, 2013 8:40 AM

All replies

  • 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();
    
    		}


    n.Wright

    Monday, December 30, 2013 2:25 PM
  • The code for the Trimmer method will cause a crash because of using QueryInterface from a null object. I looked at a online document and accordingly made the following changes:

    IDXGIDevice3 * pDXGIDevice;
    HRESULT hr = m_d3dDevice->QueryInterface(__uuidof(IDXGIDevice3), (void **) &pDXGIDevice);
    pDXGIDevice->Trim();

    After this, I get the same error saying Trim was not called.

    Tuesday, December 31, 2013 9:01 AM