summaryrefslogtreecommitdiffstats
path: root/src/angle/patches/0013-ANGLE-Add-support-for-querying-platform-device.patch
blob: 00e32186f00dd3d03e50aa935aab6af13bf57f8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
From 3499339ab768017458d3b5295af3742a0f6015db Mon Sep 17 00:00:00 2001
From: Andrew Knight <andrew.knight@digia.com>
Date: Mon, 22 Sep 2014 23:15:26 +0300
Subject: [PATCH 13/16] ANGLE: Add support for querying platform device

The EGL_EXT_device_base extension allows for querying the platform
device of the graphics hardware via eglQueryDisplayAttribEXT().
As that extension is not supported by ANGLE, this patch adds similar
functionality to the existing eglQuerySurfacePointerANGLE API. When
EGL_DEVICE_EXT is passed as the queried attribute, the underlying
D3D/DXGI device pointer is passed back to the caller via the value
argument.

The D3D device is needed for video support in QtMultimedia as well as
the IDXGIDevice3::Trim() calls required by the Windows Store.

Change-Id: Ibdf228d81d6604e56db9dd8597d7cd2983ebc428
---
 src/3rdparty/angle/src/libEGL/libEGL.cpp | 47 +++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/src/3rdparty/angle/src/libEGL/libEGL.cpp b/src/3rdparty/angle/src/libEGL/libEGL.cpp
index 7ea11c5..c2e0fd6 100644
--- a/src/3rdparty/angle/src/libEGL/libEGL.cpp
+++ b/src/3rdparty/angle/src/libEGL/libEGL.cpp
@@ -18,6 +18,9 @@
 #include "libGLESv2/Texture.h"
 #include "libGLESv2/main.h"
 #include "libGLESv2/renderer/SwapChain.h"
+#if defined(ANGLE_ENABLE_D3D11)
+#  include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
+#endif
 
 #include "libEGL/main.h"
 #include "libEGL/Display.h"
@@ -484,24 +487,48 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf
     egl::Display *display = static_cast<egl::Display*>(dpy);
     egl::Surface *eglSurface = (egl::Surface*)surface;
 
-    if (!validateSurface(display, eglSurface))
-    {
-        return EGL_FALSE;
-    }
-
-    if (surface == EGL_NO_SURFACE)
-    {
-        return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
-    }
-
     switch (attribute)
     {
       case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
         {
+            if (!validateSurface(display, eglSurface))
+            {
+                return EGL_FALSE;
+            }
+
+            if (surface == EGL_NO_SURFACE)
+            {
+                return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
+            }
+
             rx::SwapChain *swapchain = eglSurface->getSwapChain();
             *value = (void*) (swapchain ? swapchain->getShareHandle() : NULL);
         }
         break;
+#if defined(ANGLE_ENABLE_D3D11)
+      case EGL_DEVICE_EXT:
+        {
+            if (!validateDisplay(display))
+            {
+                return EGL_FALSE;
+            }
+
+            rx::Renderer *renderer = display->getRenderer();
+            if (!renderer)
+            {
+                *value = NULL;
+                break;
+            }
+
+            if (renderer->getMajorShaderModel() < 4)
+            {
+                return egl::error(EGL_BAD_CONTEXT, EGL_FALSE);
+            }
+
+            *value = static_cast<rx::Renderer11*>(renderer)->getDevice();
+        }
+        break;
+#endif
       default:
         return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
     }
-- 
1.9.0.msysgit.0