When I joined Bitsquid a month ago, someone mentioned they wanted to upgrade the DirectX SDK to get some improvements, but that there was a dependency in the way. I was foolish, and volunteered to investigate. Over the past ten days or so I have untangled the whole mess, leading to a successful upgrade. I now want to share my findings so the next unfortunate soul can save some time.
Step 1: Explore
First stop: MSDN's article. I had heard that the DirectX SDK was now included in the Windows SDK, but I wasn't sure what that covered. This article sums it up. With a teammate, we went through the whole list, figuring out what we were and were not using. In the end, the only problematic components were XInput, XAudio2, and D3DX9Mesh. The bulk of the codebase had already been converted away from using D3DX, which was great!
However another thing needed clearing up. Our minspec is still Windows 7. How was that going to work? Luckily, MSDN had the answer again. This article reveals that the Windows 8.X SDK is available on Windows 7. This is covered in more details on this page and that page.
Step 2: Well let's just try then
I changed the paths in our project generation files to the Windows SDK. I also added the June 2010 SDK, but only for XAudio2 and D3DX9Mesh (more on XInput further down). After fixing only a few compile errors, things seemed mostly fine... until I got a runtime crash about ID3D11ShaderReflection. Huh?
Step 3: GUIDs and the magic
I had wrongly assumed that the link errors I had been seeing when changing the paths were caused by DX9, because I read too fast. Linking with the old dxguid.lib made the errors go away, so I didn't think about it more. However, a large part of DirectX relies on GUIDs, unique hardcoded identifiers. When debugging, I noticed that IID_ID3D11ShaderReflection had the wrong value compared to the Windows SDK header, which was causing the crash. I went on a goose hunt for what was somehow changing this value, and wasted a day to looking for a wrongly included file.
But by default, those GUIDs are
extern variables, and will get their values from lib files.
And I was linking with an old one.
I removed dxguid.lib from the linker, but that of course caused the GUIDs to be undefined.
The solution for that is to
#define INITGUID before including windows.h.
Thanks to the Ogre3D forums for pointing me towards
the relevant support page,
since they encountered the same issue before.
At this point everything was fine, except that it was failing on the build machines.
Step 4: d3dcompiler
The first error had been around for a long time. We had so far, unknowingly, relied on the d3dcompiler DLL being present in System32! Since System32 is part of the default DLL search path, this is easy to overlook, especially when the DirectX SDK is a required install anyway. We were now relying on a more recent version, supposed to be included in the Windows SDK. Yet still it was failing... because we did not have a proper installation step. I tweaked the project files again, adding a copy step for that DLL. CI, however, was still failing.
Step 5: XInput
XInput comes in several versions in the Windows SDK.
1.4 is the most recent one as I'm writing this, and is Windows 8-only.
To use XInput on Windows 7, you need to use version 9.1.0.
For that, ensure that
is set to the proper value (see further up on the page).
You also need to explicitly link with XInput9_1_0.lib and not XInput.lib,
or Windows 7 will get a runtime crash trying to fetch XInput1_4.dll, which doesn't exist on Windows 7.
In my case this was breaking the automated tests on a Windows 7 machine, but was completely fine on my Windows 8 workstation.
Step 6: Profit?
As far as I can tell this should be the end of it, but the rendering team has yet to stress-test it. We'll see what breaks as they poke around :)
Hopefully this can save you some time if you're doing a similar upgrade, or convince you to give it a try if you've been holding back.