Add support for generating UWP (Windows Store) projects again

Until late 2017, ANGLE supported  Windows Store apps on Windows 8.1,
Windows Phone 8.1, and Windows 10 (via the Universal Windows
Platform, aka UWP).

Unfortunately ANGLE deprecated support for Windows Store when it
switched from GYP to GN in 2017. Since then, users have been able
to use Microsoft\angle for their UWP apps but this isn't ideal since
it's based on a 2017 copy of Google\angle.

This PR bring back support for UWPs, so that UWP users can use
Google\angle again. Specifically it:

- Adds support for generating UWP projects via GN
- Adds helper/util functions specific to UWP (they're mostly
similar to the desktop Windows helpers)
- Fixes some existing Windows Store code that's rotted since 2017
- Disables async shader compilation for UWPs, since its
implementation calls wait on the UI thread (which is forbidden
in UWPs)
- Renames 'ANGLE_ENABLE_WINDOWS_STORE' to
'ANGLE_ENABLE_WINDOWS_UWP', since ANGLE only support UWPs now
- Fixes misc other related issues (such as dependencies on D3D9
headers in API-agnostic code)

Note that this doesn't bring back support for Windows/Phone 8.1.

BUG=angleproject:3922

Change-Id: Ia79ae05a5e0e0a0625eb633bf1928722dfd3e85f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1811871
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 93fdc5e..cb44889 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -25,9 +25,13 @@
   # Defaults to capture building to $root_out_dir/angle_libs/with_capture.
   # Switch on to build capture to $root_out_dir.
   angle_with_capture_by_default = false
+
+  # Don't build extra (test, samples etc) for Windows UWP. We don't have
+  # infrastructure (e.g. windowing helper functions) in place to run them.
+  angle_build_all = !angle_is_winuwp
 }
 
-if (!build_with_chromium) {
+if (!build_with_chromium && angle_build_all) {
   group("all") {
     testonly = true
     deps = [
@@ -139,6 +143,10 @@
       "-Wshorten-64-to-32",
     ]
   }
+
+  if (angle_is_winuwp) {
+    cflags += [ "/wd4447" ]  # 'main' signature found without threading model.
+  }
 }
 
 # This config adds build-ids to the associated library.
@@ -222,7 +230,7 @@
   }
 }
 
-if (is_win) {
+if (is_win && !angle_is_winuwp) {
   angle_source_set("angle_stack_walker") {
     sources = [
       "util/windows/third_party/StackWalker/src/StackWalker.cpp",
@@ -338,7 +346,9 @@
 
   if (is_win) {
     sources += libangle_gpu_info_util_win_sources
-    libs += [ "setupapi.lib" ]
+    if (!angle_is_winuwp) {
+      libs += [ "setupapi.lib" ]
+    }
     libs += [ "dxgi.lib" ]
   }
 
@@ -622,7 +632,13 @@
 
   if (angle_enable_d3d11) {
     sources += libangle_d3d11_sources
-    sources += libangle_d3d11_win32_sources
+
+    if (angle_is_winuwp) {
+      sources += libangle_d3d11_winuwp_sources
+    } else {
+      sources += libangle_d3d11_win32_sources
+    }
+
     libs += [ "dxguid.lib" ]
     import("src/libANGLE/renderer/d3d/d3d11/d3d11_blit_shaders_autogen.gni")
     sources += libangle_d3d11_blit_shaders
@@ -852,7 +868,7 @@
   }
 }
 
-if (is_win) {
+if (is_win && !angle_is_winuwp) {
   angle_shared_library("libGL") {
     sources = libgl_sources
 
@@ -1006,7 +1022,7 @@
     "util/util_export.h",
   ]
 
-  if (is_win) {
+  if (is_win && !angle_is_winuwp) {
     sources += [ "util/windows/wgl_loader_autogen.h" ]
   }
 
@@ -1023,7 +1039,7 @@
     "util/gles_loader_autogen.cpp",
   ]
 
-  if (is_win) {
+  if (is_win && !angle_is_winuwp) {
     sources += [ "util/windows/wgl_loader_autogen.cpp" ]
   }
 
@@ -1069,7 +1085,7 @@
     public_deps = []
     libs = []
 
-    if (is_win) {
+    if (is_win && !angle_is_winuwp) {
       sources += util_win_sources
       deps += [ ":angle_stack_walker" ]
     }
@@ -1129,7 +1145,7 @@
     if (is_shared_library) {
       defines = [ "LIBANGLE_UTIL_IMPLEMENTATION" ]
 
-      if (is_win) {
+      if (is_win && !angle_is_winuwp) {
         sources += util_win_shared_sources
       }
 
diff --git a/doc/DevSetup.md b/doc/DevSetup.md
index c55439d..786381f 100644
--- a/doc/DevSetup.md
+++ b/doc/DevSetup.md
@@ -66,6 +66,8 @@
 ```
 For a release build run `gn args out/Release` and set `is_debug = false`.
 
+On Windows, you can build for the Universal Windows Platform (UWP) by setting `target_os = "winuwp"` in the args.
+
 For more information on GN run `gn help`.
 
 Ninja can be used to compile on all platforms with one of the following commands:
diff --git a/gni/angle.gni b/gni/angle.gni
index 1ba4132..bac5bd7 100644
--- a/gni/angle.gni
+++ b/gni/angle.gni
@@ -47,6 +47,9 @@
   }
   angle_shared_libvulkan = false
 
+  # There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves
+  angle_is_winuwp = is_win && current_os == "winuwp"
+
   # Default to using "_angle" suffix on Android
   if (is_android) {
     angle_libs_suffix = "_angle"
@@ -56,16 +59,18 @@
 }
 
 declare_args() {
-  angle_enable_d3d9 = is_win
+  angle_enable_d3d9 = is_win && !angle_is_winuwp
   angle_enable_d3d11 = is_win
-  angle_enable_gl = (ozone_platform_gbm || !is_linux ||
-                     (use_x11 && !is_chromeos)) && !is_fuchsia
+  angle_enable_gl =
+      (ozone_platform_gbm || !is_linux || (use_x11 && !is_chromeos)) &&
+      !is_fuchsia && !angle_is_winuwp
 
   # ANGLE Vulkan backend on Android requires API level 26, i.e. Oreo, due to
   # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
   # Otherwise, API level 24 would have been enough.
-  angle_enable_vulkan = is_win || (is_linux && use_x11 && !is_chromeos) ||
-                        (is_android && ndk_api_level_at_least_26) || is_fuchsia
+  angle_enable_vulkan =
+      (is_win && !angle_is_winuwp) || (is_linux && use_x11 && !is_chromeos) ||
+      (is_android && ndk_api_level_at_least_26) || is_fuchsia
   angle_enable_null = true
   angle_enable_essl = true
   angle_enable_glsl = true
diff --git a/src/common/platform.h b/src/common/platform.h
index 7ba97d1..3dd95e6 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -46,7 +46,7 @@
 #    include <windows.h>
 
 #    if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
-#        define ANGLE_ENABLE_WINDOWS_STORE 1
+#        define ANGLE_ENABLE_WINDOWS_UWP 1
 #    endif
 
 #    if defined(ANGLE_ENABLE_D3D9)
@@ -68,7 +68,7 @@
 #        include <wrl.h>
 #    endif
 
-#    if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#    if defined(ANGLE_ENABLE_WINDOWS_UWP)
 #        include <dxgi1_3.h>
 #        if defined(_DEBUG)
 #            include <DXProgrammableCapture.h>
diff --git a/src/common/system_utils_winuwp.cpp b/src/common/system_utils_winuwp.cpp
new file mode 100644
index 0000000..72d5509
--- /dev/null
+++ b/src/common/system_utils_winuwp.cpp
@@ -0,0 +1,120 @@
+//
+// Copyright 2019 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// system_utils_winuwp.cpp: Implementation of OS-specific functions for Windows UWP
+
+#include "system_utils.h"
+
+#include <stdarg.h>
+#include <windows.h>
+#include <array>
+#include <codecvt>
+#include <locale>
+#include <string>
+#include <vector>
+
+#include "common/debug.h"
+
+namespace angle
+{
+
+bool SetEnvironmentVar(const char *variableName, const char *value)
+{
+    // Not supported for UWP
+    return false;
+}
+
+std::string GetEnvironmentVar(const char *variableName)
+{
+    // Not supported for UWP
+    return "";
+}
+
+const char *GetSharedLibraryExtension()
+{
+    return "dll";
+}
+
+const char *GetPathSeparator()
+{
+    return ";";
+}
+
+double GetCurrentTime()
+{
+    LARGE_INTEGER frequency = {};
+    QueryPerformanceFrequency(&frequency);
+
+    LARGE_INTEGER curTime;
+    QueryPerformanceCounter(&curTime);
+
+    return static_cast<double>(curTime.QuadPart) / frequency.QuadPart;
+}
+
+class UwpLibrary : public Library
+{
+  public:
+    UwpLibrary(const char *libraryName, SearchType searchType)
+    {
+        char buffer[MAX_PATH];
+        int ret = snprintf(buffer, MAX_PATH, "%s.%s", libraryName, GetSharedLibraryExtension());
+
+        std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
+        std::wstring wideBuffer = converter.from_bytes(buffer);
+
+        if (ret > 0 && ret < MAX_PATH)
+        {
+            switch (searchType)
+            {
+                case SearchType::ApplicationDir:
+                    mModule = LoadPackagedLibrary(wideBuffer.c_str(), 0);
+                    break;
+                case SearchType::SystemDir:
+                    // Not supported in UWP
+                    break;
+            }
+        }
+    }
+
+    ~UwpLibrary() override
+    {
+        if (mModule)
+        {
+            FreeLibrary(mModule);
+        }
+    }
+
+    void *getSymbol(const char *symbolName) override
+    {
+        if (!mModule)
+        {
+            return nullptr;
+        }
+
+        return reinterpret_cast<void *>(GetProcAddress(mModule, symbolName));
+    }
+
+    void *getNative() const override { return reinterpret_cast<void *>(mModule); }
+
+  private:
+    HMODULE mModule = nullptr;
+};
+
+Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
+{
+    return new UwpLibrary(libraryName, searchType);
+}
+
+bool IsDebuggerAttached()
+{
+    return !!::IsDebuggerPresent();
+}
+
+void BreakDebugger()
+{
+    __debugbreak();
+}
+}  // namespace angle
diff --git a/src/common/tls.cpp b/src/common/tls.cpp
index 68c6ecf..9559afe 100644
--- a/src/common/tls.cpp
+++ b/src/common/tls.cpp
@@ -10,7 +10,7 @@
 
 #include <assert.h>
 
-#ifdef ANGLE_ENABLE_WINDOWS_STORE
+#ifdef ANGLE_ENABLE_WINDOWS_UWP
 #    include <map>
 #    include <mutex>
 #    include <set>
@@ -39,7 +39,7 @@
     TLSIndex index;
 
 #ifdef ANGLE_PLATFORM_WINDOWS
-#    ifdef ANGLE_ENABLE_WINDOWS_STORE
+#    ifdef ANGLE_ENABLE_WINDOWS_UWP
     if (!freeTlsIndices.empty())
     {
         DWORD result = freeTlsIndices.back();
@@ -76,7 +76,7 @@
     }
 
 #ifdef ANGLE_PLATFORM_WINDOWS
-#    ifdef ANGLE_ENABLE_WINDOWS_STORE
+#    ifdef ANGLE_ENABLE_WINDOWS_UWP
     assert(index < nextTlsIndex);
     assert(find(freeTlsIndices.begin(), freeTlsIndices.end(), index) == freeTlsIndices.end());
 
@@ -106,7 +106,7 @@
     }
 
 #ifdef ANGLE_PLATFORM_WINDOWS
-#    ifdef ANGLE_ENABLE_WINDOWS_STORE
+#    ifdef ANGLE_ENABLE_WINDOWS_UWP
     ThreadLocalData *threadData = currentThreadData;
     if (!threadData)
     {
@@ -138,7 +138,7 @@
     }
 
 #ifdef ANGLE_PLATFORM_WINDOWS
-#    ifdef ANGLE_ENABLE_WINDOWS_STORE
+#    ifdef ANGLE_ENABLE_WINDOWS_UWP
     ThreadLocalData *threadData = currentThreadData;
     if (threadData && threadData->size() > index)
     {
diff --git a/src/common/tls.h b/src/common/tls.h
index 641d66f..fbbe199 100644
--- a/src/common/tls.h
+++ b/src/common/tls.h
@@ -14,7 +14,7 @@
 #ifdef ANGLE_PLATFORM_WINDOWS
 
 // TLS does not exist for Windows Store and needs to be emulated
-#    ifdef ANGLE_ENABLE_WINDOWS_STORE
+#    ifdef ANGLE_ENABLE_WINDOWS_UWP
 #        ifndef TLS_OUT_OF_INDEXES
 #            define TLS_OUT_OF_INDEXES static_cast<DWORD>(0xFFFFFFFF)
 #        endif
diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp
index a3f0faa..b58444e 100644
--- a/src/common/utilities.cpp
+++ b/src/common/utilities.cpp
@@ -13,7 +13,7 @@
 
 #include <set>
 
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    include <windows.applicationmodel.core.h>
 #    include <windows.graphics.display.h>
 #    include <wrl.h>
@@ -1078,7 +1078,7 @@
 
 }  // namespace gl_egl
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
 std::string getTempPath()
 {
 #    ifdef ANGLE_PLATFORM_WINDOWS
@@ -1116,7 +1116,7 @@
     fwrite(content, sizeof(char), size, file);
     fclose(file);
 }
-#endif  // !ANGLE_ENABLE_WINDOWS_STORE
+#endif  // !ANGLE_ENABLE_WINDOWS_UWP
 
 #if defined(ANGLE_PLATFORM_WINDOWS)
 
diff --git a/src/common/utilities.h b/src/common/utilities.h
index a413a7e..e8df8fe 100644
--- a/src/common/utilities.h
+++ b/src/common/utilities.h
@@ -245,7 +245,7 @@
 EGLClientBuffer GLObjectHandleToEGLClientBuffer(GLuint handle);
 }  // namespace gl_egl
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
 std::string getTempPath();
 void writeFile(const char *path, const void *data, size_t size);
 #endif
diff --git a/src/gpu_info_util/SystemInfo_win.cpp b/src/gpu_info_util/SystemInfo_win.cpp
index 93d7265..f4bb137 100644
--- a/src/gpu_info_util/SystemInfo_win.cpp
+++ b/src/gpu_info_util/SystemInfo_win.cpp
@@ -14,7 +14,6 @@
 // Windows.h needs to be included first
 #include <windows.h>
 
-#include <d3d10.h>
 #include <dxgi.h>
 
 #include <array>
@@ -28,11 +27,20 @@
 
 bool GetDevicesFromDXGI(std::vector<GPUDeviceInfo> *devices)
 {
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
+    IDXGIFactory1 *factory;
+    if (!SUCCEEDED(
+            CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void **>(&factory))))
+    {
+        return false;
+    }
+#else
     IDXGIFactory *factory;
     if (!SUCCEEDED(CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void **>(&factory))))
     {
         return false;
     }
+#endif
 
     UINT i                = 0;
     IDXGIAdapter *adapter = nullptr;
@@ -42,7 +50,7 @@
         adapter->GetDesc(&desc);
 
         LARGE_INTEGER umdVersion;
-        if (adapter->CheckInterfaceSupport(__uuidof(ID3D10Device), &umdVersion) ==
+        if (adapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &umdVersion) ==
             DXGI_ERROR_UNSUPPORTED)
         {
             adapter->Release();
@@ -95,9 +103,11 @@
     // can override the heuristic to find the active GPU
     info->activeGPUIndex = 0;
 
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
     // Override isOptimus. nvd3d9wrap.dll is loaded into all processes when Optimus is enabled.
     HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll");
     info->isOptimus    = nvd3d9wrap != nullptr;
+#endif
 
     return true;
 }
diff --git a/src/libANGLE/Display.cpp b/src/libANGLE/Display.cpp
index ba8f982..edd04a5 100644
--- a/src/libANGLE/Display.cpp
+++ b/src/libANGLE/Display.cpp
@@ -1368,7 +1368,7 @@
         return true;
     }
 
-#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
     if (display == EGL_SOFTWARE_DISPLAY_ANGLE || display == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
         display == EGL_D3D11_ONLY_DISPLAY_ANGLE)
     {
diff --git a/src/libANGLE/features.h b/src/libANGLE/features.h
index 9459237..5a562da 100644
--- a/src/libANGLE/features.h
+++ b/src/libANGLE/features.h
@@ -53,8 +53,9 @@
 #endif
 
 // Controls if our threading code uses std::async or falls back to single-threaded operations.
-#if !defined(ANGLE_STD_ASYNC_WORKERS)
+// Note that we can't easily use std::async in UWPs due to UWP threading restrictions.
+#if !defined(ANGLE_STD_ASYNC_WORKERS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    define ANGLE_STD_ASYNC_WORKERS ANGLE_ENABLED
-#endif  // !defined(ANGLE_STD_ASYNC_WORKERS)
+#endif  // !defined(ANGLE_STD_ASYNC_WORKERS) && & !defined(ANGLE_ENABLE_WINDOWS_UWP)
 
 #endif  // LIBANGLE_FEATURES_H_
diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
index 811e193..aabe067 100644
--- a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
@@ -121,7 +121,7 @@
     }
 
     ANGLE_TRACE_EVENT0("gpu.angle", "HLSLCompiler::initialize");
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
     // Find a D3DCompiler module that had already been loaded based on a predefined list of
     // versions.
@@ -214,12 +214,12 @@
 {
     ASSERT(mInitialized);
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
     ASSERT(mD3DCompilerModule);
 #endif
     ASSERT(mD3DCompileFunc);
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE) && defined(ANGLE_ENABLE_DEBUG_TRACE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP) && defined(ANGLE_ENABLE_DEBUG_TRACE)
     std::string sourcePath = getTempPath();
     std::ostringstream stream;
     stream << "#line 2 \"" << sourcePath << "\"\n\n" << hlsl;
diff --git a/src/libANGLE/renderer/d3d/RendererD3D.cpp b/src/libANGLE/renderer/d3d/RendererD3D.cpp
index ba71982..00c57f0 100644
--- a/src/libANGLE/renderer/d3d/RendererD3D.cpp
+++ b/src/libANGLE/renderer/d3d/RendererD3D.cpp
@@ -240,7 +240,9 @@
 {
     switch (hr)
     {
+#ifdef ANGLE_ENABLE_D3D9
         case D3DERR_OUTOFVIDEOMEMORY:
+#endif
         case E_OUTOFMEMORY:
             return GL_OUT_OF_MEMORY;
         default:
diff --git a/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
index bf82a0c..e97e03f 100644
--- a/src/libANGLE/renderer/d3d/ShaderD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
@@ -252,7 +252,7 @@
 
     const std::string &source = mData.getSource();
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
     if (gl::DebugAnnotationsActive())
     {
         sourcePath = getTempPath();
diff --git a/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp b/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
index 3125043..0690118 100644
--- a/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
@@ -67,12 +67,14 @@
 
 void DebugAnnotator11::initialize(ID3D11DeviceContext *context)
 {
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
     // ID3DUserDefinedAnnotation.GetStatus only works on Windows10 or greater.
     // Returning true unconditionally from DebugAnnotator11::getStatus() means
     // writing out all compiled shaders to temporary files even if debugging
     // tools are not attached. See rx::ShaderD3D::prepareSourceAndReturnOptions.
     // If you want debug annotations, you must use Windows 10.
     if (IsWindows10OrGreater())
+#endif
     {
         mAnnotationThread = std::this_thread::get_id();
         mUserDefinedAnnotation.Attach(
diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
index 6bb17ac..57b1dbd 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -62,7 +62,7 @@
 #include "libANGLE/renderer/renderer_utils.h"
 #include "libANGLE/trace.h"
 
-#ifdef ANGLE_ENABLE_WINDOWS_STORE
+#ifdef ANGLE_ENABLE_WINDOWS_UWP
 #    include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h"
 #else
 #    include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h"
@@ -513,7 +513,7 @@
 
     ANGLE_TRY(initializeD3DDevice());
 
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    if !ANGLE_SKIP_DXGI_1_2_CHECK
     {
         ANGLE_TRACE_EVENT0("gpu.angle", "Renderer11::initialize (DXGICheck)");
@@ -674,7 +674,7 @@
 
     if (!mCreatedWithDeviceEXT)
     {
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
         PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = nullptr;
         {
             ANGLE_TRACE_EVENT0("gpu.angle", "Renderer11::initialize (Load DLLs)");
@@ -1140,11 +1140,13 @@
     // All D3D feature levels support robust resource init
     outExtensions->robustResourceInitialization = true;
 
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
     // Compositor Native Window capabilies require WinVer >= 1803
     if (CompositorNativeWindow11::IsSupportedWinRelease())
     {
         outExtensions->windowsUIComposition = true;
     }
+#endif
 }
 
 angle::Result Renderer11::flush(Context11 *context11)
@@ -1202,7 +1204,7 @@
     static_assert(sizeof(ABI::Windows::UI::Composition::SpriteVisual *) == sizeof(HWND),
                   "Pointer size must match Window Handle size");
 
-#ifdef ANGLE_ENABLE_WINDOWS_STORE
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
     return NativeWindow11WinRT::IsValidNativeWindow(window);
 #else
     if (NativeWindow11Win32::IsValidNativeWindow(window))
@@ -1218,6 +1220,9 @@
                                                 const egl::Config *config,
                                                 const egl::AttributeMap &attribs) const
 {
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
+    return new NativeWindow11WinRT(window, config->alphaSize > 0);
+#else
     auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window);
 
     if (useWinUiComp)
@@ -1226,15 +1231,11 @@
     }
     else
     {
-#ifdef ANGLE_ENABLE_WINDOWS_STORE
-        UNUSED_VARIABLE(attribs);
-        return new NativeWindow11WinRT(window, config->alphaSize > 0);
-#else
         return new NativeWindow11Win32(
             window, config->alphaSize > 0,
             attribs.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE) == EGL_TRUE);
-#endif
     }
+#endif
 }
 
 egl::Error Renderer11::getD3DTextureInfo(const egl::Config *configuration,
@@ -2109,14 +2110,14 @@
 
     if (deviceType == d3d11::ANGLE_D3D11_DEVICE_TYPE_WARP)
     {
-#ifndef ANGLE_ENABLE_WINDOWS_STORE
+#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
         if (!IsWindows8OrGreater())
         {
             // WARP on Windows 7 doesn't support shared handles
             mSupportsShareHandles = false;
             return false;
         }
-#endif  // ANGLE_ENABLE_WINDOWS_STORE
+#endif  // !defined(ANGLE_ENABLE_WINDOWS_UWP)
 
         // WARP on Windows 8.0+ supports shared handles when shared with another WARP device
         // TODO: allow applications to query for HARDWARE or WARP-specific share handles,
diff --git a/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp b/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp
index 5cf6af1..ac6d9a5 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Trim11.cpp
@@ -10,7 +10,7 @@
 #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
 
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    include <windows.applicationmodel.core.h>
 #    include <wrl.h>
 #    include <wrl/wrappers/corewrappers.h>
@@ -44,7 +44,7 @@
         return;
     }
 
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
     ID3D11Device *device      = mRenderer->getDevice();
     IDXGIDevice3 *dxgiDevice3 = d3d11::DynamicCastComObject<IDXGIDevice3>(device);
     if (dxgiDevice3)
@@ -57,7 +57,7 @@
 
 bool Trim11::registerForRendererTrimRequest()
 {
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
     ICoreApplication *coreApplication = nullptr;
     HRESULT result                    = GetActivationFactory(
         HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
@@ -84,7 +84,7 @@
 
 void Trim11::unregisterForRendererTrimRequest()
 {
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
     if (mApplicationSuspendedEventToken.value != 0)
     {
         ICoreApplication *coreApplication = nullptr;
diff --git a/src/libANGLE/renderer/d3d/d3d11/Trim11.h b/src/libANGLE/renderer/d3d/d3d11/Trim11.h
index 8c5cdb7..eb1f3e7 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Trim11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/Trim11.h
@@ -13,7 +13,7 @@
 #include "libANGLE/Error.h"
 #include "libANGLE/angletypes.h"
 
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
 #    include <EventToken.h>
 #endif
 
@@ -29,7 +29,7 @@
 
   private:
     Renderer11 *mRenderer;
-#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+#if defined(ANGLE_ENABLE_WINDOWS_UWP)
     EventRegistrationToken mApplicationSuspendedEventToken;
 #endif
 
diff --git a/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp b/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
index f04591d..d2c26fd 100644
--- a/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
@@ -1693,7 +1693,7 @@
     // D3D11 does not support vertex attribute aliasing
     limitations->noVertexAttributeAliasing = true;
 
-#ifdef ANGLE_ENABLE_WINDOWS_STORE
+#ifdef ANGLE_ENABLE_WINDOWS_UWP
     // Setting a non-zero divisor on attribute zero doesn't work on certain Windows Phone 8-era
     // devices. We should prevent developers from doing this on ALL Windows Store devices. This will
     // maintain consistency across all Windows devices. We allow non-zero divisors on attribute zero
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
index 8dc6076..82df5e9 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
@@ -49,11 +49,15 @@
     ComPtr<IMap<HSTRING, IInspectable *>> mPropertyMap;
 };
 
-[uuid(7F924F66 - EBAE - 40E5 - A10B - B8F35E245190)] class CoreWindowSizeChangedHandler
+// clang format would break the uuid below
+// clang-format off
+[uuid(7F924F66-EBAE-40E5-A10B-B8F35E245190)] class CoreWindowSizeChangedHandler
     : public Microsoft::WRL::RuntimeClass<
           Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
           IWindowSizeChangedEventHandler>
 {
+    // clang-format on
+
   public:
     CoreWindowSizeChangedHandler() {}
     HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
index d613fe0..7e85f93 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
@@ -88,8 +88,15 @@
                                              DXGI_FORMAT format,
                                              UINT width,
                                              UINT height,
+                                             UINT samples,
                                              IDXGISwapChain **swapChain)
 {
+    if (samples > 1)
+    {
+        // Multisample not implemented for WinRT window types
+        return E_NOTIMPL;
+    }
+
     if (mImpl)
     {
         IDXGIFactory2 *factory2     = d3d11::DynamicCastComObject<IDXGIFactory2>(factory);
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
index 85bfc26..d359a8b 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
@@ -34,6 +34,7 @@
                             DXGI_FORMAT format,
                             UINT width,
                             UINT height,
+                            UINT samples,
                             IDXGISwapChain **swapChain) override;
 
     void commitChange() override;
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
index 671dab0..75a901a 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
@@ -43,11 +43,15 @@
     ComPtr<IDXGISwapChain1> mSwapChain;
 };
 
-[uuid(8ACBD974 - 8187 - 4508 - AD80 - AEC77F93CF36)] class SwapChainPanelSizeChangedHandler
+// clang format would break the uuid below
+// clang-format off
+[uuid(8ACBD974-8187-4508-AD80-AEC77F93CF36)] class SwapChainPanelSizeChangedHandler
     : public Microsoft::WRL::RuntimeClass<
           Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
           ABI::Windows::UI::Xaml::ISizeChangedEventHandler>
 {
+    // clang-format on
+
   public:
     SwapChainPanelSizeChangedHandler() {}
     HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
diff --git a/src/libGLESv2.gni b/src/libGLESv2.gni
index ba759a2..be23152 100644
--- a/src/libGLESv2.gni
+++ b/src/libGLESv2.gni
@@ -88,7 +88,11 @@
 }
 
 if (is_win) {
-  angle_system_utils_sources += [ "src/common/system_utils_win.cpp" ]
+  if (current_os == "winuwp") {
+    angle_system_utils_sources += [ "src/common/system_utils_winuwp.cpp" ]
+  } else {
+    angle_system_utils_sources += [ "src/common/system_utils_win.cpp" ]
+  }
 }
 
 libangle_image_util_sources = [
@@ -669,7 +673,7 @@
   "src/third_party/systeminfo/SystemInfo.h",
 ]
 
-libangle_d3d11_winrt_sources = [
+libangle_d3d11_winuwp_sources = [
   "src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp",
   "src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h",
   "src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp",
diff --git a/util/util.gni b/util/util.gni
index 492c875..240ff48 100644
--- a/util/util.gni
+++ b/util/util.gni
@@ -37,7 +37,9 @@
   "util/windows/WGLWindow.h",
 ]
 
-util_win_shared_sources = [ "util/windows/WGLWindow.cpp" ]
+if (current_os != "winuwp") {
+  util_win_shared_sources = [ "util/windows/WGLWindow.cpp" ]
+}
 
 util_posix_sources = [
   "util/posix/Posix_crash_handler.cpp",
diff --git a/util/util_gl.h b/util/util_gl.h
index c044742..1c42875 100644
--- a/util/util_gl.h
+++ b/util/util_gl.h
@@ -13,9 +13,9 @@
 #if defined(ANGLE_USE_UTIL_LOADER)
 #    include "util/egl_loader_autogen.h"
 #    include "util/gles_loader_autogen.h"
-#    if defined(ANGLE_PLATFORM_WINDOWS)
+#    if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
 #        include "util/windows/wgl_loader_autogen.h"
-#    endif  // defined(ANGLE_PLATFORM_WINDOWS)
+#    endif  // defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
 #else
 
 #    if !defined(GL_GLES_PROTOTYPES)