Merge branch 'master' into idd-no-gpu-warn

This commit is contained in:
Geoffrey McRae
2026-06-03 21:35:08 +10:00
committed by GitHub
12 changed files with 75 additions and 15 deletions

View File

@@ -30,7 +30,8 @@ struct LGPipeMsg
enum enum
{ {
SETCURSORPOS, SETCURSORPOS,
SETDISPLAYMODE SETDISPLAYMODE,
GPUSTATUS
} }
type; type;
union union
@@ -49,5 +50,11 @@ struct LGPipeMsg
uint32_t refresh; uint32_t refresh;
} }
displayMode; displayMode;
struct
{
bool software;
}
gpuStatus;
}; };
}; };

View File

@@ -30,6 +30,13 @@ HRESULT CD3D11Device::Init()
hr = m_factory->EnumAdapterByLuid(m_adapterLuid, IID_PPV_ARGS(&m_adapter)); hr = m_factory->EnumAdapterByLuid(m_adapterLuid, IID_PPV_ARGS(&m_adapter));
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
DXGI_ADAPTER_DESC1 desc = {};
hr = m_adapter->GetDesc1(&desc);
if (FAILED(hr))
return hr;
m_isSoftware = (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) != 0;
// only 11.1 supports DX12 interoperabillity // only 11.1 supports DX12 interoperabillity
static const D3D_FEATURE_LEVEL featureLevels[] = static const D3D_FEATURE_LEVEL featureLevels[] =

View File

@@ -36,6 +36,7 @@ private:
ComPtr<IDXGIAdapter1 > m_adapter; ComPtr<IDXGIAdapter1 > m_adapter;
ComPtr<ID3D11Device5 > m_device; ComPtr<ID3D11Device5 > m_device;
ComPtr<ID3D11DeviceContext4> m_context; ComPtr<ID3D11DeviceContext4> m_context;
bool m_isSoftware;
public: public:
CD3D11Device(LUID adapterLuid) : CD3D11Device(LUID adapterLuid) :
@@ -51,4 +52,6 @@ public:
ComPtr<ID3D11Device5> GetDevice() { return m_device; } ComPtr<ID3D11Device5> GetDevice() { return m_device; }
ComPtr<ID3D11DeviceContext4> GetContext() { return m_context; } ComPtr<ID3D11DeviceContext4> GetContext() { return m_context; }
bool IsSoftware() { return m_isSoftware; }
}; };

View File

@@ -21,6 +21,7 @@
#include "CIndirectMonitorContext.h" #include "CIndirectMonitorContext.h"
#include "CPlatformInfo.h" #include "CPlatformInfo.h"
#include "CDebug.h" #include "CDebug.h"
#include "CPipeServer.h"
CIndirectMonitorContext::CIndirectMonitorContext(_In_ IDDCX_MONITOR monitor, CIndirectDeviceContext * device) : CIndirectMonitorContext::CIndirectMonitorContext(_In_ IDDCX_MONITOR monitor, CIndirectDeviceContext * device) :
m_monitor(monitor), m_monitor(monitor),
@@ -70,6 +71,7 @@ reInit:
} }
m_swapChain.reset(new CSwapChainProcessor(m_monitor, m_devContext, swapChain, m_dx11Device, m_dx12Device, newFrameEvent)); m_swapChain.reset(new CSwapChainProcessor(m_monitor, m_devContext, swapChain, m_dx11Device, m_dx12Device, newFrameEvent));
g_pipe.SetGPUStatus(m_dx11Device->IsSoftware());
} }
void CIndirectMonitorContext::UnassignSwapChain() void CIndirectMonitorContext::UnassignSwapChain()

View File

@@ -174,4 +174,16 @@ void CPipeServer::SetDisplayMode(uint32_t width, uint32_t height, uint32_t refre
msg.displayMode.height = height; msg.displayMode.height = height;
msg.displayMode.refresh = refresh; msg.displayMode.refresh = refresh;
WriteMsg(msg); WriteMsg(msg);
}
void CPipeServer::SetGPUStatus(bool software)
{
if (!m_connected)
return;
LGPipeMsg msg;
msg.size = sizeof(msg);
msg.type = LGPipeMsg::GPUSTATUS;
msg.gpuStatus.software = software;
WriteMsg(msg);
} }

View File

@@ -55,6 +55,7 @@ class CPipeServer
void SetCursorPos(uint32_t x, uint32_t y); void SetCursorPos(uint32_t x, uint32_t y);
void SetDisplayMode(uint32_t width, uint32_t height, uint32_t refresh); void SetDisplayMode(uint32_t width, uint32_t height, uint32_t refresh);
void SetGPUStatus(bool software);
}; };
extern CPipeServer g_pipe; extern CPipeServer g_pipe;

View File

@@ -90,7 +90,7 @@ void CConfigWindow::updateFont()
for (HWND child : std::initializer_list<HWND>({ for (HWND child : std::initializer_list<HWND>({
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel, *m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete, *m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete, *m_modeReset,
*m_autosizeGroup, *m_defRefreshLabel, *m_defRefresh, *m_defRefreshHz, *m_autosizeGroup, *m_defRefreshLabel, *m_defRefresh, *m_defRefreshHz,
*m_prefGroup, *m_prefNoGPU, *m_prefGroup, *m_prefNoGPU,
})) }))
@@ -157,6 +157,7 @@ LRESULT CConfigWindow::onCreate()
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd)); m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd)); m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
m_modeReset.reset(new CButton(L"Reset", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
EnableWindow(*m_modeUpdate, FALSE); EnableWindow(*m_modeUpdate, FALSE);
EnableWindow(*m_modeDelete, FALSE); EnableWindow(*m_modeDelete, FALSE);
@@ -207,6 +208,7 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20); pos.pinBottomLeft(*m_modeRefresh, 75, 48, 50, 20);
pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24); pos.pinBottomLeft(*m_modeUpdate, 24, 20, 50, 24);
pos.pinBottomLeft(*m_modeDelete, 75, 20, 50, 24); pos.pinBottomLeft(*m_modeDelete, 75, 20, 50, 24);
pos.pinBottomLeft(*m_modeReset, 126, 20, 50, 24);
pos.pinTopLeft(*m_autosizeGroup, 224, 40, 200, 52); pos.pinTopLeft(*m_autosizeGroup, 224, 40, 200, 52);
pos.pinTopLeft(*m_defRefreshLabel, 236, 64, 95, 20); pos.pinTopLeft(*m_defRefreshLabel, 236, 64, 95, 20);
@@ -293,6 +295,14 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
updateModeList(); updateModeList();
onModeListSelectChange(); onModeListSelectChange();
} }
else if (m_modeReset && hwnd == *m_modeReset && code == BN_CLICKED && m_modes)
{
*m_modes = m_settings.getDefaultModes();
m_settings.setModes(*m_modes);
m_modeBox->clear();
updateModeList();
onModeListSelectChange();
}
else if (m_defRefresh && hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh) else if (m_defRefresh && hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh)
{ {
int value; int value;

View File

@@ -52,6 +52,7 @@ class CConfigWindow : public CWindow
std::unique_ptr<CButton> m_modeUpdate; std::unique_ptr<CButton> m_modeUpdate;
std::unique_ptr<CButton> m_modeDelete; std::unique_ptr<CButton> m_modeDelete;
std::unique_ptr<CButton> m_modeReset;
std::unique_ptr<CGroupBox> m_autosizeGroup; std::unique_ptr<CGroupBox> m_autosizeGroup;
std::unique_ptr<CStaticWidget> m_defRefreshLabel; std::unique_ptr<CStaticWidget> m_defRefreshLabel;

View File

@@ -264,6 +264,10 @@ void CPipeClient::Thread()
HandleSetDisplayMode(msg); HandleSetDisplayMode(msg);
break; break;
case LGPipeMsg::GPUSTATUS:
HandleGPUStatus(msg);
break;
default: default:
DEBUG_ERROR("Unknown message type %d", msg.type); DEBUG_ERROR("Unknown message type %d", msg.type);
break; break;
@@ -300,3 +304,8 @@ void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg)
if (result != DISP_CHANGE_SUCCESSFUL) if (result != DISP_CHANGE_SUCCESSFUL)
DEBUG_ERROR("ChangeDisplaySettingsEx Failed (0x%08x)", result); DEBUG_ERROR("ChangeDisplaySettingsEx Failed (0x%08x)", result);
} }
void CPipeClient::HandleGPUStatus(const LGPipeMsg& msg)
{
// TODO: implement me
}

View File

@@ -49,6 +49,7 @@ private:
void HandleSetCursorPos(const LGPipeMsg& msg); void HandleSetCursorPos(const LGPipeMsg& msg);
void HandleSetDisplayMode(const LGPipeMsg& msg); void HandleSetDisplayMode(const LGPipeMsg& msg);
void HandleGPUStatus(const LGPipeMsg& msg);
public: public:
~CPipeClient() { DeInit(); } ~CPipeClient() { DeInit(); }

View File

@@ -78,6 +78,24 @@ static std::optional<DisplayMode> parseDisplayMode(const std::wstring &str)
return mode; return mode;
} }
std::vector<DisplayMode> CRegistrySettings::getDefaultModes()
{
auto defaultRefresh = getDefaultRefresh();
int refresh = defaultRefresh ? *defaultRefresh : DEFAULT_REFRESH;
std::vector<DisplayMode> result;
for (int i = 0; i < ARRAYSIZE(DefaultDisplayModes); ++i)
{
DisplayMode mode;
mode.width = DefaultDisplayModes[i][0];
mode.height = DefaultDisplayModes[i][1];
mode.refresh = refresh;
mode.preferred = i == DefaultPreferredDisplayMode;
result.emplace_back(mode);
}
return result;
}
std::optional<std::vector<DisplayMode>> CRegistrySettings::getModes() std::optional<std::vector<DisplayMode>> CRegistrySettings::getModes()
{ {
LSTATUS status; LSTATUS status;
@@ -89,19 +107,7 @@ std::optional<std::vector<DisplayMode>> CRegistrySettings::getModes()
case ERROR_SUCCESS: case ERROR_SUCCESS:
break; break;
case ERROR_FILE_NOT_FOUND: case ERROR_FILE_NOT_FOUND:
{ return getDefaultModes();
std::vector<DisplayMode> result;
for (int i = 0; i < ARRAYSIZE(DefaultDisplayModes); ++i)
{
DisplayMode mode;
mode.width = DefaultDisplayModes[i][0];
mode.height = DefaultDisplayModes[i][1];
mode.refresh = DefaultDisplayModes[i][2];
mode.preferred = i == DefaultPreferredDisplayMode;
result.emplace_back(mode);
}
return result;
}
default: default:
DEBUG_ERROR_HR(status, "RegGetValue(Modes) length computation"); DEBUG_ERROR_HR(status, "RegGetValue(Modes) length computation");
return {}; return {};

View File

@@ -44,6 +44,7 @@ public:
LSTATUS open(); LSTATUS open();
bool isOpen() { return !!hKey; } bool isOpen() { return !!hKey; }
std::vector<DisplayMode> getDefaultModes();
std::optional<std::vector<DisplayMode>> getModes(); std::optional<std::vector<DisplayMode>> getModes();
LSTATUS setModes(const std::vector<DisplayMode> &modes); LSTATUS setModes(const std::vector<DisplayMode> &modes);