SDL2, Direct3D11 renderer and Windows 7

SDL2 has some good renderers, specially for Windows OS: Direct3D (version 9), OpenGL, software and since a few months, Direct3D11 (version 11) was also added.

The first three, have been extensively tested while developing CRM64Pro and some bugs were found, submitted and fixed so it is quite stable and ready for production games. Recently, I have interested on the Direct3D v11 renderer, it uses Direct2D so it could be faster than Direct3D v9 and I always have read that Direct3D v11 is cleaner than v9 and a big performance increase can be obtained. Well, now is where this history begins.

All my computers have installed Windows 7 SP1 and have some VMs running RHEL6, Fedora, Windows XP, Windows 8 and Windows 10 for testing purposes and I mainly use Visual Studio 2010 with Windows 8.1 SDK.

After downloading SDL 2.0.4 latest snapshot (as of today), enabling Direct3D v11 (it is disabled by default but you can enable it on sdl_config_windows.h file), compiling and linking against a test application (testrendertarget project), I started to take some performance numbers to be used as reference against Direct3D v11.

In general, Direct3D v9 is faster than OpenGL renderer although it depends on the video card and drivers (in my case, an AMD Radeon HD6950). The problem was when I executed the Direct3D v11 test… it miserably failed not matter what I tried! with this error:

Couldn’t create renderer: D3D11_CreateSwapChain, IDXGIFactory2::CreateSwapChainForHwnd: (random characters, aka garbage! Later on, during debugging, I could see that the error code was: DXGI_ERROR_INVALID_CALL)

I did the mandatory “googling it” and after spending some time reading several but non-related to SDL2 stuff about this interfaces, I started to think that probably the problem is the Windows 7 itself but well, I know it is able to support DX11 and my video card too so time for checking the SDL2 Direct3D v11 source code implementation.

I quickly see that it is using DX11.1 and not DX11.0. The former one was introduced on Windows 8 but later on, a patch was released for Windows 7 users that partially implemented some functionality of DX11.1 on Windows 7 systems. This patch is named “Platform Update for Windows 7” (KB2670838) and if you have updated your system, there are a lot of chances that you already have it.

The key here was the word “partially implemented”, so apparently, some functionality of DX11.1 is not available on Windows 7. I read the Microsoft documentation to exactly check what is supported and what is unsupported. It was not very hard to find that the CreateSwapChainForHwnd() method has a field for scaling and when it is set to DXGI_SCALING_NONE, Windows 7 with the platform update caused a DXGI_ERROR_INVALID_CALL. In other words, Windows 7 does not support calling CreateSwapChainForHwnd() when scaling is none.

Following the mandatory curiosity, I changed DXGI_SCALING_NONE by DXGI_SCALING_STRETCH, which is supported and, indeed, it succeeded! but while debugging the application I found that there are calls to other methods that are directly unsupported as IDXGISwapChain1::SetRotation() and more, so I stopped here and fully understand that SDL2 Direct3D v11 renderer does not work on Windows 7.

Now, I wanted to know what happen on a VMs with Windows 10 Preview installed, so I did the tests and voila! Direct3D 11 renderer works fine so, I imagine also works on Windows 8. The problem is that I can not test the performance on a VM as the numbers are not representative in comparison with a physical machine.

At the end, it was like a mix of feelings: I was able to understand everything so I was happy, but I could not test the performance of this renderer and that was my initial goal. At some point in the next days, I will reinstall one of my computers with Windows 10 and I could go on with this test. The final goal is to update glSDL Benchmark including this new renderer in order to have a good and reliable performance numbers.

The conclusion is that SDL2 Direct3D v11 renderer does NOT support Windows 7 and you need Windows 8+ for enjoying it.

1 Response to SDL2, Direct3D11 renderer and Windows 7

  1. Asuka says:

    The fact is that if you comment the SetRotation call, it just can run

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.