[PATCH 4/5] dxgi: Allow wrapping factory objects.

Józef Kucia jkucia at codeweavers.com
Fri Jan 26 15:09:05 CST 2018


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

For RenderDoc in Wine.

---
 dlls/d3d11/d3d11_private.h |  2 +-
 dlls/dxgi/factory.c        | 18 +++++++++++++++---
 include/wine/winedxgi.idl  | 11 ++++++++++-
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index 9089398e5dfc..c286e768d9cb 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -29,7 +29,7 @@
 #include "winuser.h"
 #include "objbase.h"
 
-#include "d3d11_1.h"
+#include "d3d11_4.h"
 #ifdef D3D11_INIT_GUID
 #include "initguid.h"
 #endif
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index 8d2407895029..3f8816b3c23b 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -35,7 +35,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory4 *ifac
 
     TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
 
-    if (IsEqualGUID(iid, &IID_IDXGIFactory4)
+    if (IsEqualGUID(iid, &IID_IWineDXGIFactory)
+            || IsEqualGUID(iid, &IID_IDXGIFactory4)
             || IsEqualGUID(iid, &IID_IDXGIFactory3)
             || IsEqualGUID(iid, &IID_IDXGIFactory2)
             || (factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1))
@@ -504,10 +505,21 @@ static const struct IDXGIFactory4Vtbl dxgi_factory_vtbl =
 
 struct dxgi_factory *unsafe_impl_from_IDXGIFactory4(IDXGIFactory4 *iface)
 {
+    IWineDXGIFactory *wine_factory;
+    struct dxgi_factory *factory;
+    HRESULT hr;
+
     if (!iface)
         return NULL;
-    assert(iface->lpVtbl == &dxgi_factory_vtbl);
-    return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory4_iface);
+    if (FAILED(hr = IDXGIFactory4_QueryInterface(iface, &IID_IWineDXGIFactory, (void **)&wine_factory)))
+    {
+        ERR("Failed to get IWineDXGIFactory interface, hr %#x.\n", hr);
+        return NULL;
+    }
+    assert(wine_factory->lpVtbl == (void *)&dxgi_factory_vtbl);
+    factory = CONTAINING_RECORD(wine_factory, struct dxgi_factory, IDXGIFactory4_iface);
+    IWineDXGIFactory_Release(wine_factory);
+    return factory;
 }
 
 static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
diff --git a/include/wine/winedxgi.idl b/include/wine/winedxgi.idl
index 983cdba68d14..c3564d50800b 100644
--- a/include/wine/winedxgi.idl
+++ b/include/wine/winedxgi.idl
@@ -18,7 +18,7 @@
 
 #pragma makedep header
 
-import "dxgi.idl";
+import "dxgi1_5.idl";
 
 [
     object,
@@ -59,3 +59,12 @@ interface IWineDXGIDeviceParent : IUnknown
 interface IWineDXGIAdapter : IDXGIAdapter1
 {
 }
+
+[
+    object,
+    local,
+    uuid(ea02a0d1-4c95-488a-a82c-6034621e8c4f)
+]
+interface IWineDXGIFactory : IDXGIFactory4
+{
+}
-- 
2.13.6




More information about the wine-devel mailing list