diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c index 87d886b1995..d18db852f65 100644 --- a/dlls/dxgi/adapter.c +++ b/dlls/dxgi/adapter.c @@ -38,6 +38,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_QueryInterface(IWineDXGIAdapter *i if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDXGIObject) || IsEqualGUID(riid, &IID_IDXGIAdapter) + || IsEqualGUID(riid, &IID_IDXGIAdapter1) || IsEqualGUID(riid, &IID_IWineDXGIAdapter)) { IUnknown_AddRef(iface); @@ -135,9 +136,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IWineDXGIAdapter *ifac return S_OK; } -static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc(IWineDXGIAdapter *iface, DXGI_ADAPTER_DESC *desc) +static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc1(IWineDXGIAdapter *iface, DXGI_ADAPTER_DESC1 *desc) { - struct dxgi_adapter *This = impl_from_IWineDXGIAdapter(iface); + struct dxgi_adapter *adapter = impl_from_IWineDXGIAdapter(iface); struct wined3d_adapter_identifier adapter_id; char description[128]; struct wined3d *wined3d; @@ -145,38 +146,57 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc(IWineDXGIAdapter *iface, D TRACE("iface %p, desc %p.\n", iface, desc); - if (!desc) return E_INVALIDARG; + if (!desc) + return E_INVALIDARG; - wined3d = IWineDXGIFactory_get_wined3d(This->parent); + wined3d = IWineDXGIFactory_get_wined3d(adapter->parent); adapter_id.driver_size = 0; adapter_id.description = description; adapter_id.description_size = sizeof(description); adapter_id.device_name_size = 0; EnterCriticalSection(&dxgi_cs); - hr = wined3d_get_adapter_identifier(wined3d, This->ordinal, 0, &adapter_id); + hr = wined3d_get_adapter_identifier(wined3d, adapter->ordinal, 0, &adapter_id); wined3d_decref(wined3d); LeaveCriticalSection(&dxgi_cs); - if (SUCCEEDED(hr)) - { - if (!MultiByteToWideChar(CP_ACP, 0, description, -1, desc->Description, 128)) - { - DWORD err = GetLastError(); - ERR("Failed to translate description %s (%#x).\n", debugstr_a(description), err); - hr = E_FAIL; - } + if (FAILED(hr)) + return hr; - desc->VendorId = adapter_id.vendor_id; - desc->DeviceId = adapter_id.device_id; - desc->SubSysId = adapter_id.subsystem_id; - desc->Revision = adapter_id.revision; - desc->DedicatedVideoMemory = adapter_id.video_memory; - desc->DedicatedSystemMemory = 0; /* FIXME */ - desc->SharedSystemMemory = 0; /* FIXME */ - memcpy(&desc->AdapterLuid, &adapter_id.adapter_luid, sizeof(desc->AdapterLuid)); + if (!MultiByteToWideChar(CP_ACP, 0, description, -1, desc->Description, 128)) + { + DWORD err = GetLastError(); + ERR("Failed to translate description %s (%#x).\n", debugstr_a(description), err); + hr = E_FAIL; } + desc->VendorId = adapter_id.vendor_id; + desc->DeviceId = adapter_id.device_id; + desc->SubSysId = adapter_id.subsystem_id; + desc->Revision = adapter_id.revision; + desc->DedicatedVideoMemory = adapter_id.video_memory; + desc->DedicatedSystemMemory = 0; /* FIXME */ + desc->SharedSystemMemory = 0; /* FIXME */ + memcpy(&desc->AdapterLuid, &adapter_id.adapter_luid, sizeof(desc->AdapterLuid)); + desc->Flags = 0; + + return hr; +} + +static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc(IWineDXGIAdapter *iface, DXGI_ADAPTER_DESC *desc) +{ + DXGI_ADAPTER_DESC1 desc1; + HRESULT hr; + + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + return E_INVALIDARG; + + if (FAILED(hr = dxgi_adapter_GetDesc1(iface, &desc1))) + return hr; + memcpy(desc, &desc1, sizeof(*desc)); + return hr; } @@ -214,6 +234,8 @@ static const struct IWineDXGIAdapterVtbl dxgi_adapter_vtbl = dxgi_adapter_EnumOutputs, dxgi_adapter_GetDesc, dxgi_adapter_CheckInterfaceSupport, + /* IDXGIAdapter1 methods */ + dxgi_adapter_GetDesc1, /* IWineDXGIAdapter methods */ dxgi_adapter_get_ordinal, }; diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 9be59db963f..b8e7b330b9b 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -101,6 +101,8 @@ static void test_device_interfaces(IDXGIDevice *device) static void test_adapter_desc(IDXGIDevice *device) { + DXGI_ADAPTER_DESC1 desc1; + IDXGIAdapter1 *adapter1; DXGI_ADAPTER_DESC desc; IDXGIAdapter *adapter; HRESULT hr; @@ -126,6 +128,33 @@ static void test_adapter_desc(IDXGIDevice *device) desc.SharedSystemMemory, desc.SharedSystemMemory / (1024 * 1024)); trace("LUID: %08x:%08x.\n", desc.AdapterLuid.HighPart, desc.AdapterLuid.LowPart); + hr = IDXGIAdapter_QueryInterface(adapter, &IID_IDXGIAdapter1, (void **)&adapter1); + ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE), "Got unexpected hr %#x.\n", hr); + if (hr == E_NOINTERFACE) + goto done; + + hr = IDXGIAdapter1_GetDesc1(adapter1, &desc1); + ok(SUCCEEDED(hr), "GetDesc1 failed, hr %#x.\n", hr); + + ok(!lstrcmpW(desc.Description, desc1.Description), + "Got unexpected description %s.\n", wine_dbgstr_w(desc1.Description)); + ok(desc1.VendorId == desc.VendorId, "Got unexpected vendor ID %04x.\n", desc1.VendorId); + ok(desc1.DeviceId == desc.DeviceId, "Got unexpected device ID %04x.\n", desc1.DeviceId); + ok(desc1.SubSysId == desc.SubSysId, "Got unexpected sub system ID %04x.\n", desc1.SubSysId); + ok(desc1.Revision == desc.Revision, "Got unexpected revision %02x.\n", desc1.Revision); + ok(desc1.DedicatedVideoMemory == desc.DedicatedVideoMemory, + "Got unexpected dedicated video memory %lu.\n", desc1.DedicatedVideoMemory); + ok(desc1.DedicatedSystemMemory == desc.DedicatedSystemMemory, + "Got unexpected dedicated system memory %lu.\n", desc1.DedicatedSystemMemory); + ok(desc1.SharedSystemMemory == desc.SharedSystemMemory, + "Got unexpected shared system memory %lu.\n", desc1.SharedSystemMemory); + ok(!memcmp(&desc.AdapterLuid, &desc1.AdapterLuid, sizeof(desc.AdapterLuid)), + "Got unexpected adapter LUID %08x:%08x.\n", desc1.AdapterLuid.HighPart, desc1.AdapterLuid.LowPart); + trace("Flags: %08x.\n", desc1.Flags); + + IDXGIAdapter1_Release(adapter1); + +done: IDXGIAdapter_Release(adapter); } diff --git a/include/wine/winedxgi.idl b/include/wine/winedxgi.idl index 363030a0018..a3baece97b2 100644 --- a/include/wine/winedxgi.idl +++ b/include/wine/winedxgi.idl @@ -33,7 +33,7 @@ interface IWineDXGIFactory : IDXGIFactory local, uuid(ab1de34c-2963-4ffd-8493-40f580e510e5) ] -interface IWineDXGIAdapter : IDXGIAdapter +interface IWineDXGIAdapter : IDXGIAdapter1 { UINT get_ordinal(); }