[PATCH 2/5] dxgi: Implement dxgi_output_TakeOwnership().
Henri Verbeet
hverbeet at codeweavers.com
Wed Oct 30 09:01:30 CDT 2019
From: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
This supersedes patch 172271.
dlls/dxgi/output.c | 17 +++++++++++++++--
dlls/dxgi/tests/dxgi.c | 20 ++++++++++++--------
dlls/wined3d/directx.c | 31 +++++++++++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 1 +
5 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c
index db5c106948c..a2331358e69 100644
--- a/dlls/dxgi/output.c
+++ b/dlls/dxgi/output.c
@@ -364,9 +364,22 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput4 *iface)
static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput4 *iface, IUnknown *device, BOOL exclusive)
{
- FIXME("iface %p, device %p, exclusive %d stub!\n", iface, device, exclusive);
+ struct dxgi_output *output = impl_from_IDXGIOutput4(iface);
+ struct wined3d_output *wined3d_output;
+ HRESULT hr = DXGI_ERROR_INVALID_CALL;
- return E_NOTIMPL;
+ TRACE("iface %p, device %p, exclusive %d.\n", iface, device, exclusive);
+
+ if (!device)
+ return DXGI_ERROR_INVALID_CALL;
+
+ wined3d_mutex_lock();
+ if ((wined3d_output = wined3d_get_adapter_output(output->adapter->factory->wined3d,
+ output->adapter->ordinal)))
+ hr = wined3d_output_take_ownership(wined3d_output, exclusive);
+ wined3d_mutex_unlock();
+
+ return hr;
}
static void STDMETHODCALLTYPE dxgi_output_ReleaseOwnership(IDXGIOutput4 *iface)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index cbb5806e2d2..b05e7f8bf96 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -5611,10 +5611,14 @@ static void test_output_ownership(IUnknown *device, BOOL is_d3d12)
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_SUCCESS, FALSE);
else
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_GRAPHICS_PRESENT_OCCLUDED, TRUE);
+ hr = IDXGIOutput_TakeOwnership(output, NULL, FALSE);
+ ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDXGIOutput_TakeOwnership(output, NULL, TRUE);
+ ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
hr = IDXGIOutput_TakeOwnership(output, device, FALSE);
todo_wine ok(hr == (is_d3d12 ? E_NOINTERFACE : E_INVALIDARG), "Got unexpected hr %#x.\n", hr);
hr = IDXGIOutput_TakeOwnership(output, device, TRUE);
- todo_wine ok(hr == (is_d3d12 ? E_NOINTERFACE : S_OK), "Got unexpected hr %#x.\n", hr);
+ todo_wine_if(is_d3d12) ok(hr == (is_d3d12 ? E_NOINTERFACE : S_OK), "Got unexpected hr %#x.\n", hr);
IDXGIOutput_ReleaseOwnership(output);
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_SUCCESS, FALSE);
@@ -5624,16 +5628,16 @@ static void test_output_ownership(IUnknown *device, BOOL is_d3d12)
goto done;
hr = IDXGIOutput_TakeOwnership(output, device, FALSE);
- todo_wine ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
+ ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
IDXGIOutput_ReleaseOwnership(output);
hr = IDXGIOutput_TakeOwnership(output, device, TRUE);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
/* Note that the "exclusive" parameter to IDXGIOutput_TakeOwnership()
* seems to behave opposite to what's described by MSDN. */
- wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_GRAPHICS_PRESENT_OCCLUDED, TRUE);
+ wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_GRAPHICS_PRESENT_OCCLUDED, FALSE);
hr = IDXGIOutput_TakeOwnership(output, device, FALSE);
- todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
IDXGIOutput_ReleaseOwnership(output);
/* Swapchain in windowed mode. */
@@ -5646,11 +5650,11 @@ static void test_output_ownership(IUnknown *device, BOOL is_d3d12)
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_SUCCESS, FALSE);
hr = IDXGIOutput_TakeOwnership(output, device, FALSE);
- todo_wine ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
+ ok(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, "Got unexpected hr %#x.\n", hr);
hr = IDXGIOutput_TakeOwnership(output, device, TRUE);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_GRAPHICS_PRESENT_OCCLUDED, TRUE);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_GRAPHICS_PRESENT_OCCLUDED, FALSE);
IDXGIOutput_ReleaseOwnership(output);
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_SUCCESS, FALSE);
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index ce4ffd3a565..7c0443cd6e5 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -72,6 +72,37 @@ void CDECL wined3d_output_release_ownership(const struct wined3d_output *output)
D3DKMTSetVidPnSourceOwner(&set_owner_desc);
}
+HRESULT CDECL wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive)
+{
+ D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc;
+ D3DKMT_VIDPNSOURCEOWNER_TYPE owner_type;
+ NTSTATUS status;
+
+ TRACE("output %p, exclusive %#x.\n", output, exclusive);
+
+ owner_type = exclusive ? D3DKMT_VIDPNSOURCEOWNER_EXCLUSIVE : D3DKMT_VIDPNSOURCEOWNER_SHARED;
+ set_owner_desc.pType = &owner_type;
+ set_owner_desc.pVidPnSourceId = &output->vidpn_source_id;
+ set_owner_desc.VidPnSourceCount = 1;
+ set_owner_desc.hDevice = output->kmt_device;
+ status = D3DKMTSetVidPnSourceOwner(&set_owner_desc);
+
+ switch (status)
+ {
+ case STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE:
+ return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
+ case STATUS_INVALID_PARAMETER:
+ return E_INVALIDARG;
+ case STATUS_PROCEDURE_NOT_FOUND:
+ return E_NOINTERFACE;
+ case STATUS_SUCCESS:
+ return S_OK;
+ default:
+ FIXME("Unhandled error %#x.\n", status);
+ return E_FAIL;
+ }
+}
+
static void wined3d_output_cleanup(const struct wined3d_output *output)
{
D3DKMT_DESTROYDEVICE destroy_device_desc;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 8fda4801409..d9e4cfb6d91 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -193,6 +193,7 @@
@ cdecl wined3d_device_validate_device(ptr ptr)
@ cdecl wined3d_output_release_ownership(ptr)
+@ cdecl wined3d_output_take_ownership(ptr long)
@ cdecl wined3d_palette_create(ptr long long ptr ptr)
@ cdecl wined3d_palette_decref(ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index eba61d0777e..ce24eb3feff 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2490,6 +2490,7 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
void __cdecl wined3d_output_release_ownership(const struct wined3d_output *output);
+HRESULT __cdecl wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive);
HRESULT __cdecl wined3d_palette_create(struct wined3d_device *device, DWORD flags,
unsigned int entry_count, const PALETTEENTRY *entries, struct wined3d_palette **palette);
--
2.11.0
More information about the wine-devel
mailing list