[PATCH v4 5/5] dxgi: Add a function to IWineDXGIAdapter to receive external memory usage info.
Conor McCarthy
cmccarthy at codeweavers.com
Wed Dec 4 08:11:18 CST 2019
For use by future patched vkd3d and Wine d3d12 modules.
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
dlls/dxgi/adapter.c | 13 +++++++++++++
dlls/wined3d/directx.c | 21 +++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
include/wine/winedxgi.idl | 4 ++++
5 files changed, 41 insertions(+)
diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c
index d7afad62..f6410f44 100644
--- a/dlls/dxgi/adapter.c
+++ b/dlls/dxgi/adapter.c
@@ -409,6 +409,18 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_get_adapter_info(IWineDXGIAdapter
return hr;
}
+static void STDMETHODCALLTYPE dxgi_adapter_update_memory_usage(IWineDXGIAdapter *iface,
+ unsigned int non_local, INT64 bytes_added)
+{
+ struct dxgi_adapter *adapter = impl_from_IWineDXGIAdapter(iface);
+
+ TRACE("iface %p, non-local %u, bytes added 0x%s.\n", iface, non_local,
+ wine_dbgstr_longlong(bytes_added));
+
+ wined3d_update_adapter_memory_usage(adapter->factory->wined3d, adapter->ordinal,
+ non_local ? WINED3D_ADAPTER_MEMORY_NON_LOCAL : WINED3D_ADAPTER_MEMORY_LOCAL, bytes_added);
+}
+
static const struct IWineDXGIAdapterVtbl dxgi_adapter_vtbl =
{
dxgi_adapter_QueryInterface,
@@ -437,6 +449,7 @@ static const struct IWineDXGIAdapterVtbl dxgi_adapter_vtbl =
dxgi_adapter_GetDesc3,
/* IWineDXGIAdapter methods */
dxgi_adapter_get_adapter_info,
+ dxgi_adapter_update_memory_usage,
};
struct dxgi_adapter *unsafe_impl_from_IDXGIAdapter(IDXGIAdapter *iface)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 4625009c..7011f737 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1400,6 +1400,27 @@ fail:
return WINED3DERR_INVALIDCALL;
}
+void CDECL wined3d_update_adapter_memory_usage(const struct wined3d *wined3d, unsigned int adapter_idx,
+ enum wined3d_adapter_memory_type type, INT64 bytes_added)
+{
+ struct wined3d_adapter *adapter;
+
+ wined3d_mutex_lock();
+
+ if (adapter_idx >= wined3d->adapter_count || type >= ARRAY_SIZE(adapter->memory_usage))
+ {
+ ERR("Invalid call.\n");
+ goto done;
+ }
+
+ adapter = wined3d->adapters[adapter_idx];
+
+ adapter_adjust_memory(adapter, type, bytes_added);
+
+done:
+ wined3d_mutex_unlock();
+}
+
HRESULT CDECL wined3d_get_adapter_memory_info(const struct wined3d *wined3d, unsigned int adapter_idx,
enum wined3d_adapter_memory_type type, struct wined3d_adapter_memory_info *info)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 17cfed9c..07a59ec3 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -27,6 +27,7 @@
@ cdecl wined3d_set_adapter_display_mode(ptr long ptr)
@ cdecl wined3d_set_adapter_reserved_memory(ptr long long int64);
@ cdecl wined3d_unregister_adapter_memory_event(ptr long long);
+@ cdecl wined3d_update_adapter_memory_usage(ptr long long int64);
@ cdecl wined3d_unregister_windows(ptr)
@ cdecl wined3d_blend_state_create(ptr ptr ptr ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 30c97492..e584d763 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2241,6 +2241,8 @@ HRESULT __cdecl wined3d_set_adapter_reserved_memory(const struct wined3d *wined3
enum wined3d_adapter_memory_type type, UINT64 reservation);
HRESULT __cdecl wined3d_unregister_adapter_memory_event(const struct wined3d *wined3d, unsigned int adapter_idx,
DWORD cookie);
+void __cdecl wined3d_update_adapter_memory_usage(const struct wined3d *wined3d, unsigned int adapter_idx,
+ enum wined3d_adapter_memory_type type, INT64 bytes_added);
void __cdecl wined3d_unregister_windows(struct wined3d *wined3d);
HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
diff --git a/include/wine/winedxgi.idl b/include/wine/winedxgi.idl
index 070ac2fd..fbc224a9 100644
--- a/include/wine/winedxgi.idl
+++ b/include/wine/winedxgi.idl
@@ -82,6 +82,10 @@ struct wine_dxgi_adapter_info
interface IWineDXGIAdapter : IDXGIAdapter4
{
HRESULT get_adapter_info([out] struct wine_dxgi_adapter_info *info);
+ void update_memory_usage(
+ [in] unsigned int non_local,
+ [in] INT64 bytes_added
+ );
}
[
--
2.24.0
More information about the wine-devel
mailing list