Question

My windows 8 app is failing the Certification test:

The app should call the Trim API on its IDXGIDevice3 interface anytime it is about to be suspended.

The link takes me to a C++ page, but I'm using SharpDX. I can only find one example of this mentioned on a post in a book here https://www.packtpub.com/article/integrating-direct3d-xaml-windows81#more

Unfortunately it mentioned a DeviceManager class (from the book I think?) and my SharpDX.DXGI.Device3 is missing. There is a Device1 and Device2 but no 3. Perhaps different version of the library or I'm missing a reference to something else?

So I'm looking for an example of how to call Trim so that the Certification app is happy and it cleans up any graphics objects etc on suspending the app.

void App::OnSuspending(
_In_ Platform::Object^ sender,
_In_ Windows::ApplicationModel::SuspendingEventArgs^ args
)
  {
      Windows::ApplicationModel::SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();

      // Save application data

      m_exampleDxgiAdapter->Trim();
      deferral->Complete();
  }
Was it helpful?

Solution

The following example shows how to call Trim() in order to pass the Certification process:

async void OnSuspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
{
    var Deferral = e.SuspendingOperation.GetDeferral();

    using (var Device = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware, SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport, new[] { SharpDX.Direct3D.FeatureLevel.Level_11_1, SharpDX.Direct3D.FeatureLevel.Level_11_0 }))
    using (var Direct3DDevice = Device.QueryInterface<SharpDX.Direct3D11.Device1>())
    using (var DxgiDevice3 = Direct3DDevice.QueryInterface<SharpDX.DXGI.Device3>())
        DxgiDevice3.Trim();

    Deferral.Complete();
}

You must download and use SharpDX Latest Dev Package (which is currently 2.5.1) for SharpDX.DXGI.Device3

OTHER TIPS

SharpDX.DXGI.Device3 is available from latest SharpDX dev package (2.5.1) from the DirectX11_2-winrt assemblies.

This DeviceManager is not part of DirectX API but looks like it is part of the sample from the book. You need to retrieve the Device3 device by "COM-querying" the interface on the original DXGI device (something like deviceManager.Device1.QueryInterface<Device3>();)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top