Improvements to D3D11 detection and error handling.

This commit is contained in:
Henrik Rydgard committed 2017-02-23 10:40:55 +01:00
1 parent 85ce4ac219
commit acde17e3ce
8 files changed
+98 -64

No files matched your search

+20 -38
View File
@@ -5,7 +5,7 @@
#include "OSVersion.h"
#include "Common/CommonWindows.h"
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor) {
bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool greater) {
uint64_t conditionMask = 0;
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
@@ -15,7 +15,7 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u
osvi.dwMinorVersion = minor;
osvi.wServicePackMajor = spMajor;
osvi.wServicePackMinor = spMinor;
uint32_t op = VER_EQUAL;
uint32_t op = greater ? VER_GREATER_EQUAL : VER_EQUAL;
VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, op);
VER_SET_CONDITION(conditionMask, VER_MINORVERSION, op);
@@ -28,43 +28,25 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u
}
std::string GetWindowsVersion() {
const bool IsWindowsXPSP2 = DoesVersionMatchWindows(5, 1, 2, 0);
const bool IsWindowsXPSP3 = DoesVersionMatchWindows(5, 1, 3, 0);
const bool IsWindowsVista = DoesVersionMatchWindows(6, 0);
const bool IsWindowsVistaSP1 = DoesVersionMatchWindows(6, 0, 1, 0);
const bool IsWindowsVistaSP2 = DoesVersionMatchWindows(6, 0, 2, 0);
const bool IsWindows7 = DoesVersionMatchWindows(6, 1);
const bool IsWindows7SP1 = DoesVersionMatchWindows(6, 1, 1, 0);
const bool IsWindows8 = DoesVersionMatchWindows(6, 2);
const bool IsWindows8_1 = DoesVersionMatchWindows(6, 3);
if (IsWindowsXPSP2)
return "Microsoft Windows XP, Service Pack 2";
if (IsWindowsXPSP3)
return "Microsoft Windows XP, Service Pack 3";
if (IsWindowsVista)
return "Microsoft Windows Vista";
if (IsWindowsVistaSP1)
return "Microsoft Windows Vista, Service Pack 1";
if (IsWindowsVistaSP2)
return "Microsoft Windows Vista, Service Pack 2";
if (IsWindows7)
return "Microsoft Windows 7";
if (IsWindows7SP1)
return "Microsoft Windows 7, Service Pack 1";
if (IsWindows8)
return "Microsoft Windows 8 or greater"; // "Applications not manifested for Windows 10 will return the Windows 8 OS version value (6.2)."
if (IsWindows8_1)
return "Microsoft Windows 8.1";
const bool IsWindowsXPSP2 = DoesVersionMatchWindows(5, 1, 2, 0, false);
const bool IsWindowsXPSP3 = DoesVersionMatchWindows(5, 1, 3, 0, false);
const bool IsWindowsVista = DoesVersionMatchWindows(6, 0, 0, 0, false);
const bool IsWindowsVistaSP1 = DoesVersionMatchWindows(6, 0, 1, 0, false);
const bool IsWindowsVistaSP2 = DoesVersionMatchWindows(6, 0, 2, 0, false);
const bool IsWindows7 = DoesVersionMatchWindows(6, 1, 0, 0, false);
const bool IsWindows7SP1 = DoesVersionMatchWindows(6, 1, 1, 0, false);
const bool IsWindows8 = DoesVersionMatchWindows(6, 2, 0, 0, false);
const bool IsWindows8_1 = DoesVersionMatchWindows(6, 3, 0, 0, false);
if (IsWindowsXPSP2) return "Microsoft Windows XP, Service Pack 2";
if (IsWindowsXPSP3) return "Microsoft Windows XP, Service Pack 3";
if (IsWindowsVista) return "Microsoft Windows Vista";
if (IsWindowsVistaSP1) return "Microsoft Windows Vista, Service Pack 1";
if (IsWindowsVistaSP2) return "Microsoft Windows Vista, Service Pack 2";
if (IsWindows7) return "Microsoft Windows 7";
if (IsWindows7SP1) return "Microsoft Windows 7, Service Pack 1";
if (IsWindows8) return "Microsoft Windows 8 or greater"; // "Applications not manifested for Windows 10 will return the Windows 8 OS version value (6.2)."
if (IsWindows8_1) return "Microsoft Windows 8.1";
return "Unsupported version of Microsoft Windows.";
}