added adapter name and FPS to the GUI's main menu bar

This commit is contained in:
myT 2024-02-07 02:43:43 +01:00
parent fedfff191e
commit dad7565aa0
3 changed files with 28 additions and 0 deletions

View file

@ -170,6 +170,8 @@ void GUI_DrawMainMenu()
} }
} }
RE_DrawMainMenuBarInfo();
ImGui::EndMainMenuBar(); ImGui::EndMainMenuBar();
} }

View file

@ -1896,3 +1896,28 @@ void R_ShutDownGUI()
ClearShaderReplacements(); ClearShaderReplacements();
ClearImageReplacements(); ClearImageReplacements();
} }
void RE_DrawMainMenuBarInfo()
{
static uint32_t frameTimes[16];
static uint32_t frameCount = 0;
static int displayedFPS = 0;
frameTimes[frameCount++] = rhie.presentToPresentUS;
if(frameCount == ARRAY_LEN(frameTimes))
{
uint32_t sum = 0;
for(uint32_t i = 0; i < ARRAY_LEN(frameTimes); ++i)
{
sum += frameTimes[i];
}
sum /= ARRAY_LEN(frameTimes);
displayedFPS = (int)((1000000 + (sum >> 1)) / sum);
frameCount = 0;
}
const char* const info = va("%s | %3d FPS", rhiInfo.adapter, displayedFPS);
const float offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize("___").x - ImGui::CalcTextSize(info).x;
ImGui::SameLine(offset);
ImGui::Text(info);
}

View file

@ -179,6 +179,7 @@ typedef struct {
qhandle_t RE_NK_CreateFontAtlas( vmIndex_t, byte * outBuf, int outSize, const byte* inBuf, int inSize ); // 1 call per VM at most qhandle_t RE_NK_CreateFontAtlas( vmIndex_t, byte * outBuf, int outSize, const byte* inBuf, int inSize ); // 1 call per VM at most
void RE_UploadNuklear( void* vertexes, int numVertexBytes, void* indexes, int numIndexBytes ); void RE_UploadNuklear( void* vertexes, int numVertexBytes, void* indexes, int numIndexBytes );
void RE_DrawNuklear( int firstIndex, int numIndexes, qhandle_t shader, const int* scissorRect ); void RE_DrawNuklear( int firstIndex, int numIndexes, qhandle_t shader, const int* scissorRect );
void RE_DrawMainMenuBarInfo();
// //
// these are the functions imported by the refresh module // these are the functions imported by the refresh module