From bbc3a5f89821030dd2772cd8015070a3da9ad57e Mon Sep 17 00:00:00 2001
From: Oliver Wolff <oliver.wolff@theqtcompany.com>
Date: Mon, 29 Feb 2016 11:09:24 +0100
Subject: [PATCH 1/7] ANGLE: Improve Windows Phone Support

This contains compile fixes for Windows Phone as well as improved
orientation handling.

Change-Id: I5011e9980957ff0797db179b36c3be9cac6df497
---
 src/3rdparty/angle/src/common/platform.h           |  2 ++
 .../renderer/d3d/d3d11/DebugAnnotator11.cpp        |  2 +-
 .../src/libANGLE/renderer/d3d/d3d11/NativeWindow.h |  4 +++
 .../src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp |  8 ++++-
 .../libANGLE/renderer/d3d/d3d11/SwapChain11.cpp    | 40 ++++++++++++++++++++++
 .../d3d/d3d11/winrt/CoreWindowNativeWindow.cpp     | 33 ++++++++++++++++--
 .../d3d/d3d11/winrt/CoreWindowNativeWindow.h       | 35 ++++++++++++++++++-
 .../d3d/d3d11/winrt/InspectableNativeWindow.cpp    | 12 +++++++
 .../d3d/d3d11/winrt/InspectableNativeWindow.h      | 14 +++++++-
 src/3rdparty/angle/src/libANGLE/validationEGL.cpp  |  4 ++-
 .../src/third_party/systeminfo/SystemInfo.cpp      |  4 +--
 11 files changed, 148 insertions(+), 10 deletions(-)

diff --git a/src/3rdparty/angle/src/common/platform.h b/src/3rdparty/angle/src/common/platform.h
index 56db297..4e3851c 100644
--- a/src/3rdparty/angle/src/common/platform.h
+++ b/src/3rdparty/angle/src/common/platform.h
@@ -68,7 +68,9 @@
 #   if defined(ANGLE_ENABLE_WINDOWS_STORE)
 #       include <dxgi1_3.h>
 #       if defined(_DEBUG)
+#          if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
 #           include <DXProgrammableCapture.h>
+#          endif
 #           include <dxgidebug.h>
 #       endif
 #   endif
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
index f9d28e8..2e42859 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
@@ -77,7 +77,7 @@ bool DebugAnnotator11::getStatus()
     }
 
     return true;  // Default if initializeDevice() failed
-#elif defined(_DEBUG)
+#elif defined(_DEBUG) && (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
     static bool underCapture = true;
 
     // ID3DUserDefinedAnnotation::GetStatus doesn't work with the Graphics Diagnostics tools in
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
index f28ce4f..1c94538 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
@@ -54,6 +54,7 @@ namespace rx
 class NativeWindow
 {
   public:
+    enum RotationFlags { RotateNone = 0, RotateLeft = 1, RotateRight = 2 };
     explicit NativeWindow(EGLNativeWindowType window,
                           const egl::Config *config,
                           bool directComposition);
@@ -62,6 +63,9 @@ class NativeWindow
     bool initialize();
     bool getClientRect(LPRECT rect);
     bool isIconic();
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+    RotationFlags rotationFlags() const;
+#endif
     static bool isValidNativeWindow(EGLNativeWindowType window);
 
     HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
index f7757df..03159bb 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -10,7 +10,9 @@
 
 #include <EGL/eglext.h>
 #include <sstream>
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
 #include <VersionHelpers.h>
+#endif
 
 #include "common/tls.h"
 #include "common/utilities.h"
@@ -445,7 +447,11 @@ Renderer11::Renderer11(egl::Display *display)
             }
         }
 
+#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+        if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 9)
+#else
         if (requestedMajorVersion == 9 && requestedMinorVersion == 3)
+#endif
         {
             mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_9_3);
         }
@@ -946,12 +952,12 @@ egl::ConfigSet Renderer11::generateConfigs() const
             config.bindToTextureRGBA = (colorBufferFormatInfo.format == GL_RGBA ||
                                         colorBufferFormatInfo.format == GL_BGRA_EXT);
             config.colorBufferType = EGL_RGB_BUFFER;
-            config.configCaveat    = EGL_NONE;
             config.configID        = static_cast<EGLint>(configs.size() + 1);
             // Can only support a conformant ES2 with feature level greater than 10.0.
             config.conformant = (mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0)
                                     ? (EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR)
                                     : 0;
+            config.configCaveat = config.conformant == EGL_NONE ? EGL_NON_CONFORMANT_CONFIG : EGL_NONE;
 
             // PresentPathFast may not be conformant
             if (mPresentPathFastEnabled)
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
index a56d3fa..9432a7f 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
@@ -222,8 +222,14 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
         const bool useSharedResource = !mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport();
 
         D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+        const int textureLength = std::max(backbufferWidth, backbufferHeight);
+        offscreenTextureDesc.Width = textureLength;
+        offscreenTextureDesc.Height = textureLength;
+#else
         offscreenTextureDesc.Width = backbufferWidth;
         offscreenTextureDesc.Height = backbufferHeight;
+#endif
         offscreenTextureDesc.Format = backbufferFormatInfo.texFormat;
         offscreenTextureDesc.MipLevels = 1;
         offscreenTextureDesc.ArraySize = 1;
@@ -336,8 +342,14 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
             d3d11::GetTextureFormatInfo(mDepthBufferFormat, mRenderer->getRenderer11DeviceCaps());
 
         D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+        const int textureLength = std::max(backbufferWidth, backbufferHeight);
+        depthStencilTextureDesc.Width = textureLength;
+        depthStencilTextureDesc.Height = textureLength;
+#else
         depthStencilTextureDesc.Width = backbufferWidth;
         depthStencilTextureDesc.Height = backbufferHeight;
+#endif
         depthStencilTextureDesc.Format = depthBufferFormatInfo.texFormat;
         depthStencilTextureDesc.MipLevels = 1;
         depthStencilTextureDesc.ArraySize = 1;
@@ -422,6 +434,7 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
         return EGL_SUCCESS;
     }
 
+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
     // Can only call resize if we have already created our swap buffer and resources
     ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView && mBackBufferSRView);
 
@@ -479,6 +492,12 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
     mFirstSwap = true;
 
     return resetOffscreenBuffers(backbufferWidth, backbufferHeight);
+#else
+    // Do nothing on Windows Phone apart from updating the internal buffer/width height
+    mWidth = backbufferWidth;
+    mHeight = backbufferHeight;
+    return EGL_SUCCESS;
+#endif
 }
 
 DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const
@@ -704,6 +723,21 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(EGLint x, EGLint y, EGLint width,
     float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
     float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
 
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+    const float dim = std::max(mWidth, mHeight);
+    float u1 = x / dim;
+    float v1 = y / dim;
+    float u2 = (x + width) / dim;
+    float v2 = (y + height) / dim;
+
+    const NativeWindow::RotationFlags flags = mNativeWindow.rotationFlags();
+    const bool rotateL = flags == NativeWindow::RotateLeft;
+    const bool rotateR = flags == NativeWindow::RotateRight;
+    d3d11::SetPositionTexCoordVertex(&vertices[0], x1, y1, rotateL ? u2 : u1, rotateR ? v2 : v1);
+    d3d11::SetPositionTexCoordVertex(&vertices[1], x1, y2, rotateR ? u2 : u1, rotateL ? v1 : v2);
+    d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, rotateR ? u1 : u2, rotateL ? v2 : v1);
+    d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, rotateL ? u1 : u2, rotateR ? v1 : v2);
+#else
     float u1 = x / float(mWidth);
     float v1 = y / float(mHeight);
     float u2 = (x + width) / float(mWidth);
@@ -723,6 +757,7 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(EGLint x, EGLint y, EGLint width,
     d3d11::SetPositionTexCoordVertex(&vertices[1], x1, y2, u1, v2);
     d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, u2, v1);
     d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, u2, v2);
+#endif
 
     deviceContext->Unmap(mQuadVB, 0);
 
@@ -752,8 +787,13 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(EGLint x, EGLint y, EGLint width,
     D3D11_VIEWPORT viewport;
     viewport.TopLeftX = 0;
     viewport.TopLeftY = 0;
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+    viewport.Width = (rotateL || rotateR) ? mHeight : mWidth;
+    viewport.Height = (rotateL || rotateR) ? mWidth : mHeight;
+#else
     viewport.Width = static_cast<FLOAT>(mWidth);
     viewport.Height = static_cast<FLOAT>(mHeight);
+#endif
     viewport.MinDepth = 0.0f;
     viewport.MaxDepth = 1.0f;
     deviceContext->RSSetViewports(1, &viewport);
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
index 71f0e42..6a4795a 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
@@ -8,8 +8,6 @@
 
 #include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h"
 
-#include <windows.graphics.display.h>
-
 using namespace ABI::Windows::Foundation::Collections;
 
 namespace rx
@@ -21,6 +19,7 @@ CoreWindowNativeWindow::~CoreWindowNativeWindow()
 
 bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet *propertySet)
 {
+    mOrientationChangedEventToken.value = 0;
     ComPtr<IPropertySet> props = propertySet;
     ComPtr<IInspectable> win = window;
     SIZE swapChainSize = {};
@@ -100,6 +99,16 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
 
     if (SUCCEEDED(result))
     {
+        ComPtr<ABI::Windows::Graphics::Display::IDisplayInformationStatics> displayInformation;
+        result = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(), &displayInformation);
+        if (SUCCEEDED(result))
+        {
+            result = displayInformation->GetForCurrentView(&mDisplayInformation);
+        }
+    }
+
+    if (SUCCEEDED(result))
+    {
         mNewClientRect = mClientRect;
         mClientRectChanged = false;
         return registerForSizeChangeEvents();
@@ -117,6 +126,15 @@ bool CoreWindowNativeWindow::registerForSizeChangeEvents()
         result = mCoreWindow->add_SizeChanged(sizeChangedHandler.Get(), &mSizeChangedEventToken);
     }
 
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+    ComPtr<IDisplayOrientationEventHandler> orientationChangedHandler;
+    result = sizeChangedHandler.As(&orientationChangedHandler);
+    if (SUCCEEDED(result))
+    {
+        result = mDisplayInformation->add_OrientationChanged(orientationChangedHandler.Get(), &mOrientationChangedEventToken);
+    }
+#endif
+
     if (SUCCEEDED(result))
     {
         return true;
@@ -131,7 +149,16 @@ void CoreWindowNativeWindow::unregisterForSizeChangeEvents()
     {
         (void)mCoreWindow->remove_SizeChanged(mSizeChangedEventToken);
     }
+
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+    if (mDisplayInformation)
+    {
+        (void)mDisplayInformation->remove_OrientationChanged(mOrientationChangedEventToken);
+    }
+#endif
+
     mSizeChangedEventToken.value = 0;
+    mOrientationChangedEventToken.value = 0;
 }
 
 HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
@@ -168,7 +195,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
     if (SUCCEEDED(result))
     {
 
-#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+#if 0 //(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) // Qt: allow Windows Phone to resize, but don't modify the backing texture in the swap chain.
         // Test if swapchain supports resize.  On Windows Phone devices, this will return DXGI_ERROR_UNSUPPORTED.  On
         // other devices DXGI_ERROR_INVALID_CALL should be returned because the combination of flags passed
         // (DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE) are invalid flag combinations.
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
index 7747005..4de235a 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
@@ -12,8 +12,10 @@
 #include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h"
 
 #include <memory>
+#include <windows.graphics.display.h>
 
 typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler;
+typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_t IDisplayOrientationEventHandler;
 
 namespace rx
 {
@@ -42,11 +44,13 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl
   private:
     ComPtr<ABI::Windows::UI::Core::ICoreWindow> mCoreWindow;
     ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
+    ComPtr<ABI::Windows::Graphics::Display::IDisplayInformation> mDisplayInformation;
+    EventRegistrationToken mOrientationChangedEventToken;
 };
 
 [uuid(7F924F66-EBAE-40E5-A10B-B8F35E245190)]
 class CoreWindowSizeChangedHandler :
-    public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWindowSizeChangedEventHandler>
+    public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWindowSizeChangedEventHandler, IDisplayOrientationEventHandler>
 {
   public:
     CoreWindowSizeChangedHandler() { }
@@ -78,6 +82,35 @@ class CoreWindowSizeChangedHandler :
         return S_OK;
     }
 
+        IFACEMETHOD(Invoke)(ABI::Windows::Graphics::Display::IDisplayInformation *displayInformation, IInspectable *)
+        {
+    #if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+            NativeWindow::RotationFlags flags = NativeWindow::RotateNone;
+            ABI::Windows::Graphics::Display::DisplayOrientations orientation;
+            if (SUCCEEDED(displayInformation->get_CurrentOrientation(&orientation)))
+            {
+                switch (orientation)
+                {
+                  case ABI::Windows::Graphics::Display::DisplayOrientations_Landscape:
+                    flags = NativeWindow::RotateLeft;
+                    break;
+                  case ABI::Windows::Graphics::Display::DisplayOrientations_LandscapeFlipped:
+                    flags = NativeWindow::RotateRight;
+                    break;
+                  default:
+                    break;
+                }
+            }
+            std::shared_ptr<InspectableNativeWindow> host = mHost.lock();
+            if (host)
+            {
+                host->setRotationFlags(flags);
+            }
+    #endif
+            return S_OK;
+        }
+
+
   private:
     std::weak_ptr<InspectableNativeWindow> mHost;
 };
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
index 47a6dae..c9b203e 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
@@ -80,6 +80,18 @@ bool NativeWindow::getClientRect(RECT *rect)
     return false;
 }
 
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+NativeWindow::RotationFlags NativeWindow::rotationFlags() const
+{
+    if (mImpl)
+    {
+        return mImpl->rotationFlags();
+    }
+
+    return NativeWindow::RotateNone;
+}
+#endif
+
 bool NativeWindow::isIconic()
 {
     return false;
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
index 4b9cf80..70e5fe7 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
@@ -36,7 +36,8 @@ class InspectableNativeWindow
         mSwapChainScale(1.0f),
         mClientRectChanged(false),
         mClientRect({0,0,0,0}),
-        mNewClientRect({0,0,0,0})
+        mNewClientRect({0,0,0,0}),
+        mRotationFlags(NativeWindow::RotateNone)
     {
         mSizeChangedEventToken.value = 0;
     }
@@ -94,6 +95,16 @@ class InspectableNativeWindow
         }
     }
 
+    NativeWindow::RotationFlags rotationFlags() const
+    {
+        return mRotationFlags;
+    }
+
+    void setRotationFlags(NativeWindow::RotationFlags flags)
+    {
+        mRotationFlags = flags;
+    }
+
   protected:
     virtual HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) = 0;
 
@@ -104,6 +115,7 @@ class InspectableNativeWindow
     RECT mClientRect;
     RECT mNewClientRect;
     bool mClientRectChanged;
+    NativeWindow::RotationFlags mRotationFlags;
 
     EventRegistrationToken mSizeChangedEventToken;
 };
diff --git a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp
index bff3c94..972f6a7 100644
--- a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp
+++ b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp
@@ -269,7 +269,7 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context
         return Error(EGL_BAD_CONFIG);
     }
 
-    if (clientMajorVersion == 3 && !(configuration->conformant & EGL_OPENGL_ES3_BIT_KHR))
+    if (clientMajorVersion == 3 && !(configuration->conformant & EGL_OPENGL_ES3_BIT_KHR) && !(configuration->configCaveat & EGL_NON_CONFORMANT_CONFIG))
     {
         return Error(EGL_BAD_CONFIG);
     }
@@ -496,6 +496,7 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri
         return Error(EGL_BAD_MATCH);
     }
 
+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) // On Windows Store, we know the originating texture came from D3D11, so bypass this check
     const Caps &caps = display->getCaps();
 
     EGLenum textureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
@@ -519,6 +520,7 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri
     {
         return Error(EGL_BAD_MATCH);
     }
+#endif
 
     return Error(EGL_SUCCESS);
 }
diff --git a/src/3rdparty/angle/src/third_party/systeminfo/SystemInfo.cpp b/src/3rdparty/angle/src/third_party/systeminfo/SystemInfo.cpp
index 97dfcaa..e082895 100644
--- a/src/3rdparty/angle/src/third_party/systeminfo/SystemInfo.cpp
+++ b/src/3rdparty/angle/src/third_party/systeminfo/SystemInfo.cpp
@@ -26,7 +26,7 @@
 #include <windows.h>
 #include "common/platform.h"
 
-#if _WIN32_WINNT_WINBLUE
+#if _WIN32_WINNT_WINBLUE && WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
 #include <versionhelpers.h>
 #endif
 
-- 
2.7.0.windows.1

