Add GPU Info to Crash Handler

I'm sure there's a better way to do this, but I also shouldn't be allowed to touch any cpp code.

This loops through all dxgi adapters based on example code I ripped from Microsoft and StackOverflow and dumps that into the crash log.

I'm hoping it doesn't make the window too tall, so if there's a better way to list only the display adapters that are unique, I'm all for it.
This commit is contained in:
Robert Baker 2026-02-07 20:58:55 -08:00
parent 2b347eaff9
commit 73447f205d
No known key found for this signature in database
GPG key ID: F98889FF6167EE90

View file

@ -28,6 +28,9 @@
#include <ShObjIdl.h>
#include <shlobj_core.h>
#include <dxgi.h>
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
@ -470,6 +473,37 @@ void open_folder_and_select_items(HWND hwndOpener, const std::wstring& path) {
ILFree(piid);
}
std::vector <IDXGIAdapter1*> EnumerateAdapters(void)
{
IDXGIAdapter1* pAdapter;
std::vector <IDXGIAdapter1*> vAdapters;
IDXGIFactory1* pFactory = NULL;
// Create a DXGIFactory object.
if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory)))
{
return vAdapters;
}
for (UINT i = 0;
pFactory->EnumAdapters1(i, &pAdapter) != DXGI_ERROR_NOT_FOUND;
++i)
{
vAdapters.push_back(pAdapter);
}
if (pFactory)
{
pFactory->Release();
}
return vAdapters;
}
void export_tspack(HWND hWndParent, const std::filesystem::path& logDir, const std::string& crashLog, const std::string& troubleshootingPackData) {
static const char* SourceLogFiles[] = {
"output.log", // XIVLauncher for Windows
@ -1022,6 +1056,27 @@ int main() {
log << std::format(L"System Time: {0:%F} {0:%T} {0:%Ez}", std::chrono::system_clock::now()) << std::endl;
log << std::format(L"CPU Vendor: {}", vendor) << std::endl;
log << std::format(L"CPU Brand: {}", brand) << std::endl;
std::vector <IDXGIAdapter1*> availableAdapters = EnumerateAdapters();
for (int i = 0; i < availableAdapters.size(); i++) {
auto& myAdapter = *availableAdapters[i];
auto adapterDescription = DXGI_ADAPTER_DESC1();
myAdapter.GetDesc1(&adapterDescription);
// Print description to console here
log << std::format(L"GPU Desc: {}", adapterDescription.Description) << std::endl;
}
/*
for_each(availableAdapters.begin(), availableAdapters.end(), [](IDXGIAdapter1* adapter, , std::wostream log) {
auto& myAdapter = *adapter;
auto adapterDescription = DXGI_ADAPTER_DESC1();
myAdapter.GetDesc1(&adapterDescription);
// Print description to console here
log << std::format(L"GPU Desc: {}", adapterDescription.Description) << std::endl;
});
*/
log << L"\n" << stackTrace << std::endl;
if (pProgressDialog)