Games for Windows and the DirectX SDK blog

Technical tips, tricks, and news about game development for Microsoft platforms including desktop, Xbox One, and UWP


Project maintained by walbourn Hosted on GitHub Pages — Theme by mattgraham
Home | Posts by Tag | Posts by Month

Twilight for Windows 7

general

Chuck Walbourn -

As a reminder, Windows 7 end-of-life for consumer is fast approaching on January 14, 2020. There are enterprises that will have on-going support contracts, but officially for consumers that’s the end of the road. There are of course a number of gamers still running Windows 7–thankfully according to the Valve Steam Hardware Survey they are almost all running 64-bit–, and it will remain important in some markets for some time to come. So, here are a few tips for developers still needing to support Windows 7.

First, Windows 7 Service Pack 1 is really your minimum. Officially Windows 7 RTM isn’t supported anymore even by the Visual C++ Runtime. There are also assumptions made for most consumer software that the system is updated with the latest changes from Windows Update. For a history of the roll-up releases, see KB4009469.

Second, keep in mind that SHA-2 support is an essential update for a Windows 7 machine. See KB4472027 and Windows Enforcement of SHA1 Certificates.

DirectX

Windows 7 SP1 supports all the DirectX 11.1 software features with KB2670838, but it does not support D3D_FEATURE_LEVEL_11_1 or the various ‘optional hardware features’ that require updated drivers. Note the 11.1 Runtime makes it a lot easier to interop Direct2D/DirectWrite with Direct3D 11. See this blog post and Microsoft Docs for the technical details.

A limited form of Direct3D 12 is also available for Windows 7 SP1. This includes the DirectX Raytracing API. It requires some careful coding, and existing Windows 10 DirectX 12 applications are probably making a number of other system assumptions that need to be revisited, but it’s a useful option for unifying your rendering. For details see Porting DirectX 12 games to Windows 7. For developers, this is supported through a NuGet package.

Debugging support and tooling in these scenarios is limited, so you should plan to do most of your development work on Windows 10.

Also be aware that the D3D12onWin7 solution does not support Windows 8.0 or Windows 8.1 per the specification. If you look at the numbers on hardware survey you’ll see why this was excluded.

XAudio 2

In my many blog posts about the retiring of the legacy DirectX SDK, one key area that keeps it alive is the fact that XAudio 2.7 was the last release to support Windows 7. This made it difficult for games to use XAudio 2.8/2.9 features built into the OS for Win32 desktop applications on later versions of Windows.

The great news here is that much like the DirectX 12 story, there is a version of XAudio 2.9 that supports Windows 7 SP1, Windows 8.0, Windows 8.1, and still takes advantage of the Windows 10 built-in version. See Microsoft Docs for all the details. The developer story utilizes a NuGet package as well.

The XAudio2 samples on GitHub have been updated to support using the new XAudio 2.9 REDIST version instead of the DirectX SDK.

HLSL

The D3DCompiler_47.dll in the Windows 10 SDK is compatible with Windows 7 and can be redistributed with your application. See HLSL, FXC, and D3DCompile.

The DXIL Shader Model 6 dxcompiler.dll from the Windows 10 (18362 or earlier) SDK is not compatible with Windows 7. The most recent release from GitHub does support being used on Windows 7.

UTF-8

Windows has long made use of Unicode for localization support, but this has been through wchar_t 16-bit wide characters. There are proponents that strongly suggest using UTF-8 instead since they are more portable, take less memory, etc. See the UTF-8 Everywhere manifesto for details and some recommended best practices for Windows development.

There’s been some good work to get the most recent versions of Windows 10 to better support UTF-8, but it will be a long time before you can just switch to using narrow-string Unicode to call the Win32 APIs.

You can and should use the manifesto practices on Windows 7 as well, but there’s one issue I’ve run into you should note. When you use MultiByteToWideChar with CP_UTF8, if you pass the flag MB_PRECOMPOSED it works fine with Windows 10. It will, however, fail on Windows 7. This is because officially the only valid flags are 0 or MB_ERR_INVALID_CHARS. Windows 10 ignores the commonly used MB_PRECOMPOSED flag for this case to simplify porting, but older systems don’t tolerate it.

Additional notes

  • The LOAD_LIBRARY_SEARCH_SYSTEM32 flag is a useful security feature when explicitly loading a system DLL. Keep in mind that it’s not supported on Windows 7 SP1 without KB2533623 installed.

  • With Windows 7 or later, Win32 desktop applications should include embedded manifests. See Manifest Madness.

  • If you are wanting to integrate with the Game Explorer, the most recent version of the GDFMaker tool can be found in Windows 10 SDK. You can find GDFTrace and GamesuxInstallHelper on GitHub.

Related: Windows Vista, Windows XP