Graphics Reference
In-Depth Information
Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm,
Stereo = false,
SampleDescription.Count = 1,
SampleDescription.Quality = 0,
Usage = SharpDX.DXGI.Usage.BackBuffer |
SharpDX.DXGI.Usage.RenderTargetOutput,
Scaling = SharpDX.DXGI.Scaling.Stretch,
BufferCount = 2,
SwapEffect = SharpDX.DXGI.SwapEffect.FlipSequential,
Flags = SharpDX.DXGI.SwapChainFlags.None
};
return desc;
}
9.
We will not be implementing the Direct3D render loop within a
Run
method for our
Windows Store apps—this is because we will use the existing composition events
where appropriate. Therefore, we will create a new abstract method
Render
and
provide a default empty implementation of
Run
.
public abstract void Render();
[Obsolete("Use the Render method for WinRT", true)]
public override void Run()
{ }
How it works…
As of Windows 8.1 and DirectX Graphics Infrastructure (DXGI) 1.3, all Direct3D devices
created by our Windows Store apps should call
SharpDX.DXGI.Device3.Trim
when
suspending to reduce the memory consumed by the app and graphics driver. This reduces the
chance that our app will be terminated to reclaim resources while it is suspended—although
our application should consider destroying other resources as well. When resuming, drivers
that support trimming will recreate the resources as required.
We have used
Windows.ApplicationModel.Core.CoreApplication
rather than
Windows.UI.Xaml.Application
for the
Suspending
event, so that we can use the class
for both an XAML-based Direct3D app as well as one that implements its own
Windows.
ApplicationModel.Core.IFrameworkView
in order to render to
CoreWindow
directly.
Windows Store apps only support a flip presentation model and therefore require that
the swap chain is created using a
SharpDX.DXGI.SwapEffect.FlipSequential
swap effect; this in turn requires between two and 16 buffers specified in the
SwapChainDescription1.BufferCount
property. When using a flip model, it is also
necessary to specify the
SwapChainDescription1.SampleDescription
property with
Count=1
and
Quality=0
, as multisample anti-aliasing (MSAA) is not supported on the
swap chain buffers themselves. A flip presentation model avoids unnecessarily copying the
swap-chain buffer and increases the performance.