mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Print GPU info into console
This commit is contained in:
parent
7e682b1c39
commit
c23f1e51be
|
@ -3785,6 +3785,13 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
|
|||
// check what this context can do
|
||||
const char *pVersionString = (const char *)glGetString(GL_VERSION);
|
||||
dbg_msg("opengl", "Version string: %s", pVersionString);
|
||||
|
||||
const char *pRendererString = (const char *)glGetString(GL_RENDERER);
|
||||
|
||||
str_copy(pCommand->m_pVendorString, pVendorString, gs_GPUInfoStringSize);
|
||||
str_copy(pCommand->m_pVersionString, pVersionString, gs_GPUInfoStringSize);
|
||||
str_copy(pCommand->m_pRendererString, pRendererString, gs_GPUInfoStringSize);
|
||||
|
||||
// parse version string
|
||||
ParseVersionString(pVersionString, pCommand->m_pCapabilities->m_ContextMajor, pCommand->m_pCapabilities->m_ContextMinor, pCommand->m_pCapabilities->m_ContextPatch);
|
||||
|
||||
|
@ -4614,6 +4621,9 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
CmdSDL.m_GlewPatch = GlewPatch;
|
||||
CmdSDL.m_pInitError = &InitError;
|
||||
CmdSDL.m_pErrStringPtr = &pErrorStr;
|
||||
CmdSDL.m_pVendorString = m_aVendorString;
|
||||
CmdSDL.m_pVersionString = m_aVersionString;
|
||||
CmdSDL.m_pRendererString = m_aRendererString;
|
||||
CmdBuffer.AddCommand(CmdSDL);
|
||||
RunBuffer(&CmdBuffer);
|
||||
WaitForIdle();
|
||||
|
|
|
@ -433,6 +433,10 @@ public:
|
|||
|
||||
int *m_pInitError;
|
||||
|
||||
char *m_pVendorString;
|
||||
char *m_pVersionString;
|
||||
char *m_pRendererString;
|
||||
|
||||
int m_RequestedMajor;
|
||||
int m_RequestedMinor;
|
||||
int m_RequestedPatch;
|
||||
|
@ -486,6 +490,8 @@ public:
|
|||
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
||||
};
|
||||
|
||||
static constexpr size_t gs_GPUInfoStringSize = 256;
|
||||
|
||||
// graphics backend implemented with SDL and OpenGL
|
||||
class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
||||
{
|
||||
|
@ -497,6 +503,10 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
|||
|
||||
SBackendCapabilites m_Capabilites;
|
||||
|
||||
char m_aVendorString[gs_GPUInfoStringSize] = {};
|
||||
char m_aVersionString[gs_GPUInfoStringSize] = {};
|
||||
char m_aRendererString[gs_GPUInfoStringSize] = {};
|
||||
|
||||
bool m_UseNewOpenGL;
|
||||
|
||||
char m_aErrorString[256];
|
||||
|
@ -536,6 +546,21 @@ public:
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual const char *GetVendorString()
|
||||
{
|
||||
return m_aVendorString;
|
||||
}
|
||||
|
||||
virtual const char *GetVersionString()
|
||||
{
|
||||
return m_aVersionString;
|
||||
}
|
||||
|
||||
virtual const char *GetRendererString()
|
||||
{
|
||||
return m_aRendererString;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ENGINE_CLIENT_BACKEND_SDL_H
|
||||
|
|
|
@ -2388,6 +2388,19 @@ int CGraphics_Threaded::Init()
|
|||
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff};
|
||||
|
||||
m_InvalidTexture = LoadTextureRaw(4, 4, CImageInfo::FORMAT_RGBA, s_aNullTextureData, CImageInfo::FORMAT_RGBA, TEXLOAD_NORESAMPLE);
|
||||
|
||||
ColorRGBA GPUInfoPrintColor{0.6f, 0.5f, 1.0f, 1.0f};
|
||||
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "GPU vendor: %s", GetVendorString());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gfx", aBuf, GPUInfoPrintColor);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "GPU renderer: %s", GetRendererString());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gfx", aBuf, GPUInfoPrintColor);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "GPU version: %s", GetVersionString());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gfx", aBuf, GPUInfoPrintColor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2591,6 +2604,21 @@ SWarning *CGraphics_Threaded::GetCurWarning()
|
|||
}
|
||||
}
|
||||
|
||||
const char *CGraphics_Threaded::GetVendorString()
|
||||
{
|
||||
return m_pBackend->GetVendorString();
|
||||
}
|
||||
|
||||
const char *CGraphics_Threaded::GetVersionString()
|
||||
{
|
||||
return m_pBackend->GetVersionString();
|
||||
}
|
||||
|
||||
const char *CGraphics_Threaded::GetRendererString()
|
||||
{
|
||||
return m_pBackend->GetRendererString();
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen)
|
||||
{
|
||||
if(g_Config.m_GfxDisplayAllModes)
|
||||
|
|
|
@ -675,6 +675,10 @@ public:
|
|||
virtual bool HasQuadContainerBuffering() { return false; }
|
||||
virtual bool Has2DTextureArrays() { return false; }
|
||||
virtual const char *GetErrorString() { return NULL; }
|
||||
|
||||
virtual const char *GetVendorString() = 0;
|
||||
virtual const char *GetVersionString() = 0;
|
||||
virtual const char *GetRendererString() = 0;
|
||||
};
|
||||
|
||||
class CGraphics_Threaded : public IEngineGraphics
|
||||
|
@ -1150,6 +1154,10 @@ public:
|
|||
bool IsTextBufferingEnabled() override { return m_OpenGLTextBufferingEnabled; }
|
||||
bool IsQuadContainerBufferingEnabled() override { return m_OpenGLQuadContainerBufferingEnabled; }
|
||||
bool HasTextureArrays() override { return m_OpenGLHasTextureArrays; }
|
||||
|
||||
const char *GetVendorString() override;
|
||||
const char *GetVersionString() override;
|
||||
const char *GetRendererString() override;
|
||||
};
|
||||
|
||||
extern IGraphicsBackend *CreateGraphicsBackend();
|
||||
|
|
|
@ -276,6 +276,10 @@ public:
|
|||
virtual bool IsQuadContainerBufferingEnabled() = 0;
|
||||
virtual bool HasTextureArrays() = 0;
|
||||
|
||||
virtual const char *GetVendorString() = 0;
|
||||
virtual const char *GetVersionString() = 0;
|
||||
virtual const char *GetRendererString() = 0;
|
||||
|
||||
struct CLineItem
|
||||
{
|
||||
float m_X0, m_Y0, m_X1, m_Y1;
|
||||
|
|
Loading…
Reference in a new issue