vcpkg/ports/angle/001-fix-uwp.patch

263 lines
12 KiB
Diff
Raw Normal View History

diff --git a/src/libANGLE/renderer/d3d/RendererD3D.cpp b/src/libANGLE/renderer/d3d/RendererD3D.cpp
index fa46476..ad56164 100644
--- a/src/libANGLE/renderer/d3d/RendererD3D.cpp
+++ b/src/libANGLE/renderer/d3d/RendererD3D.cpp
@@ -240,7 +240,6 @@ GLenum DefaultGLErrorCode(HRESULT hr)
{
switch (hr)
{
- case D3DERR_OUTOFVIDEOMEMORY:
case E_OUTOFMEMORY:
return GL_OUT_OF_MEMORY;
default:
diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
index 62f263b..b8efe15 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -14,6 +14,7 @@
#include "common/tls.h"
#include "common/utilities.h"
+#include "common/debug.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
@@ -1142,9 +1143,11 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions
// Compositor Native Window capabilies require WinVer >= 1803
if (CompositorNativeWindow11::IsSupportedWinRelease())
- {
- outExtensions->windowsUIComposition = true;
- }
+ #ifdef ANGLE_ENABLE_WINDOWS_STORE
+ outExtensions->windowsUIComposition = NativeWindow11WinRT::IsSupportedWin10Release();
+ #else
+ outExtensions->windowsUIComposition = CompositorNativeWindow11::IsSupportedWinRelease();
+ #endif
}
angle::Result Renderer11::flush(Context11 *context11)
@@ -1218,16 +1221,23 @@ NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window,
const egl::Config *config,
const egl::AttributeMap &attribs) const
{
- auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window);
-
+#ifdef ANGLE_ENABLE_WINDOWS_STORE
+ auto useWinUiComp = window != nullptr && !NativeWindow11WinRT::IsValidNativeWindow(window);
+#else
+ auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window);
+#endif
if (useWinUiComp)
{
- return new CompositorNativeWindow11(window, config->alphaSize > 0);
+#ifdef ANGLE_ENABLE_WINDOWS_STORE
+ return new NativeWindow11WinRT(window, config->alphaSize > 0);
+#else
+ return new CompositorNativeWindow11(window, config->alphaSize > 0);
+#endif
}
else
{
#ifdef ANGLE_ENABLE_WINDOWS_STORE
- UNUSED_VARIABLE(attribs);
+ ANGLE_UNUSED_VARIABLE(attribs);
return new NativeWindow11WinRT(window, config->alphaSize > 0);
#else
return new NativeWindow11Win32(
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
index cb2f279..d76905c 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
@@ -145,6 +145,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
unsigned int width,
unsigned int height,
bool containsAlpha,
+ unsigned int samples,
IDXGISwapChain1 **swapChain)
{
if (device == nullptr || factory == nullptr || swapChain == nullptr || width == 0 ||
@@ -158,6 +159,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
swapChainDesc.Height = height;
swapChainDesc.Format = format;
swapChainDesc.Stereo = FALSE;
+ swapChainDesc.SampleDesc.Count = samples;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage =
@@ -213,11 +215,9 @@ HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWind
static float GetLogicalDpi()
{
- ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> displayProperties;
-
- if (SUCCEEDED(GetActivationFactory(
- HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(),
- displayProperties.GetAddressOf())))
+ ComPtr<ABI::Windows::Graphics::Display::IDisplayInformation> displayProperties;
+ if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
+ displayProperties.GetAddressOf())))
{
float dpi = 96.0f;
if (SUCCEEDED(displayProperties->get_LogicalDpi(&dpi)))
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
index ae57cfb..dd77b42 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
@@ -36,6 +36,7 @@ class CoreWindowNativeWindow : public InspectableNativeWindow,
unsigned int width,
unsigned int height,
bool containsAlpha,
+ unsigned int samples,
IDXGISwapChain1 **swapChain) override;
protected:
@@ -49,7 +50,7 @@ class CoreWindowNativeWindow : public InspectableNativeWindow,
ComPtr<IMap<HSTRING, IInspectable *>> mPropertyMap;
};
-[uuid(7F924F66 - EBAE - 40E5 - A10B - B8F35E245190)] class CoreWindowSizeChangedHandler
+[uuid(7F924F66-EBAE-40E5-A10B-B8F35E245190)] class CoreWindowSizeChangedHandler
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IWindowSizeChangedEventHandler>
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
index 708e8a2..9bfa4c4 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
@@ -53,6 +53,7 @@ class InspectableNativeWindow
unsigned int width,
unsigned int height,
bool containsAlpha,
+ unsigned int samples,
IDXGISwapChain1 **swapChain) = 0;
bool getClientRect(RECT *rect)
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
index 8972ca2..caf2a7e 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
@@ -13,6 +13,8 @@
#include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h"
#include "libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h"
+#include <windows.foundation.metadata.h>
+
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
@@ -88,6 +90,7 @@ HRESULT NativeWindow11WinRT::createSwapChain(ID3D11Device *device,
DXGI_FORMAT format,
UINT width,
UINT height,
+ UINT samples,
IDXGISwapChain **swapChain)
{
if (mImpl)
@@ -95,7 +98,7 @@ HRESULT NativeWindow11WinRT::createSwapChain(ID3D11Device *device,
IDXGIFactory2 *factory2 = d3d11::DynamicCastComObject<IDXGIFactory2>(factory);
IDXGISwapChain1 *swapChain1 = nullptr;
HRESULT result =
- mImpl->createSwapChain(device, factory2, format, width, height, mHasAlpha, &swapChain1);
+ mImpl->createSwapChain(device, factory2, format, width, height, mHasAlpha, samples, &swapChain1);
SafeRelease(factory2);
*swapChain = static_cast<IDXGISwapChain *>(swapChain1);
return result;
@@ -118,5 +121,44 @@ bool NativeWindow11WinRT::IsValidNativeWindow(EGLNativeWindowType window)
// Anything else will be rejected as an invalid IInspectable.
return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window);
}
+bool NativeWindow11WinRT::IsSupportedWin10Release()
+{
+ HSTRING className, contractName;
+ HSTRING_HEADER classNameHeader, contractNameHeader;
+ boolean isSupported = false;
+
+ const wchar_t *str = static_cast<const wchar_t *>(RuntimeClass_Windows_Foundation_Metadata_ApiInformation);
+ unsigned int length;
+ SizeTToUInt32(::wcslen(str), &length);
+ HRESULT hr = WindowsCreateStringReference(RuntimeClass_Windows_Foundation_Metadata_ApiInformation, length, &classNameHeader, &className);
+
+ if (FAILED(hr))
+ {
+ return isSupported;
+ }
+
+ Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Metadata::IApiInformationStatics> api;
+
+ hr = RoGetActivationFactory(className, __uuidof(ABI::Windows::Foundation::Metadata::IApiInformationStatics), &api);
+
+ if (FAILED(hr))
+ {
+ return isSupported;
+ }
+
+ str = static_cast<const wchar_t *>(L"Windows.Foundation.UniversalApiContract");
+ SizeTToUInt32(::wcslen(str), &length);
+ hr = WindowsCreateStringReference(L"Windows.Foundation.UniversalApiContract", length, &contractNameHeader,
+ &contractName);
+
+ if (FAILED(hr))
+ {
+ return isSupported;
+ }
+
+ api->IsApiContractPresentByMajor(contractName, 6, &isSupported);
+
+ return isSupported;
+}
} // namespace rx
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
index eac5b21..b9ee344 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
@@ -34,11 +34,14 @@ class NativeWindow11WinRT : public NativeWindow11
DXGI_FORMAT format,
UINT width,
UINT height,
+ UINT samples,
IDXGISwapChain **swapChain) override;
void commitChange() override;
static bool IsValidNativeWindow(EGLNativeWindowType window);
+ static bool IsSupportedWin10Release();
+
private:
bool mHasAlpha;
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
index af0beb6..20fd632 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
@@ -246,6 +246,7 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
+ unsigned int samples,
bool containsAlpha,
IDXGISwapChain1 **swapChain)
{
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
index 09642ee..fc69bf4 100644
--- a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
@@ -27,6 +27,7 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
+ unsigned int samples,
bool containsAlpha,
IDXGISwapChain1 **swapChain) override;
@@ -43,7 +44,7 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow,
ComPtr<IDXGISwapChain1> mSwapChain;
};
-[uuid(8ACBD974 - 8187 - 4508 - AD80 - AEC77F93CF36)] class SwapChainPanelSizeChangedHandler
+[uuid(8ACBD974-8187-4508-AD80-AEC77F93CF36)] class SwapChainPanelSizeChangedHandler
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
ABI::Windows::UI::Xaml::ISizeChangedEventHandler>