Beware of D3D feature level 11 in the Windows Phone emulator

Windows Phone 8 devices support Direct3D 11.1 feature level 9.3, but our emulator uses the WARP rasterizer, which can handle all the way up to feature level 11. This means that, if you aren't careful, it is possible to accidentally use more advanced D3D features while developing in the emulator, only to get an unpleasant surprise when these things don't work on an actual device.

Q: how to avoid unpleasant surprises?

A: make sure you explicitly select feature level 9.3, even when running in the emulator.

Starting with the Windows Phone Direct3D App project template, open up Direct3DBase.cpp, find this code in the CreateDeviceResources method:

Tada! Now you will be using 9.3 in the emulator, the same as on actual device hardware.

Right above this code, notice how the template turns on D3D11_CREATE_DEVICE_DEBUG only if the _DEBUG define is set? This enables extra validation to give more useful error messages if you make a mistake in your D3D API usage. But that validation is not free, so we only enable it in debug builds.

Oh, that explains why the enulator was running slowly with Direct3D11 if the device ia a WARP. Is there any chance to get in the future a hardware device using the GPU host? (Though using GPU host would lead to much more power than WP8 GPU, and I guess there is no real way to simulate the slowness of a mobile GPU on a desktop GPU).

As I don't have a WP8 phone, can't test anything, but with a i7 4 cores 3.4GHz machine, how much is it on par perf-wise with a real hardware phone compare to using WARP?

Thanks

6 Nov 2012 6:36 PM

This is very useful for me.Can you share with us something more like this. Thanks.

Lucian

7 Nov 2012 12:22 AM

To avoid having to remember this each time you create a new project, you could simply edit the Direct3DBase.cpp file in the template itself, i.e. in the zip file c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\VC\Windows Phone\1033\WindowsPhoneDirect3DApp.zip

> Oh, that explains why the enulator was running slowly with Direct3D11 if the device ia a WARP.

It obviously depends what hardware you run it on, but unless you're on something lower end like a slow laptop, the emulator is actually not that far removed from the performance of an actual device. Obviously they will never match exactly, but it's within an order of magnitude. Certainly much closer than using a high end desktop GPU would be.

> As I don't have a WP8 phone, can't test anything, but with a i7 4 cores 3.4GHz machine, how much is it on par perf-wise with a real hardware phone compare to using WARP?

A real phone will likely be a little faster than emulator on the GPU side, but obviously much slower on the CPU side. So it very much depends on what your workload is like. If you are limited by draw call submissions or excessive memory bandwidth, the emulator will probably end up faster than a device, but if you are limited by texture fetch or triangle rasterization, the device will likely win.