Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement D3DKMTEnumAdapters2 and D3DKMTQueryAdapterInfo (for WDDM_2_7_CAPS) #259

Open
wants to merge 67 commits into
base: experimental_9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
508a728
ws2_32/Tests: Add tests for send buffering.
Sep 13, 2024
832a61e
ntdll: Avoid short writes on nonblocking sockets.
Sep 13, 2024
ce15d36
ntdll: Locally duplicated socket fd for background send.
Sep 13, 2024
1eea231
ntdll: Don't cancel background socket sends.
Sep 13, 2024
ea84f2f
server: Correct STATUS_NOT_FOUND return from (cancel_async).
Sep 13, 2024
ac4be53
fixup! winevulkan: Share keyed mutex data.
Sep 20, 2024
fad64fd
winex11.drv: Set X window property to indicate if the presentation ma…
Sep 19, 2024
b6eba4d
nsiproxy: Only set the connection count from tcp_conns_enumerate_all …
misterfifths Sep 23, 2024
3638eac
nsiproxy: Only set the endpoint count from udp_endpoint_enumerate_all…
misterfifths Sep 23, 2024
db96f88
kernel32/tests: Add a test for TLS links.
Aug 27, 2024
fff0fab
ntdll: Reserve space for some TLS directories at once.
Aug 27, 2024
ab68793
ntdll: Iterate TEBs only once in alloc_tls_slot().
Aug 27, 2024
3d50128
ntdll: Do not use TlsLinks for enumerating TEBs.
Aug 27, 2024
e7da5a1
ntdll/tests: Add more tests for process instrumentation callback.
Sep 3, 2024
a91e43f
ntdll: Call instrumentation callback from wine_syscall_dispatcher on …
Sep 4, 2024
db90ca1
ntdll: Call instrumentation callback for KiUserExceptionDispatcher on…
Sep 4, 2024
cabc00e
ntdll: Call instrumentation callback for LdrInitializeThunk on x64.
Sep 4, 2024
dbd334b
ntdll: Call instrumentation callback for KiUserModeCallback on x64.
Sep 4, 2024
139fd55
ntdll: Support old parameter layout for NtSetInformationProcess( Proc…
Sep 5, 2024
95fab23
fixup! ntdll: Support x86_64 syscall emulation.
Sep 24, 2024
2382761
Revert "ntdll: Change module search order in LdrFindEntryForAddress()."
Sep 24, 2024
6ea3cc3
ntdll: Implement RtlRbInsertNodeEx().
Sep 20, 2024
17b61f5
ntdll: Implement RtlRbRemoveNode().
Sep 20, 2024
2b697f0
ntdll/tests: Add tests for RTL RB tree.
Sep 19, 2024
efadc74
ntdll: Fill LDR_DATA_TABLE_ENTRY.BaseAddressIndexNode.
Sep 20, 2024
713554e
ntdll: Use base address tree in get_modref().
Sep 20, 2024
5df0fa5
ntdll: Use base address tree in LdrFindEntryForAddress().
Sep 20, 2024
a3c850f
ntdll: Implement NtSetInformationProcess( ProcessTlsInformation ).
Sep 17, 2024
1bd85e4
ntdll: Use NtSetInformationProcess( ProcessTlsInformation ) in alloc_…
Sep 24, 2024
7ebedd3
ntdll: Match memory allocation layout for ThreadLocalStoragePointer.
Sep 24, 2024
d037b81
ntdll/tests: Move unwinding tests to a separate file.
julliard Feb 19, 2024
c67cc17
ntdll/tests: Add a test for module function table search.
Sep 24, 2024
f3cf8d1
ntdll: Maintain module exception directory table.
Sep 24, 2024
f612d6f
HACK: wine.inf: Add native,builting override for TDUSC / xinput1_3.
Sep 24, 2024
ae11e82
fixup! winevulkan: Support waiting for and signalling d3d12 shared fe…
Sep 25, 2024
d444e90
fixup! winex11.drv: Set X window property to indicate if the presenta…
Sep 25, 2024
ae0bc6d
winhttp/tests: Add some tests for querying string options with NULL b…
nsivov Jul 8, 2024
fb0369b
winhttp: Fix error handling when returning string options.
nsivov Jul 8, 2024
8fc24d2
winhttp: Implement WinHttpQueryOption(WINHTTP_OPTION_URL).
Jul 9, 2024
b6eff70
winhttp/tests: Add some more tests for string options in WinHttpQuery…
nsivov Jul 16, 2024
a753926
winhttp: Handle exact buffer length match in WinHttpQueryOption().
nsivov Jul 16, 2024
6dfd3c9
winevulkan: Update to VK spec version 1.3.295.
DadSchoorse Aug 30, 2024
38e2c27
winevulkan: Avoid empty struct extension conversions.
DadSchoorse Sep 26, 2024
8b70d56
winevulkan: Update to VK spec version 1.3.296.
DadSchoorse Sep 26, 2024
1e44da3
winevulkan: Update vk.xml to 1.3.296.
ivyl Sep 27, 2024
3254c83
comctl32: Implement EVENT_OBJECT_STATECHANGE for buttons.
madewokherd Jul 22, 2024
61992a5
user32: Handle WM_GETOBJECT in buttons.
madewokherd Jul 31, 2024
2b48135
win32u: Implement EVENT_OBJECT_NAMECHANGE.
madewokherd Jul 31, 2024
0b29c42
comctl32: Handle WM_GETOBJECT in tab control.
madewokherd Jul 24, 2024
e753a48
win32u: Correctly fill new foreground window TID in WM_ACTIVATEAPP.
Sep 28, 2024
d4022ea
user32: Respond to OBJID_QUERYCLASSNAMEIDX in combo boxes.
madewokherd Sep 28, 2024
2cc5baf
comctl32: Handle OBJID_QUERYCLASSNAMEIDX in trackbars.
madewokherd Sep 28, 2024
4ee0a14
ntdll: Skip dll file search when getting module handle.
Sep 29, 2024
be74251
atiadlxx: Bump driver version to 99.
Sep 29, 2024
308764a
wine.inf: Enable builtin atiadlxx for FFXVI.
Sep 29, 2024
9db402d
ntdll: HACK: Enable WINE_ALERT_SIMULATE_SCHED_QUANTUM option for Mary…
Sep 30, 2024
38e2231
Revert "win32u: Correctly fill new foreground window TID in WM_ACTIVA…
Sep 30, 2024
cd414fc
win32u: Call set_active_window() helper directly from handle_internal…
Sep 30, 2024
e05e0ba
win32u: Correctly fill new foreground window TID in WM_ACTIVATEAPP.
Sep 28, 2024
849d4bd
fixup! ntdll: Skip dll file search when getting module handle.
Sep 30, 2024
d6e4afd
ntdll: HACK: Force en-US locale for EAC launcher.
Oct 1, 2024
68460d3
user32/tests: Add tests for QueryDisplayConfig( QDC_VIRTUAL_MODE_AWAR…
Oct 1, 2024
1a1f136
win32u: Support QDC_VIRTUAL_MODE_AWARE in NtUserGetDisplayConfigBuffe…
Oct 1, 2024
5416bf6
win32u: Support QDC_VIRTUAL_MODE_AWARE in NtUserQueryDisplayConfig().
Oct 1, 2024
f25c0d0
gdi32: Implement D3DKMTEnumAdapters2
liam-middlebrook Oct 12, 2024
23d772f
win32u: Move D3DKMTQueryAdapterInfo into gdi_dc_funcs
liam-middlebrook Oct 12, 2024
b239fbc
winex11.drv: Implement D3DKMTQueryAdapterInfo WDDM_2_7_CAPS
liam-middlebrook Oct 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dlls/atiadlxx/atiadlxx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ typedef struct ADLDisplayMap
} ADLDisplayMap, *LPADLDisplayMap;

static const ADLVersionsInfo version = {
"23.19.02-230831a-396538C-AMD-Software-Adrenalin-Edition",
"99.19.02-230831a-396538C-AMD-Software-Adrenalin-Edition",
"",
"http://support.amd.com/drivers/xml/driver_09_us.xml",
};

static const ADLVersionsInfoX2 version2 = {
"23.19.02-230831a-396538C-AMD-Software-Adrenalin-Edition",
"99.19.02-230831a-396538C-AMD-Software-Adrenalin-Edition",
"",
"23.10.2",
"99.10.2",
"http://support.amd.com/drivers/xml/driver_09_us.xml",
};

Expand Down
11 changes: 11 additions & 0 deletions dlls/comctl32/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 );
infoPtr->state |= BUTTON_BTNPRESSED;
SetCapture( hWnd );
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
}
else if (wParam == VK_UP || wParam == VK_DOWN)
{
Expand Down Expand Up @@ -637,6 +638,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
SetCapture( hWnd );
infoPtr->state |= BUTTON_BTNPRESSED;
SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 );
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
break;

case WM_KEYUP:
Expand All @@ -649,6 +651,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
SendMessageW(hWnd, BCM_SETDROPDOWNSTATE, FALSE, 0);
if (!(state & BUTTON_BTNPRESSED)) break;
infoPtr->state &= BUTTON_NSTATES | BST_HOT;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
if (!(state & BST_PUSHED))
{
ReleaseCapture();
Expand Down Expand Up @@ -688,6 +691,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
infoPtr->state &= BUTTON_NSTATES;
if (infoPtr->state & BST_PUSHED)
SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 );
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
}
break;

Expand Down Expand Up @@ -717,13 +721,15 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
{
infoPtr->state |= BST_HOT;
InvalidateRect( hWnd, NULL, FALSE );
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
break;
}

case WM_MOUSELEAVE:
{
infoPtr->state &= ~BST_HOT;
InvalidateRect( hWnd, NULL, FALSE );
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
break;
}

Expand Down Expand Up @@ -858,6 +864,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
case WM_SETFOCUS:
TRACE("WM_SETFOCUS %p\n",hWnd);
infoPtr->state |= BST_FOCUS;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );

if (btn_type == BS_OWNERDRAW)
paint_button( infoPtr, btn_type, ODA_FOCUS );
Expand All @@ -871,6 +878,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
case WM_KILLFOCUS:
TRACE("WM_KILLFOCUS %p\n",hWnd);
infoPtr->state &= ~BST_FOCUS;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );

if ((infoPtr->state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
ReleaseCapture();
Expand Down Expand Up @@ -994,6 +1002,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
if ((infoPtr->state & 3) != wParam)
{
infoPtr->state = (infoPtr->state & ~3) | wParam;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
InvalidateRect( hWnd, NULL, FALSE );
}
if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && (style & WS_CHILD))
Expand All @@ -1017,6 +1026,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
if (btn_type == BS_USERBUTTON)
BUTTON_NOTIFY_PARENT( hWnd, (state & BST_PUSHED) ? BN_HILITE : BN_UNHILITE );
infoPtr->state = state;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );

InvalidateRect( hWnd, NULL, FALSE );
}
Expand All @@ -1029,6 +1039,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
{
infoPtr->state &= ~BST_DROPDOWNPUSHED;
infoPtr->state |= new_state;
NotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
InvalidateRect(hWnd, NULL, FALSE);
}
break;
Expand Down
5 changes: 5 additions & 0 deletions dlls/comctl32/tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,11 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case TCM_SETEXTENDEDSTYLE:
return TAB_SetExtendedStyle (infoPtr, wParam, lParam);

case WM_GETOBJECT:
if ((LONG)lParam == OBJID_QUERYCLASSNAMEIDX)
return 0x1000f;
break;

case WM_GETFONT:
return TAB_GetFont (infoPtr);

Expand Down
15 changes: 15 additions & 0 deletions dlls/comctl32/tests/tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,20 @@ static void test_TCM_GETROWCOUNT(void)
DestroyWindow(hTab);
}

static void test_WM_GETOBJECT(void)
{
HWND hTab;
DWORD objid;

hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 2);
ok(hTab != NULL, "Failed to create tab control\n");

objid = SendMessageA(hTab, WM_GETOBJECT, 0, OBJID_QUERYCLASSNAMEIDX);
ok(objid == 0x1000f, "Unexpected objid %lu.\n", objid);

DestroyWindow(hTab);
}

START_TEST(tab)
{
LOGFONTA logfont;
Expand Down Expand Up @@ -1660,6 +1674,7 @@ START_TEST(tab)
test_create();
test_TCN_SELCHANGING();
test_TCM_GETROWCOUNT();
test_WM_GETOBJECT();

uninit_winevent_hook();

Expand Down
5 changes: 5 additions & 0 deletions dlls/comctl32/trackbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,11 @@ TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_GETDLGCODE:
return DLGC_WANTARROWS;

case WM_GETOBJECT:
if ((LONG)lParam == OBJID_QUERYCLASSNAMEIDX)
return 0x10012;
return 0;

case WM_KEYDOWN:
return TRACKBAR_KeyDown (infoPtr, (INT)wParam);

Expand Down
74 changes: 71 additions & 3 deletions dlls/gdi32/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,78 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI
return status;
}

NTSTATUS WINAPI D3DKMTEnumAdapters2( const void *param )
NTSTATUS WINAPI D3DKMTEnumAdapters2( D3DKMT_ENUMADAPTERS2 *enumAdapters )
{
FIXME( "param %p stub.\n", param );
return STATUS_NOT_SUPPORTED;
NTSTATUS status = STATUS_SUCCESS;
SP_DEVINFO_DATA device_data;
DEVPROPTYPE type;
HDEVINFO devinfo;
UINT dev_count = 0;
HANDLE mutex;

TRACE("(%p)\n", enumAdapters);

mutex = get_display_device_init_mutex();
devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, L"PCI", NULL, 0);
Copy link

@Triang3l Triang3l Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the "PCI" enumerator also include software devices like the Microsoft Basic Display Adapter with the WARP software Direct3D UMD, as well as non-PCI GPUs such as the Host1x-attached Nvidia Tegra 3's GPU in the Microsoft Surface RT?

For enumerating all display devices, CM_Get_Device_Interface_List for GUID_DISPLAY_DEVICE_ARRIVAL can be used alternatively (however you need D3DKMTOpenAdapterFromDeviceName aka NtGdiDdDDIOpenAdapterFromDeviceName implemented somehow to actually obtain the D3DKMT adapter handle from the device name returned by it — and in upstream Wine, as of now, that function simply does NtGdiDdDDIOpenAdapterFromLuid for a zeroed LUID), it does include the software adapter, although I'm not sure how well-implemented cfgmgr32 is in Wine on non-Windows hosts overall.

One usage example is available at https://gitlab.freedesktop.org/Triang3l/mesa/-/blob/Terakan/src/amd/terascale/vulkan/winsys/wddm/terakan_physical_device_wddm.c (see terakan_physical_device_wddm_enumerate).

Note the kind of dependency reversal in that current implementation of NtGdiDdDDIOpenAdapterFromDeviceName in Wine also (which is of course fine as for now it's just a stub that opens the first available adapter or something like that). FromDeviceName has existed since Windows Vista, while FromLuid was added in Windows 8, and is itself can be implemented as calling FromDeviceName and comparing the LUID for each adapter returned by CM_Get_Device_Interface_List.

Copy link

@Triang3l Triang3l Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://learn.microsoft.com/en-us/windows-hardware/drivers/install/enumerating-installed-device-interface-classes, SetupDiGetClassDevs also can be used for the purposes of enumeration, but the Enumerator argument can be NULL. And yeah, since you can query the LUID this way (via DEVPROPKEY_GPU_LUID) without actually calling D3DKMTOpenAdapterFromDeviceName, it should be more straightforward than using the Configuration Manager. Is the "PCI" enumerator needed for anything important in Wine, and what happens if you don't pass it?

Edit: The Configuration Manager also has CM_Get_Device_Interface_Property for the same purpose, so it doesn't really matter which one of the two is used — and the Setup API also appears to be much older, though CfgMgr appears to have been added in Vista, which is the first release to have WDDM at all.

Edit 2: Which Windows version has gotten DEVPKEY_Gpu_Luid at all first? If it's actually something as recent as some Windows 10 update rather than Vista, the D3DKMTOpenAdapterFromDeviceName approach may be more preferable. Though if you can get the device name from the Setup API rather than the Configuration Manager as well, the selection between the two also doesn't matter.

device_data.cbSize = sizeof(device_data);

while(SetupDiEnumDeviceInfo(devinfo, dev_count++, &device_data))
{
D3DKMT_OPENADAPTERFROMLUID luid_desc;
UINT dev_idx = dev_count - 1;
D3DKMT_ADAPTERINFO *adapter;

TRACE("Device: %u\n", dev_idx);

/* If nothing to write, just pass through the loop */
if (!enumAdapters->pAdapters)
continue;

adapter = (D3DKMT_ADAPTERINFO*)(enumAdapters->pAdapters + dev_idx);

if (SetupDiGetDevicePropertyW(devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type,
(BYTE *)&luid_desc.AdapterLuid, sizeof(luid_desc.AdapterLuid), NULL, 0))
{
/* NumOfSources appears to be in reference to displays. This could mean connected
* displays, maximum number of "heads", surfaces for direct scanout, or something else
* entirely. It's not clear from the MSDN page what kind of value is actually expected
* here.
*
* bPrecisePresentRegionsPreferred sounds like a scanout-level optimization. Again, MSDN
* isn't very descriptive about what this really means. Given that it's typical for
* modern GPUs to scanout an entire surface at once, leave this falsey.
*/
adapter->NumOfSources = 0;
adapter->bPrecisePresentRegionsPreferred = FALSE;
FIXME("NumOfSources and bPrecisePresentRegionsPreferred not set, need implementation.\n");

if ((status = NtGdiDdDDIOpenAdapterFromLuid(&luid_desc)))
break;

adapter->AdapterLuid = luid_desc.AdapterLuid;
adapter->hAdapter = luid_desc.hAdapter;

TRACE("hAdapter: %u AdapterLuid: %08lx:%08lx NumOfSources: %lu bPrecisePresentRegionsPreferred: %d\n",
adapter->hAdapter,
adapter->AdapterLuid.HighPart,
adapter->AdapterLuid.LowPart,
adapter->NumOfSources,
adapter->bPrecisePresentRegionsPreferred);
}
else
{
TRACE("no known adapter\n");
}
}
/* decrement dev count to actual count */
dev_count--;
SetupDiDestroyDeviceInfoList(devinfo);
release_display_device_init_mutex(mutex);

TRACE("Devices enumerated: %u\n", dev_count);
enumAdapters->NumAdapters = dev_count;

return status;
}

/***********************************************************************
Expand Down
Loading