From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 49 ++++++++++++++++++++++++++------------ dlls/dxcore/tests/dxcore.c | 6 ++--- 2 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index e60740cc5eb..e32b79ec2bb 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -102,46 +102,65 @@ static BOOL STDMETHODCALLTYPE dxcore_adapter_IsPropertySupported(IDXCoreAdapter return FALSE; }
+static HRESULT dxcore_adapter_get_property_size(struct dxcore_adapter *adapter, + DXCoreAdapterProperty property, size_t *size) +{ + static const size_t property_sizes[] = + { + [InstanceLuid] = sizeof(LUID), + [HardwareID] = sizeof(DXCoreHardwareID), + }; + + switch (property) + { + case InstanceLuid: + case HardwareID: + *size = property_sizes[property]; + return S_OK; + + default: + FIXME("Property %u not implemented.\n", property); + return DXGI_ERROR_INVALID_CALL; + } +} + static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *iface, DXCoreAdapterProperty property, size_t buffer_size, void *buffer) { struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + size_t size; + HRESULT hr;
TRACE("iface %p, property %u, buffer_size %Iu, buffer %p\n", iface, property, buffer_size, buffer);
if (!buffer) return E_POINTER;
+ if (FAILED(hr = dxcore_adapter_get_property_size(adapter, property, &size))) + return hr; + + if (buffer_size < size) + return E_INVALIDARG; + switch (property) { case InstanceLuid: - { - LUID *luid = buffer; - - if (buffer_size < sizeof(*luid)) - return E_INVALIDARG; - - *luid = adapter->identifier.adapter_luid; + *(LUID *)buffer = adapter->identifier.adapter_luid; break; - } + case HardwareID: { struct DXCoreHardwareID *hardware_id = buffer;
- if (buffer_size != sizeof(DXCoreHardwareID)) - return E_INVALIDARG; - hardware_id->vendorID = adapter->identifier.vendor_id; hardware_id->deviceID = adapter->identifier.device_id; hardware_id->subSysID = adapter->identifier.subsystem_id; hardware_id->revision = adapter->identifier.revision; break; } + default: - { - FIXME("property %u not implemented.\n", property); - return DXGI_ERROR_INVALID_CALL; - } + break; }
return S_OK; diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 36953a757bf..1f5d8c318bd 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -220,9 +220,9 @@ static void test_GetProperty(void)
memset(hwid, 0, sizeof(hwid)); hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) + 1, hwid); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(!!hwid[0].vendorID, "Expected vendorID.\n"); - todo_wine ok(!!hwid[0].deviceID, "Expected deviceID.\n"); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(!!hwid[0].vendorID, "Expected vendorID.\n"); + ok(!!hwid[0].deviceID, "Expected deviceID.\n"); ok(!hwid[1].vendorID, "Expected no vendorID.\n"); ok(!hwid[1].deviceID, "Expected no deviceID.\n");