summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xretrace/dxgiretrace.py13
-rw-r--r--retrace/retrace_swizzle.hpp9
-rw-r--r--specs/d3d11.py2
-rw-r--r--specs/dxgi.py4
-rw-r--r--specs/winapi.py5
5 files changed, 30 insertions, 3 deletions
diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py
index 1abfabd9..fbd11683 100755
--- a/retrace/dxgiretrace.py
+++ b/retrace/dxgiretrace.py
@@ -258,6 +258,19 @@ class D3DRetracer(Retracer):
print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);'
self.checkResult(interface, method)
return
+ if interface.name.startswith('ID3D11Device') and method.name == 'OpenSharedResource':
+ # Some applications (e.g., video playing in IE11) create shared resources within the same process.
+ # TODO: Generalize to other OpenSharedResource variants
+ print r' retrace::map<HANDLE>::const_iterator it = _shared_handle_map.find(hResource);'
+ print r' if (it == _shared_handle_map.end()) {'
+ print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";'
+ print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);'
+ self.checkResult(interface, method)
+ print r' } else {'
+ print r' hResource = it->second;'
+ Retracer.invokeInterfaceMethod(self, interface, method)
+ print r' }'
+ return
if interface.name.startswith('ID3D11Device') and method.name.startswith('OpenSharedResource'):
print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";'
print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);'
diff --git a/retrace/retrace_swizzle.hpp b/retrace/retrace_swizzle.hpp
index ddeecf3f..74589719 100644
--- a/retrace/retrace_swizzle.hpp
+++ b/retrace/retrace_swizzle.hpp
@@ -55,6 +55,15 @@ private:
base_type base;
public:
+ typedef typename base_type::const_iterator const_iterator;
+
+ const_iterator end(void) const {
+ return base.end();
+ }
+
+ const_iterator find(const T & key) const {
+ return base.find(key);
+ }
T & operator[] (const T &key) {
typename base_type::iterator it;
diff --git a/specs/d3d11.py b/specs/d3d11.py
index bbbaaf6b..cec92941 100644
--- a/specs/d3d11.py
+++ b/specs/d3d11.py
@@ -1383,7 +1383,7 @@ ID3D11Device.methods += [
StdMethod(HRESULT, "CreatePredicate", [(Pointer(Const(D3D11_QUERY_DESC)), "pPredicateDesc"), Out(Pointer(ObjPointer(ID3D11Predicate)), "ppPredicate")]),
StdMethod(HRESULT, "CreateCounter", [(Pointer(Const(D3D11_COUNTER_DESC)), "pCounterDesc"), Out(Pointer(ObjPointer(ID3D11Counter)), "ppCounter")]),
StdMethod(HRESULT, "CreateDeferredContext", [(UINT, "ContextFlags"), Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppDeferredContext")]),
- StdMethod(HRESULT, "OpenSharedResource", [(HANDLE, "hResource"), (REFIID, "ReturnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
+ StdMethod(HRESULT, "OpenSharedResource", [(RAW_HANDLE, "hResource"), (REFIID, "ReturnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
StdMethod(HRESULT, "CheckFormatSupport", [(DXGI_FORMAT, "Format"), Out(Pointer(D3D11_FORMAT_SUPPORT), "pFormatSupport")], sideeffects=False),
StdMethod(HRESULT, "CheckMultisampleQualityLevels", [(DXGI_FORMAT, "Format"), (UINT, "SampleCount"), Out(Pointer(UINT), "pNumQualityLevels")], sideeffects=False),
StdMethod(Void, "CheckCounterInfo", [Out(Pointer(D3D11_COUNTER_INFO), "pCounterInfo")], sideeffects=False),
diff --git a/specs/dxgi.py b/specs/dxgi.py
index 7349e25a..b79e15cf 100644
--- a/specs/dxgi.py
+++ b/specs/dxgi.py
@@ -375,8 +375,10 @@ IDXGIDeviceSubObject.methods += [
StdMethod(HRESULT, "GetDevice", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppDevice")]),
]
+SHARED_HANDLE = Handle("shared_handle", RAW_HANDLE)
+
IDXGIResource.methods += [
- StdMethod(HRESULT, "GetSharedHandle", [Out(Pointer(HANDLE), "pSharedHandle")]),
+ StdMethod(HRESULT, "GetSharedHandle", [Out(Pointer(SHARED_HANDLE), "pSharedHandle")]),
StdMethod(HRESULT, "GetUsage", [Out(Pointer(DXGI_USAGE), "pUsage")], sideeffects=False),
StdMethod(HRESULT, "SetEvictionPriority", [(DXGI_RESOURCE_PRIORITY, "EvictionPriority")]),
StdMethod(HRESULT, "GetEvictionPriority", [Out(Pointer(DXGI_RESOURCE_PRIORITY), "pEvictionPriority")], sideeffects=False),
diff --git a/specs/winapi.py b/specs/winapi.py
index f4e6ba0c..3697f858 100644
--- a/specs/winapi.py
+++ b/specs/winapi.py
@@ -85,7 +85,10 @@ LPCVOID = OpaquePointer(Const(VOID))
def DECLARE_HANDLE(expr):
return Handle(expr, IntPointer(expr))
-HANDLE = DECLARE_HANDLE("HANDLE")
+# XXX: HANDLE type is often used for disjoint handle namespaces
+RAW_HANDLE = IntPointer("HANDLE")
+HANDLE = Handle("HANDLE", RAW_HANDLE)
+
HWND = DECLARE_HANDLE("HWND")
HDC = DECLARE_HANDLE("HDC")
HMONITOR = DECLARE_HANDLE("HMONITOR")