[PATCH 4/5] wined3d: Introduce wined3d_adapter_get_output_ordinal().
Zhiyi Zhang
zzhang at codeweavers.com
Mon Feb 10 02:20:07 CST 2020
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
dlls/dxgi/adapter.c | 2 +-
dlls/dxgi/dxgi_private.h | 3 ++-
dlls/dxgi/output.c | 8 +++++---
dlls/wined3d/directx.c | 25 ++++++++++++++++++++++---
dlls/wined3d/wined3d.spec | 1 +
dlls/wined3d/wined3d_private.h | 2 ++
include/wine/wined3d.h | 2 ++
7 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c
index 477f19f3f4..329c67196c 100644
--- a/dlls/dxgi/adapter.c
+++ b/dlls/dxgi/adapter.c
@@ -136,7 +136,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IWineDXGIAdapter *ifac
return DXGI_ERROR_NOT_FOUND;
}
- if (FAILED(hr = dxgi_output_create(adapter, &output_object)))
+ if (FAILED(hr = dxgi_output_create(adapter, output_idx, &output_object)))
{
*output = NULL;
return hr;
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 5b93449834..5fd920b642 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -146,9 +146,10 @@ struct dxgi_output
LONG refcount;
struct wined3d_private_store private_store;
struct dxgi_adapter *adapter;
+ UINT wined3d_output_ordinal;
};
-HRESULT dxgi_output_create(struct dxgi_adapter *adapter, struct dxgi_output **output) DECLSPEC_HIDDEN;
+HRESULT dxgi_output_create(struct dxgi_adapter *adapter, UINT ordinal, struct dxgi_output **output) DECLSPEC_HIDDEN;
struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface) DECLSPEC_HIDDEN;
/* IDXGIAdapter */
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c
index a2331358e6..0f14dc75fc 100644
--- a/dlls/dxgi/output.c
+++ b/dlls/dxgi/output.c
@@ -581,20 +581,22 @@ struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface)
return CONTAINING_RECORD(iface, struct dxgi_output, IDXGIOutput4_iface);
}
-static void dxgi_output_init(struct dxgi_output *output, struct dxgi_adapter *adapter)
+static void dxgi_output_init(struct dxgi_output *output, UINT ordinal, struct dxgi_adapter *adapter)
{
output->IDXGIOutput4_iface.lpVtbl = &dxgi_output_vtbl;
output->refcount = 1;
wined3d_private_store_init(&output->private_store);
output->adapter = adapter;
+ wined3d_adapter_get_output_ordinal(adapter->factory->wined3d,
+ adapter->ordinal, ordinal, &output->wined3d_output_ordinal);
IWineDXGIAdapter_AddRef(&output->adapter->IWineDXGIAdapter_iface);
}
-HRESULT dxgi_output_create(struct dxgi_adapter *adapter, struct dxgi_output **output)
+HRESULT dxgi_output_create(struct dxgi_adapter *adapter, UINT ordinal, struct dxgi_output **output)
{
if (!(*output = heap_alloc_zero(sizeof(**output))))
return E_OUTOFMEMORY;
- dxgi_output_init(*output, adapter);
+ dxgi_output_init(*output, ordinal, adapter);
return S_OK;
}
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 10bbfa4c54..c828b1fce4 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -63,6 +63,24 @@ const GLenum magLookup[] =
GL_NEAREST, GL_NEAREST, GL_LINEAR,
};
+/* Retrieve an ordinal to uniquely identify an output within a wined3d instance.
+ * output_idx here is the output index within an adapter, rather than in wined3d instance */
+HRESULT CDECL wined3d_adapter_get_output_ordinal(const struct wined3d *wined3d,
+ UINT adapter_idx, UINT output_idx, UINT *ordinal)
+{
+ struct wined3d_adapter *adapter;
+
+ if (adapter_idx >= wined3d->adapter_count)
+ return WINED3DERR_INVALIDCALL;
+
+ adapter = wined3d->adapters[adapter_idx];
+ if (output_idx >= adapter->output_count)
+ return WINED3DERR_INVALIDCALL;
+
+ *ordinal = adapter->outputs[output_idx].ordinal;
+ return WINED3D_OK;
+}
+
void CDECL wined3d_output_release_ownership(const struct wined3d_output *output)
{
D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc = {0};
@@ -117,13 +135,13 @@ static void wined3d_output_cleanup(const struct wined3d_output *output)
D3DKMTCloseAdapter(&close_adapter_desc);
}
-static HRESULT wined3d_output_init(struct wined3d_output *output, const WCHAR *device_name)
+static HRESULT wined3d_output_init(struct wined3d_output *output, const WCHAR *device_name, UINT ordinal)
{
D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME open_adapter_desc;
D3DKMT_CREATEDEVICE create_device_desc = {{0}};
D3DKMT_CLOSEADAPTER close_adapter_desc;
- TRACE("output %p, device_name %s.\n", output, wine_dbgstr_w(device_name));
+ TRACE("output %p, device_name %s, ordinal %u.\n", output, wine_dbgstr_w(device_name), ordinal);
lstrcpyW(open_adapter_desc.DeviceName, device_name);
if (D3DKMTOpenAdapterFromGdiDisplayName(&open_adapter_desc))
@@ -137,6 +155,7 @@ static HRESULT wined3d_output_init(struct wined3d_output *output, const WCHAR *d
return E_FAIL;
}
+ output->ordinal = ordinal;
output->kmt_adapter = open_adapter_desc.hAdapter;
output->kmt_device = create_device_desc.hDevice;
output->vidpn_source_id = open_adapter_desc.VidPnSourceId;
@@ -2920,7 +2939,7 @@ HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
wined3d->adapters[0]->outputs = wined3d->outputs;
wined3d->adapters[0]->output_count = 1;
- if (FAILED(hr = wined3d_output_init(&wined3d->outputs[0], wined3d->adapters[0]->device_name)))
+ if (FAILED(hr = wined3d_output_init(&wined3d->outputs[0], wined3d->adapters[0]->device_name, 0)))
{
WARN("Failed to create output, hr %#x.\n", hr);
goto fail;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 7e13e19891..dda8390bd2 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -27,6 +27,7 @@
@ cdecl wined3d_unregister_windows(ptr)
@ cdecl wined3d_adapter_get_output_count(ptr long ptr)
+@ cdecl wined3d_adapter_get_output_ordinal(ptr long long ptr)
@ cdecl wined3d_blend_state_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_blend_state_decref(ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c7ace57324..a0b3982cec 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2896,6 +2896,8 @@ struct wined3d_adapter_ops
/* The output structure, represents a video card output */
struct wined3d_output
{
+ UINT ordinal;
+
D3DKMT_HANDLE kmt_adapter;
D3DKMT_HANDLE kmt_device;
D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index f676871b25..3c9e72d210 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2284,6 +2284,8 @@ HRESULT __cdecl wined3d_set_adapter_display_mode(struct wined3d *wined3d,
void __cdecl wined3d_unregister_windows(struct wined3d *wined3d);
HRESULT __cdecl wined3d_adapter_get_output_count(const struct wined3d *wined3d, UINT adapter_idx, UINT *count);
+HRESULT __cdecl wined3d_adapter_get_output_ordinal(const struct wined3d *wined3d, UINT adapter_idx, UINT output_idx,
+ UINT *ordinal);
HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
--
2.20.1
More information about the wine-devel
mailing list