Beware of D3D feature level 11 in the Windows Phone emulator

Beware of D3D feature level 11 in the Windows Phone emulator

  • Comments 9

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:

    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3
    };

and change it to:

    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_9_3
    };

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.

  • Why is it in the template like that to begin with?

  • > Why is it in the template like that to begin with?

    An oversight.  We will most likely fix that next time we get a chance.

  • 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?

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

  • 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.

  • Any news about XNA 5.0 ? sharpdx is unripe

  • xna game studio in linux

    www.youtube.com/watch

  • Shawn what i do not understand is this ,, why do you not upgrade xna to HIGHDEF Profile and make to run on windows phone 7.8 and version 8

    and all where happy.. allso why is there no multicore support for game developerment on windows phone 8 , where we need this to run on a deticated core for games

    allso i wood like Microsoft official support of managed games on there devices ? can you explain why not

    one more ? i have seen all the build sessions and you speek of 3 screens , it is just me that is missing somthing

    where can i download the xbox 360 c++ sdk for developers, so we have the 3 screens developerment as you promisse

    and some notice here the xbox live api is include now ,, but you promisse that all developers can take avantage of the api

    channel9.msdn.com/.../PLAT-756T

    please look at the session , or fastfoward to 00:53:00

    hope you can answher these ? now you can speek freely about things as you speek of in you previse post

    Best regards

    Michael Hansen

Page 1 of 1 (9 items)
Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post