From 7343c7110c38b3ce71d679222dccf438190865b0 Mon Sep 17 00:00:00 2001 From: Gangzheng Tong Date: Fri, 18 Jul 2025 17:23:06 -0700 Subject: Fix D3D12 test failure without Windows Developer mode (#7831) * Fix D3D12 test failure without Windows Developer mode Add Windows Developer mode detection for D3D12 experimental features. D3D12 Agility SDK requires Developer mode when using experimental features like D3D12ExperimentalShaderModels. Without this check, device creation fails silently. Changes: - Add isWindowsDeveloperModeEnabled() function to check registry - Add developer mode check before enabling experimental features - Provide clear error message with instructions to enable Developer mode - Return SLANG_E_NOT_AVAILABLE to gracefully fail tests Fixes #6819 Co-authored-by: Gangzheng Tong * Add more regkey checks to cover the developer mode detections in multile Windows versions --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gangzheng Tong --- tools/render-test/render-test-main.cpp | 124 +++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 71347e4f9..23035280c 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -15,6 +15,8 @@ #if defined(_WIN32) #include +#include +#pragma comment(lib, "advapi32") #endif #include @@ -30,6 +32,121 @@ #include #endif +#if defined(_WIN32) +// Check if Windows Developer mode is enabled +// Developer mode is required for D3D12 experimental features +static bool isWindowsDeveloperModeEnabled() +{ + // Helper function to check a specific registry key with detailed logging + auto checkRegistryKey = [](HKEY rootKey, + const char* rootName, + const char* path, + const char* valueName, + bool try32BitView = false) -> bool + { + HKEY key; + DWORD accessFlags = KEY_READ | (try32BitView ? KEY_WOW64_32KEY : KEY_WOW64_64KEY); + LONG ret = RegOpenKeyExA(rootKey, path, 0, accessFlags, &key); + + if (ret != ERROR_SUCCESS) + { + return false; + } + + DWORD value = 0; + DWORD size = sizeof(DWORD); + DWORD type = REG_DWORD; + + ret = RegQueryValueExA(key, valueName, nullptr, &type, (LPBYTE)&value, &size); + + RegCloseKey(key); + + if (ret != ERROR_SUCCESS || type != REG_DWORD) + { + return false; + } + + return value == 1; + }; + + // Method 1: Check multiple registry locations with different views + struct RegistryLocation + { + HKEY rootKey; + const char* rootName; + const char* path; + const char* valueName; + }; + + RegistryLocation locations[] = { + // Windows 10+ main location + {HKEY_LOCAL_MACHINE, + "HKLM", + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", + "AllowDevelopmentWithoutDevLicense"}, + + // Alternative user location + {HKEY_CURRENT_USER, + "HKCU", + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", + "AllowDevelopmentWithoutDevLicense"}, + + // Windows 11 alternative + {HKEY_LOCAL_MACHINE, + "HKLM", + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", + "AllowAllTrustedApps"}, + + // Policy location + {HKEY_LOCAL_MACHINE, + "HKLM", + "SOFTWARE\\Policies\\Microsoft\\Windows\\Appx", + "AllowDevelopmentWithoutDevLicense"}, + + // Additional alternative locations + {HKEY_CURRENT_USER, + "HKCU", + "SOFTWARE\\Policies\\Microsoft\\Windows\\Appx", + "AllowDevelopmentWithoutDevLicense"}, + }; + + for (const auto& location : locations) + { + // Try 64-bit view first + if (checkRegistryKey( + location.rootKey, + location.rootName, + location.path, + location.valueName, + false)) + { + return true; + } + + // Try 32-bit view as fallback + if (checkRegistryKey( + location.rootKey, + location.rootName, + location.path, + location.valueName, + true)) + { + return true; + } + } + + printf("*** Developer Mode NOT DETECTED ***\n"); + printf("To enable Developer Mode:\n"); + printf("1. Open Windows Settings (Windows key + I)\n"); + printf("2. Go to 'System' -> 'For developers'\n"); + printf("3. Turn on 'Developer Mode'\n"); + printf("4. Restart the application\n"); + printf("==========================================\n"); + + return false; +} +#endif + namespace renderer_test { @@ -1426,7 +1543,14 @@ static SlangResult _innerMain( experimentalFD.configurationStructSizes = nullptr; if (options.dx12Experimental) + { + // Check if Windows Developer mode is enabled + if (!isWindowsDeveloperModeEnabled()) + { + return SLANG_E_NOT_AVAILABLE; + } desc.next = &experimentalFD; + } #endif // Look for args going to slang -- cgit v1.2.3