From c6b9e598384563a641efdff56fdbdb0d7a561ec4 Mon Sep 17 00:00:00 2001
From: Oliver Wolff <oliver.wolff@theqtcompany.com>
Date: Thu, 10 Mar 2016 15:12:58 +0100
Subject: [PATCH] ANGLE: Fix compilation with MinGW

This adds definition guards for Direct3D 11 and DirectX SDK layers, which
are only available in very recent versions (4.9.2 rev 4) of MinGW builds.
It additionally adds a few missing includes needed for compilation.

Change-Id: I254c208209c0071fae5efb6727f2b3cfd5542da6
---
 src/3rdparty/angle/src/common/platform.h           | 10 ++-
 .../src/libANGLE/renderer/d3d/HLSLCompiler.cpp     |  9 +++
 .../src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp   |  6 ++
 .../src/libANGLE/renderer/d3d/d3d11/Clear11.cpp    |  4 +
 .../renderer/d3d/d3d11/DebugAnnotator11.cpp        | 10 +++
 .../libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h |  2 +
 .../libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp  |  2 +
 .../src/libANGLE/renderer/d3d/d3d11/Query11.cpp    | 14 ++++++++++++++
 .../src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 32 +++++++-
 .../src/libANGLE/renderer/d3d/d3d11/Renderer11.h   |  4 +
 .../libANGLE/renderer/d3d/d3d11/SwapChain11.cpp    | 10 +++
 .../src/libANGLE/renderer/d3d/d3d11/SwapChain11.h  |  2 +
 .../renderer/d3d/d3d11/renderer11_utils.cpp        | 92 ++++++++++++++++++++++
 .../renderer/d3d/d3d11/win32/NativeWindow.cpp      |  8 ++
 .../src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp   |  4 +-
 src/3rdparty/angle/src/libEGL/libEGL_mingw32.def   | 27 ++++---
 src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def  | 19 +++++
 .../angle/src/libGLESv2/libGLESv2_mingw32.def      | 32 +++++++-
 .../angle/src/libGLESv2/libGLESv2d_mingw32.def     | 32 +++++++-
 19 files changed, 296 insertions(+), 21 deletions(-)

diff --git a/src/3rdparty/angle/src/common/platform.h b/src/3rdparty/angle/src/common/platform.h
index 4e3851c..be4cb94 100644
--- a/src/3rdparty/angle/src/common/platform.h
+++ b/src/3rdparty/angle/src/common/platform.h
@@ -59,9 +59,18 @@
 #   if defined(ANGLE_ENABLE_D3D11)
 #       include <d3d10_1.h>
 #       include <d3d11.h>
-#       include <d3d11_1.h>
+#       include <d3d11_1.h>
 #       include <dxgi.h>
+#      if defined(__MINGW32__)
+#          define ANGLE_MINGW32_COMPAT
+#      endif
+#      if defined(_MSC_VER) && _MSC_VER >= 1800
+#          define ANGLE_ENABLE_D3D11_1
+#      endif
+#      if defined(ANGLE_ENABLE_D3D11_1)
+#       include <d3d11_1.h>
 #       include <dxgi1_2.h>
+#      endif
 #       include <d3dcompiler.h>
 #   endif
 
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
index 0d298bb..df0257e 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
@@ -25,6 +25,15 @@ namespace
 
 #define CREATE_COMPILER_FLAG_INFO(flag) { flag, #flag }
 
+#if defined(ANGLE_MINGW32_COMPAT)
+#ifndef D3DCOMPILE_RESERVED16
+#define D3DCOMPILE_RESERVED16 0x10000
+#endif
+#ifndef D3DCOMPILE_RESERVED17
+#define D3DCOMPILE_RESERVED17 0x20000
+#endif
+#endif
+
 struct CompilerFlagInfo
 {
     UINT mFlag;
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
index 03b28c2..cd95c65 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
@@ -262,7 +262,9 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
     RenderTarget11* maskedClearDepthStencil = nullptr;
 
     ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+#if defined(ANGLE_ENABLE_D3D11_1)
     ID3D11DeviceContext1 *deviceContext1 = mRenderer->getDeviceContext1IfSupported();
+#endif
     ID3D11Device *device = mRenderer->getDevice();
 
     for (size_t colorAttachmentIndex = 0; colorAttachmentIndex < colorAttachments.size();
@@ -347,6 +349,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
                     clearValues[3] = (clearParams.colorFClearValue.alpha >= 0.5f) ? 1.0f : 0.0f;
                 }
 
+#if defined(ANGLE_ENABLE_D3D11_1)
                 if (needScissoredClear)
                 {
                     // We shouldn't reach here if deviceContext1 is unavailable.
@@ -361,6 +364,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
                     deviceContext1->ClearView(framebufferRTV, clearValues, &rect, 1);
                 }
                 else
+#endif
                 {
                     deviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
                 }
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 2e42859..1c35ab4 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp
@@ -27,7 +27,9 @@ DebugAnnotator11::~DebugAnnotator11()
 {
     if (mInitialized)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
         SafeRelease(mUserDefinedAnnotation);
+#endif
 
 #if !defined(ANGLE_ENABLE_WINDOWS_STORE)
         FreeLibrary(mD3d11Module);
@@ -41,7 +43,9 @@ void DebugAnnotator11::beginEvent(const wchar_t *eventName)
 
     if (mUserDefinedAnnotation != nullptr)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
         mUserDefinedAnnotation->BeginEvent(eventName);
+#endif
     }
 }
 
@@ -51,7 +55,9 @@ void DebugAnnotator11::endEvent()
 
     if (mUserDefinedAnnotation != nullptr)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
         mUserDefinedAnnotation->EndEvent();
+#endif
     }
 }
 
@@ -61,7 +67,9 @@ void DebugAnnotator11::setMarker(const wchar_t *markerName)
 
     if (mUserDefinedAnnotation != nullptr)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
         mUserDefinedAnnotation->SetMarker(markerName);
+#endif
     }
 }
 
@@ -137,8 +145,10 @@ void DebugAnnotator11::initializeDevice()
         ASSERT(SUCCEEDED(hr));
         if (SUCCEEDED(hr))
         {
+#if defined(ANGLE_ENABLE_D3D11_1)
             mUserDefinedAnnotation = d3d11::DynamicCastComObject<ID3DUserDefinedAnnotation>(context);
             ASSERT(mUserDefinedAnnotation != nullptr);
+#endif
             mInitialized = true;
         }
 
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h
index 9da4fa2..d1a0f7f 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h
@@ -11,6 +11,8 @@
 
 #include "common/debug.h"
 
+struct ID3DUserDefinedAnnotation;
+
 namespace rx
 {
 
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp
index beffa30..186a035 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Framebuffer11.cpp
@@ -140,6 +140,7 @@ gl::Error Framebuffer11::discard(size_t count, const GLenum *attachments)
 
 gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments, bool useEXTBehavior) const
 {
+#if defined(ANGLE_ENABLE_D3D11_1)
     ID3D11DeviceContext1 *deviceContext1 = mRenderer->getDeviceContext1IfSupported();
 
     if (!deviceContext1)
@@ -272,6 +273,7 @@ gl::Error Framebuffer11::invalidateBase(size_t count, const GLenum *attachments,
             deviceContext1->DiscardView(stencilView);
         }
     }
+#endif // ANGLE_ENABLE_D3D11_1
 
     return gl::Error(GL_NO_ERROR);
 }
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 ea84783..62badcc 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,7 @@
 
 #include <EGL/eglext.h>
 #include <sstream>
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+#if !defined(ANGLE_MINGW32_COMPAT) && WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
 #include <VersionHelpers.h>
 #endif
 
@@ -89,6 +89,7 @@ enum
     MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16
 };
 
+#if defined(ANGLE_ENABLE_D3D11_1)
 void CalculateConstantBufferParams(GLintptr offset, GLsizeiptr size, UINT *outFirstConstant, UINT *outNumConstants)
 {
     // The offset must be aligned to 256 bytes (should have been enforced by glBindBufferRange).
@@ -105,6 +106,7 @@ void CalculateConstantBufferParams(GLintptr offset, GLsizeiptr size, UINT *outFi
     // This behaviour is explictly allowed according to the documentation on ID3D11DeviceContext1::PSSetConstantBuffers1
     // https://msdn.microsoft.com/en-us/library/windows/desktop/hh404649%28v=vs.85%29.aspx
 }
+#endif
 
 enum ANGLEFeatureLevel
 {
@@ -369,8 +371,10 @@ Renderer11::Renderer11(egl::Display *display)
     : RendererD3D(display),
       mStateCache(this),
       mStateManager(this),
-      mLastHistogramUpdateTime(ANGLEPlatformCurrent()->monotonicallyIncreasingTime()),
-      mDebug(nullptr)
+      mLastHistogramUpdateTime(ANGLEPlatformCurrent()->monotonicallyIncreasingTime())
+#if !defined(ANGLE_MINGW32_COMPAT)
+      ,mDebug(nullptr)
+#endif
 {
     mVertexDataManager = NULL;
     mIndexDataManager = NULL;
@@ -572,7 +576,9 @@ egl::Error Renderer11::initialize()
         // Cast the DeviceContext to a DeviceContext1.
         // This could fail on Windows 7 without the Platform Update.
         // Don't error in this case- just don't use mDeviceContext1.
+#if defined(ANGLE_ENABLE_D3D11_1)
         mDeviceContext1 = d3d11::DynamicCastComObject<ID3D11DeviceContext1>(mDeviceContext);
+#endif
 
         IDXGIDevice *dxgiDevice = NULL;
         result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
@@ -595,6 +601,7 @@ egl::Error Renderer11::initialize()
 
         SafeRelease(dxgiDevice);
 
+#if defined(ANGLE_ENABLE_D3D11_1)
         IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter);
 
         // On D3D_FEATURE_LEVEL_9_*, IDXGIAdapter::GetDesc returns "Software Adapter" for the description string.
@@ -618,11 +625,14 @@ egl::Error Renderer11::initialize()
             }
         }
         else
+#endif
         {
             result = mDxgiAdapter->GetDesc(&mAdapterDescription);
         }
 
+#if defined(ANGLE_ENABLE_D3D11_1)
         SafeRelease(dxgiAdapter2);
+#endif
 
         if (FAILED(result))
         {
@@ -644,6 +654,7 @@ egl::Error Renderer11::initialize()
         }
     }
 
+#if !defined(ANGLE_MINGW32_COMPAT)
     // Disable some spurious D3D11 debug warnings to prevent them from flooding the output log
 #if defined(ANGLE_SUPPRESS_D3D11_HAZARD_WARNINGS) && defined(_DEBUG)
     {
@@ -671,6 +682,7 @@ egl::Error Renderer11::initialize()
 #if !defined(NDEBUG)
     mDebug = d3d11::DynamicCastComObject<ID3D11Debug>(mDevice);
 #endif
+#endif // !ANGLE_MINGW32_COMPAT
 
     initializeDevice();
 
@@ -859,6 +871,7 @@ void Renderer11::populateRenderer11DeviceCaps()
 {
     HRESULT hr = S_OK;
 
+#if defined(ANGLE_ENABLE_D3D11_1)
     if (mDeviceContext1)
     {
         D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11Options;
@@ -869,6 +882,7 @@ void Renderer11::populateRenderer11DeviceCaps()
             mRenderer11DeviceCaps.supportsConstantBufferOffsets = (d3d11Options.ConstantBufferOffsetting != FALSE);
         }
     }
+#endif
 
     hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G6R5_UNORM, &(mRenderer11DeviceCaps.B5G6R5support));
     if (FAILED(hr))
@@ -888,9 +902,11 @@ void Renderer11::populateRenderer11DeviceCaps()
         mRenderer11DeviceCaps.B5G5R5A1support = 0;
     }
 
+#if defined(ANGLE_ENABLE_D3D11_1)
     IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter);
     mRenderer11DeviceCaps.supportsDXGI1_2 = (dxgiAdapter2 != nullptr);
     SafeRelease(dxgiAdapter2);
+#endif
 }
 
 egl::ConfigSet Renderer11::generateConfigs() const
@@ -1308,6 +1324,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::Data &data,
                 mCurrentConstantBufferVSOffset[uniformBufferIndex] != uniformBufferOffset ||
                 mCurrentConstantBufferVSSize[uniformBufferIndex] != uniformBufferSize)
             {
+#if defined(ANGLE_ENABLE_D3D11_1)
                 if (mRenderer11DeviceCaps.supportsConstantBufferOffsets && uniformBufferSize != 0)
                 {
                     UINT firstConstant = 0, numConstants = 0;
@@ -1318,6 +1335,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::Data &data,
                         1, &constantBuffer, &firstConstant, &numConstants);
                 }
                 else
+#endif
                 {
                     mDeviceContext->VSSetConstantBuffers(
                         getReservedVertexUniformBuffers() +
@@ -1369,6 +1387,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::Data &data,
                 mCurrentConstantBufferPSOffset[uniformBufferIndex] != uniformBufferOffset ||
                 mCurrentConstantBufferPSSize[uniformBufferIndex] != uniformBufferSize)
             {
+#if defined(ANGLE_ENABLE_D3D11_1)
                 if (mRenderer11DeviceCaps.supportsConstantBufferOffsets && uniformBufferSize != 0)
                 {
                     UINT firstConstant = 0, numConstants = 0;
@@ -1379,6 +1398,7 @@ gl::Error Renderer11::setUniformBuffers(const gl::Data &data,
                         1, &constantBuffer, &firstConstant, &numConstants);
                 }
                 else
+#endif
                 {
                     mDeviceContext->PSSetConstantBuffers(
                         getReservedFragmentUniformBuffers() +
@@ -2448,7 +2468,9 @@ void Renderer11::release()
     SafeRelease(mDxgiFactory);
     SafeRelease(mDxgiAdapter);
 
+#if defined(ANGLE_ENABLE_D3D11_1)
     SafeRelease(mDeviceContext1);
+#endif
 
     if (mDeviceContext)
     {
@@ -2458,7 +2480,9 @@ void Renderer11::release()
     }
 
     SafeRelease(mDevice);
+#if !defined(ANGLE_MINGW32_COMPAT)
     SafeRelease(mDebug);
+#endif
 
     if (mD3d11Module)
     {
@@ -2618,7 +2642,7 @@ bool Renderer11::getShareHandleSupport() const
 
     if (deviceType == d3d11::ANGLE_D3D11_DEVICE_TYPE_WARP)
     {
-#ifndef ANGLE_ENABLE_WINDOWS_STORE
+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) && !defined(__GNUC__)
         if (!IsWindows8OrGreater())
         {
             // WARP on Windows 7 doesn't support shared handles
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
index 62e9816..b4e7761 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
@@ -28,6 +28,8 @@ class FramebufferAttachment;
 struct ImageIndex;
 }
 
+struct ID3D11DeviceContext1;
+
 namespace rx
 {
 
@@ -442,7 +444,9 @@ class Renderer11 : public RendererD3D
     DXGI_ADAPTER_DESC mAdapterDescription;
     char mDescription[128];
     DXGIFactory *mDxgiFactory;
+#if !defined(ANGLE_MINGW32_COMPAT)
     ID3D11Debug *mDebug;
+#endif
 
     std::vector<GLuint> mScratchIndexDataBuffer;
 
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 f669f56..f80f24b 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
@@ -58,7 +58,9 @@ SwapChain11::SwapChain11(Renderer11 *renderer,
       mPassThroughResourcesInit(false),
       mFirstSwap(true),
       mSwapChain(nullptr),
+#if defined(ANGLE_ENABLE_D3D11_1)
       mSwapChain1(nullptr),
+#endif
       mKeyedMutex(nullptr),
       mBackBufferTexture(nullptr),
       mBackBufferRTView(nullptr),
@@ -90,7 +92,9 @@ SwapChain11::~SwapChain11()
 
 void SwapChain11::release()
 {
+#if defined(ANGLE_ENABLE_D3D11_1)
     SafeRelease(mSwapChain1);
+#endif
     SafeRelease(mSwapChain);
     SafeRelease(mKeyedMutex);
     SafeRelease(mBackBufferTexture);
@@ -533,7 +537,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
 
     // Release specific resources to free up memory for the new render target, while the
     // old render target still exists for the purpose of preserving its contents.
+#if defined(ANGLE_ENABLE_D3D11_1)
     SafeRelease(mSwapChain1);
+#endif
     SafeRelease(mSwapChain);
     SafeRelease(mBackBufferTexture);
     SafeRelease(mBackBufferRTView);
@@ -568,7 +574,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
 
         if (mRenderer->getRenderer11DeviceCaps().supportsDXGI1_2)
         {
+#if defined(ANGLE_ENABLE_D3D11_1)
             mSwapChain1 = d3d11::DynamicCastComObject<IDXGISwapChain1>(mSwapChain);
+#endif
         }
 
         result = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mBackBufferTexture);
@@ -837,6 +845,7 @@ EGLint SwapChain11::present(EGLint x, EGLint y, EGLint width, EGLint height)
 
     HRESULT result = S_OK;
 
+#if defined(ANGLE_ENABLE_D3D11_1)
     // Use IDXGISwapChain1::Present1 with a dirty rect if DXGI 1.2 is available.
     if (mSwapChain1 != nullptr)
     {
@@ -855,6 +864,7 @@ EGLint SwapChain11::present(EGLint x, EGLint y, EGLint width, EGLint height)
         }
     }
     else
+#endif
     {
         result = mSwapChain->Present(swapInterval, 0);
     }
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h
index 99198c6..adcd07a 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.h
@@ -75,7 +75,9 @@ class SwapChain11 : public SwapChainD3D
 
     bool mFirstSwap;
     DXGISwapChain *mSwapChain;
+#if defined(ANGLE_ENABLE_D3D11_1)
     IDXGISwapChain1 *mSwapChain1;
+#endif
     IDXGIKeyedMutex *mKeyedMutex;
 
     ID3D11Texture2D *mBackBufferTexture;
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
index d1f3ea0..a1175db 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp
@@ -23,6 +23,85 @@
 #include "libANGLE/renderer/d3d/FramebufferD3D.h"
 #include "libANGLE/renderer/d3d/WorkaroundsD3D.h"
 
+#ifndef D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
+#  define D3D_FL9_1_DEFAULT_MAX_ANISOTROPY 2
+#endif
+#ifndef D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT
+#  define D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT 1
+#endif
+#ifndef D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT
+#  define D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT 4
+#endif
+#ifndef D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT
+#  define D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT 65535
+#endif
+#ifndef D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT
+#  define D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT 1048575
+#endif
+#ifndef D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION
+#  define D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION 512
+#endif
+#ifndef D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION
+#  define D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION 4096
+#endif
+#ifndef D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION
+#  define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048
+#endif
+#ifndef D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
+#  define D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 256
+#endif
+#ifndef D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION
+#  define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096
+#endif
+#ifndef D3D11_REQ_TEXTURECUBE_DIMENSION
+#  define D3D11_REQ_TEXTURECUBE_DIMENSION 16384
+#endif
+#ifndef D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION
+#  define D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION 2048
+#endif
+#ifndef D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
+#  define D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 2048
+#endif
+#ifndef D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP
+#  define D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP 32
+#endif
+#ifndef D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP
+#  define D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP 32
+#endif
+#ifndef D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT
+#  define D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT 32
+#endif
+#ifndef D3D11_STANDARD_VERTEX_ELEMENT_COUNT
+#  define D3D11_STANDARD_VERTEX_ELEMENT_COUNT 32
+#endif
+#ifndef D3D10_1_SO_BUFFER_SLOT_COUNT
+#  define D3D10_1_SO_BUFFER_SLOT_COUNT 4
+#endif
+#ifndef D3D11_SO_BUFFER_SLOT_COUNT
+#  define D3D11_SO_BUFFER_SLOT_COUNT 4
+#endif
+#ifndef D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
+#  define D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT 14
+#endif
+#ifndef D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
+#  define D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT 16
+#endif
+#ifndef D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE
+#  define D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE -8
+#endif
+#ifndef D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE
+#  define D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE 7
+#endif
+#ifndef D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT
+#  define D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT 4096
+#endif
+#ifndef D3D11_PS_INPUT_REGISTER_COUNT
+#  define D3D11_PS_INPUT_REGISTER_COUNT 32
+#endif
+#ifndef D3D10_1_VS_OUTPUT_REGISTER_COUNT
+#  define D3D10_1_VS_OUTPUT_REGISTER_COUNT 32
+#endif
+
 namespace rx
 {
 
@@ -601,7 +683,9 @@ static size_t GetMaximumCubeMapTextureSize(D3D_FEATURE_LEVEL featureLevel)
 {
     switch (featureLevel)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
       case D3D_FEATURE_LEVEL_11_1:
+#endif
       case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURECUBE_DIMENSION;
 
       case D3D_FEATURE_LEVEL_10_1:
@@ -619,7 +703,9 @@ static size_t GetMaximum2DTextureArraySize(D3D_FEATURE_LEVEL featureLevel)
 {
     switch (featureLevel)
     {
+#if defined(ANGLE_ENABLE_D3D11_1)
       case D3D_FEATURE_LEVEL_11_1:
+#endif
       case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
 
       case D3D_FEATURE_LEVEL_10_1:
@@ -1266,7 +1352,9 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
 
     IDXGIDevice *dxgiDevice     = nullptr;
     IDXGIAdapter *dxgiAdapter   = nullptr;
+#if defined(ANGLE_ENABLE_D3D11_1)
     IDXGIAdapter2 *dxgiAdapter2 = nullptr;
+#endif
 
     ANGLED3D11DeviceType retDeviceType = ANGLE_D3D11_DEVICE_TYPE_UNKNOWN;
 
@@ -1277,6 +1365,7 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
         if (SUCCEEDED(hr))
         {
             std::wstring adapterString;
+#if defined(ANGLE_ENABLE_D3D11_1)
             HRESULT adapter2hr =
                 dxgiAdapter->QueryInterface(__uuidof(dxgiAdapter2), (void **)&dxgiAdapter2);
             if (SUCCEEDED(adapter2hr))
@@ -1289,6 +1378,7 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
                 adapterString = std::wstring(adapterDesc2.Description);
             }
             else
+#endif
             {
                 DXGI_ADAPTER_DESC adapterDesc;
                 dxgiAdapter->GetDesc(&adapterDesc);
@@ -1320,7 +1410,9 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
 
     SafeRelease(dxgiDevice);
     SafeRelease(dxgiAdapter);
+#if defined(ANGLE_ENABLE_D3D11_1)
     SafeRelease(dxgiAdapter2);
+#endif
 
     return retDeviceType;
 }
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
index 123b481..cd63789 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
@@ -12,7 +12,9 @@
 #include "common/debug.h"
 
 #include <initguid.h>
+#if !defined(__MINGW32__)
 #include <dcomp.h>
+#endif
 
 namespace rx
 {
@@ -31,9 +33,11 @@ NativeWindow::NativeWindow(EGLNativeWindowType window,
 
 NativeWindow::~NativeWindow()
 {
+#if !defined(__MINGW32__)
     SafeRelease(mCompositionTarget);
     SafeRelease(mDevice);
     SafeRelease(mVisual);
+#endif
 }
 
 bool NativeWindow::initialize()
@@ -66,6 +70,7 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
         return E_INVALIDARG;
     }
 
+#if !defined(__MINGW32__)
     if (mDirectComposition)
     {
         HMODULE dcomp = ::GetModuleHandle(TEXT("dcomp.dll"));
@@ -171,6 +176,7 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
         SafeRelease(factory2);
         return result;
     }
+#endif // !__MINGW32__
 
     DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
     swapChainDesc.BufferCount = 1;
@@ -202,9 +208,11 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
 
 void NativeWindow::commitChange()
 {
+#if !defined(__MINGW32__)
     if (mDevice)
     {
         mDevice->Commit();
     }
+#endif
 }
 }
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
index cba74c1..6bb975b 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
@@ -193,7 +193,7 @@ egl::Error Renderer9::initialize()
     {
         TRACE_EVENT0("gpu.angle", "D3d9Ex_QueryInterface");
         ASSERT(mD3d9Ex);
-        mD3d9Ex->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void**>(&mD3d9));
+        mD3d9Ex->QueryInterface(IID_IDirect3D9, reinterpret_cast<void**>(&mD3d9));
         ASSERT(mD3d9);
     }
     else
@@ -301,7 +301,7 @@ egl::Error Renderer9::initialize()
     if (mD3d9Ex)
     {
         TRACE_EVENT0("gpu.angle", "mDevice_QueryInterface");
-        result = mDevice->QueryInterface(__uuidof(IDirect3DDevice9Ex), (void**)&mDeviceEx);
+        result = mDevice->QueryInterface(IID_IDirect3DDevice9Ex, (void**)&mDeviceEx);
         ASSERT(SUCCEEDED(result));
     }
 
-- 
2.7.0.windows.1

