mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
Show GPU info (if available) in assert
This commit is contained in:
parent
144bb1dd7f
commit
70d48140f0
|
@ -293,6 +293,7 @@ public:
|
||||||
MESSAGE_BOX_TYPE_INFO,
|
MESSAGE_BOX_TYPE_INFO,
|
||||||
};
|
};
|
||||||
virtual void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) = 0;
|
virtual void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) = 0;
|
||||||
|
virtual void GetGPUInfoString(char (&aGPUInfo)[256]) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IGameClient : public IInterface
|
class IGameClient : public IInterface
|
||||||
|
|
|
@ -4631,8 +4631,19 @@ int main(int argc, const char **argv)
|
||||||
char aVersionStr[128];
|
char aVersionStr[128];
|
||||||
if(!os_version_str(aVersionStr, sizeof(aVersionStr)))
|
if(!os_version_str(aVersionStr, sizeof(aVersionStr)))
|
||||||
str_copy(aVersionStr, "unknown");
|
str_copy(aVersionStr, "unknown");
|
||||||
char aMessage[512];
|
char aGPUInfo[256];
|
||||||
str_format(aMessage, sizeof(aMessage), "An assertion error occured. Please write down or take a screenshot of the following information and report this error.\nPlease also share the assert log which you should find in the 'dumps' folder in your config directory.\n\n%s\n\nPlatform: %s\nGame version: %s %s\nOS version: %s", pMsg, CONF_PLATFORM_STRING, GAME_RELEASE_VERSION, GIT_SHORTREV_HASH != nullptr ? GIT_SHORTREV_HASH : "", aVersionStr);
|
pClient->GetGPUInfoString(aGPUInfo);
|
||||||
|
char aMessage[768];
|
||||||
|
str_format(aMessage, sizeof(aMessage),
|
||||||
|
"An assertion error occured. Please write down or take a screenshot of the following information and report this error.\n"
|
||||||
|
"Please also share the assert log which you should find in the 'dumps' folder in your config directory.\n\n"
|
||||||
|
"%s\n\n"
|
||||||
|
"Platform: %s\n"
|
||||||
|
"Game version: %s %s\n"
|
||||||
|
"OS version: %s\n\n"
|
||||||
|
"%s", // GPU info
|
||||||
|
pMsg, CONF_PLATFORM_STRING, GAME_RELEASE_VERSION, GIT_SHORTREV_HASH != nullptr ? GIT_SHORTREV_HASH : "", aVersionStr,
|
||||||
|
aGPUInfo);
|
||||||
pClient->ShowMessageBox("Assertion Error", aMessage);
|
pClient->ShowMessageBox("Assertion Error", aMessage);
|
||||||
// Client will crash due to assertion, don't call PerformAllCleanup in this inconsistent state
|
// Client will crash due to assertion, don't call PerformAllCleanup in this inconsistent state
|
||||||
});
|
});
|
||||||
|
@ -5046,3 +5057,15 @@ void CClient::ShowMessageBox(const char *pTitle, const char *pMessage, EMessageB
|
||||||
if(m_pGraphics == nullptr || !m_pGraphics->ShowMessageBox(GetSdlMessageBoxFlags(Type), pTitle, pMessage))
|
if(m_pGraphics == nullptr || !m_pGraphics->ShowMessageBox(GetSdlMessageBoxFlags(Type), pTitle, pMessage))
|
||||||
SDL_ShowSimpleMessageBox(GetSdlMessageBoxFlags(Type), pTitle, pMessage, nullptr);
|
SDL_ShowSimpleMessageBox(GetSdlMessageBoxFlags(Type), pTitle, pMessage, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClient::GetGPUInfoString(char (&aGPUInfo)[256])
|
||||||
|
{
|
||||||
|
if(m_pGraphics != nullptr && m_pGraphics->IsBackendInitialized())
|
||||||
|
{
|
||||||
|
str_format(aGPUInfo, std::size(aGPUInfo), "GPU: %s - %s - %s", m_pGraphics->GetVendorString(), m_pGraphics->GetRendererString(), m_pGraphics->GetVersionString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str_copy(aGPUInfo, "Graphics backend was not yet initialized.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -553,6 +553,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) override;
|
void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) override;
|
||||||
|
void GetGPUInfoString(char (&aGPUInfo)[256]) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3286,6 +3286,11 @@ bool CGraphics_Threaded::ShowMessageBox(unsigned Type, const char *pTitle, const
|
||||||
return m_pBackend->ShowMessageBox(Type, pTitle, pMsg);
|
return m_pBackend->ShowMessageBox(Type, pTitle, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CGraphics_Threaded::IsBackendInitialized()
|
||||||
|
{
|
||||||
|
return m_pBackend != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const char *CGraphics_Threaded::GetVendorString()
|
const char *CGraphics_Threaded::GetVendorString()
|
||||||
{
|
{
|
||||||
return m_pBackend->GetVendorString();
|
return m_pBackend->GetVendorString();
|
||||||
|
|
|
@ -1300,6 +1300,7 @@ public:
|
||||||
|
|
||||||
SWarning *GetCurWarning() override;
|
SWarning *GetCurWarning() override;
|
||||||
bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) override;
|
bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) override;
|
||||||
|
bool IsBackendInitialized() override;
|
||||||
|
|
||||||
bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) override { return m_pBackend->GetDriverVersion(DriverAgeType, Major, Minor, Patch, pName, BackendType); }
|
bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) override { return m_pBackend->GetDriverVersion(DriverAgeType, Major, Minor, Patch, pName, BackendType); }
|
||||||
bool IsConfigModernAPI() override { return m_pBackend->IsConfigModernAPI(); }
|
bool IsConfigModernAPI() override { return m_pBackend->IsConfigModernAPI(); }
|
||||||
|
|
|
@ -523,6 +523,7 @@ public:
|
||||||
|
|
||||||
// returns true if the error msg was shown
|
// returns true if the error msg was shown
|
||||||
virtual bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) = 0;
|
virtual bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) = 0;
|
||||||
|
virtual bool IsBackendInitialized() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline CTextureHandle CreateTextureHandle(int Index)
|
inline CTextureHandle CreateTextureHandle(int Index)
|
||||||
|
|
Loading…
Reference in a new issue