Display memory stats on the hud

pull/20/head
FlightlessMango 4 years ago committed by jackun
parent 8ab7cd0f20
commit 14ad1e015a
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -3,8 +3,11 @@
#include <cstring>
#include <stdio.h>
#include <iostream>
#include <thread>
struct memory_information mem_info;
pthread_t memoryThread;
float memused, memmax;
FILE *open_file(const char *file, int *reported) {
FILE *fp = nullptr;
@ -22,7 +25,7 @@ FILE *open_file(const char *file, int *reported) {
return fp;
}
void update_meminfo() {
void *update_meminfo(void *) {
FILE *meminfo_fp;
static int reported = 0;
@ -90,7 +93,9 @@ void update_meminfo() {
mem_info.bufmem = curbufmem;
mem_info.memeasyfree = cureasyfree;
std::cout << (float(mem_info.memmax) - float(mem_info.memeasyfree)) / (1024 * 1024) << " / " << float(mem_info.memmax) / (1024 * 1024) << std::endl;
memused = (float(mem_info.memmax) - float(mem_info.memeasyfree)) / (1024 * 1024);
memmax = float(mem_info.memmax) / (1024 * 1024);
fclose(meminfo_fp);
return NULL;
}

@ -1,6 +1,9 @@
#include <stdio.h>
#include <thread>
extern pthread_t memoryThread;
extern float memused, memmax;
struct memory_information {
/* memory information in kilobytes */
unsigned long long mem, memwithbuffers, memeasyfree, memfree, memmax,
@ -9,5 +12,5 @@ struct memory_information {
unsigned long long bufmem, buffers, cached;
};
void update_meminfo(void);
void *update_meminfo(void*);
FILE *open_file(const char *file, int *reported);

@ -976,6 +976,9 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
pthread_create(&gpuThread, NULL, &getAmdGpuUsage, NULL);
}
// get ram usage/max
pthread_create(&memoryThread, NULL, &update_meminfo, NULL);
// update variables for logging
// cpuLoadLog = cpuArray[0].value;
gpuLoadLog = gpuLoad;
@ -1169,6 +1172,9 @@ static void compute_swapchain_display(struct swapchain_data *data)
i++;
}
}
ImGui::TextColored(ImVec4(0.671, 0.251, 0.753, 1.00f), "MEM");
ImGui::SameLine(hudFirstRow);
ImGui::Text("%.1fG/%.1fG", memused, memmax);
if (instance_data->params.enabled[OVERLAY_PARAM_ENABLED_fps]){
ImGui::TextColored(ImVec4(0.925, 0.411, 0.411, 1.00f), "%s", engineName.c_str());
ImGui::SameLine(hudFirstRow);
@ -1189,7 +1195,6 @@ static void compute_swapchain_display(struct swapchain_data *data)
ImGui::PopFont();
}
}
// ImGui::ProgressBar(float(0.5), ImVec2(ImGui::GetContentRegionAvailWidth(), 21), NULL);
ImGui::Dummy(ImVec2(0.0f, 20.0f));

Loading…
Cancel
Save