[PATCH v4 3/5] dxgi: Partially implement IDXGIAdapter3::SetVideoMemoryReservation().
Conor McCarthy
cmccarthy at codeweavers.com
Wed Dec 4 08:11:16 CST 2019
Used by Hitman 2.
Reservations are recorded but nothing is actually reserved.
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
dlls/dxgi/adapter.c | 6 ++++--
dlls/dxgi/tests/dxgi.c | 2 --
dlls/wined3d/directx.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
5 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c
index b0825cc5..3db10e8a 100644
--- a/dlls/dxgi/adapter.c
+++ b/dlls/dxgi/adapter.c
@@ -345,10 +345,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_QueryVideoMemoryInfo(IWineDXGIAdap
static HRESULT STDMETHODCALLTYPE dxgi_adapter_SetVideoMemoryReservation(IWineDXGIAdapter *iface,
UINT node_index, DXGI_MEMORY_SEGMENT_GROUP segment_group, UINT64 reservation)
{
- FIXME("iface %p, node_index %u, segment_group %#x, reservation 0x%s stub!\n",
+ struct dxgi_adapter *adapter = impl_from_IWineDXGIAdapter(iface);
+
+ FIXME("iface %p, node_index %u, segment_group %#x, reservation 0x%s partial stub!\n",
iface, node_index, segment_group, wine_dbgstr_longlong(reservation));
- return S_OK;
+ return wined3d_set_adapter_reserved_memory(adapter->factory->wined3d, adapter->ordinal, segment_group, reservation);
}
static HRESULT STDMETHODCALLTYPE dxgi_adapter_RegisterVideoMemoryBudgetChangeNotificationEvent(
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index 1b132f92..e788a25c 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -996,13 +996,11 @@ static void test_query_video_memory_info(void)
hr = IDXGIAdapter3_QueryVideoMemoryInfo(adapter3, 0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memory_info);
ok(hr == S_OK, "Failed to query video memory info, hr %#x.\n", hr);
- todo_wine
ok(memory_info.CurrentReservation == reservation, "Got unexpected current reservation 0x%s.\n",
wine_dbgstr_longlong(memory_info.CurrentReservation));
hr = IDXGIAdapter3_QueryVideoMemoryInfo(adapter3, 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &memory_info);
ok(hr == S_OK, "Failed to query video memory info, hr %#x.\n", hr);
- todo_wine_if(desc.DedicatedVideoMemory)
ok(memory_info.CurrentReservation == reservation || !desc.DedicatedVideoMemory, "Got unexpected current reservation 0x%s.\n",
wine_dbgstr_longlong(memory_info.CurrentReservation));
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 4a8baed3..0d2bdc8e 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1422,6 +1422,42 @@ fail:
return E_INVALIDARG;
}
+HRESULT CDECL wined3d_set_adapter_reserved_memory(const struct wined3d *wined3d, unsigned int adapter_idx,
+ enum wined3d_adapter_memory_type type, UINT64 reservation)
+{
+ struct wined3d_adapter_memory_info memory_info;
+ struct wined3d_adapter *adapter;
+ HRESULT hr;
+
+ TRACE("wined3d %p, adapter_idx %u, type %u, reservation 0x%s.\n",
+ wined3d, adapter_idx, type, wine_dbgstr_longlong(reservation));
+
+ if (FAILED(hr = wined3d_get_adapter_memory_info(wined3d, adapter_idx, type, &memory_info)))
+ return hr;
+ if (memory_info.total && reservation > memory_info.total)
+ return E_INVALIDARG;
+
+ /* FIXME: Windows returns E_INVALIDARG if non-local and a non-zero reservation are specified for
+ * a UMA adapter. UMA status is unknown unless adapter->driver_info.vram_bytes is zero. */
+
+ wined3d_mutex_lock();
+
+ if (adapter_idx >= wined3d->adapter_count || type >= ARRAY_SIZE(adapter->memory_usage))
+ goto fail;
+
+ FIXME("Memory reservation sizes are returned if queried but otherwise are ignored.\n");
+ adapter = wined3d->adapters[adapter_idx];
+ adapter->memory_usage[type].bytes_reserved = reservation;
+
+ wined3d_mutex_unlock();
+
+ return WINED3D_OK;
+
+fail:
+ wined3d_mutex_unlock();
+ return E_INVALIDARG;
+}
+
HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
struct wined3d_raster_status *raster_status)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index e618b6fd..1ff73adf 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -24,6 +24,7 @@
@ cdecl wined3d_register_software_device(ptr ptr)
@ cdecl wined3d_register_window(ptr ptr ptr long)
@ cdecl wined3d_set_adapter_display_mode(ptr long ptr)
+@ cdecl wined3d_set_adapter_reserved_memory(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 7e5ca169..5ca1673d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2235,6 +2235,8 @@ BOOL __cdecl wined3d_register_window(struct wined3d *wined3d, HWND window,
struct wined3d_device *device, unsigned int flags);
HRESULT __cdecl wined3d_set_adapter_display_mode(struct wined3d *wined3d,
UINT adapter_idx, const struct wined3d_display_mode *mode);
+HRESULT __cdecl wined3d_set_adapter_reserved_memory(const struct wined3d *wined3d, unsigned int adapter_idx,
+ enum wined3d_adapter_memory_type type, UINT64 reservation);
void __cdecl wined3d_unregister_windows(struct wined3d *wined3d);
HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
--
2.24.0
More information about the wine-devel
mailing list