diff options
author | Tiago Koji Castro Shibata <tiago.shibata@gmail.com> | 2022-05-25 21:41:27 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-06-16 00:19:54 +0000 |
commit | 4622e99e103ec2c079c6da082752f8a3c2bd0c83 (patch) | |
tree | 09f96be5e15cab11446428b1f31135c59e6e9f68 | |
parent | 3b867ae69b1739a5a2950009fc9bd1d4e0d81701 (diff) |
d3d12: fallback to integrated adapter instead of arbitrary one
Using the integrated adapter when none is specified uses less power by
default and doesn't break scenarios on Optimus systems (for example, on
Surface Books, detaching the screen gets prohibited because the GPU on
the performance base is in use)
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17005>
-rw-r--r-- | src/gallium/drivers/d3d12/d3d12_dxcore_screen.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gallium/drivers/d3d12/d3d12_dxcore_screen.cpp b/src/gallium/drivers/d3d12/d3d12_dxcore_screen.cpp index b12f2f4b3b1..7017cbf5046 100644 --- a/src/gallium/drivers/d3d12/d3d12_dxcore_screen.cpp +++ b/src/gallium/drivers/d3d12/d3d12_dxcore_screen.cpp @@ -110,7 +110,17 @@ choose_dxcore_adapter(IDXCoreAdapterFactory *factory, LUID *adapter_luid) } #endif - // No adapter specified or not found, pick 0 as the default + // Adapter not specified or not found, so pick an integrated adapter if possible + for (unsigned i = 0; i < list->GetAdapterCount(); ++i) { + if (SUCCEEDED(list->GetAdapter(i, &adapter))) { + bool is_integrated; + if (SUCCEEDED(adapter->GetProperty(DXCoreAdapterProperty::IsIntegrated, &is_integrated)) && is_integrated) + return adapter; + adapter->Release(); + } + } + + // No integrated GPUs, so pick the first valid one if (list->GetAdapterCount() > 0 && SUCCEEDED(list->GetAdapter(0, &adapter))) return adapter; } |