Make `get_device_name` return GPU name

pull/703/head
jackun 2 years ago
parent c88ef84bf5
commit 8e21b52acf
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -7,6 +7,7 @@
#include <memory>
#include <unistd.h>
#include <filesystem.h>
#include <spdlog/spdlog.h>
#include <imgui.h>
#include "font_default.h"
#include "cpu.h"
@ -128,6 +129,7 @@ void imgui_create(void *ctx)
sw_stats.version_gl.is_gles);
deviceName = (char*)glGetString(GL_RENDERER);
SPDLOG_DEBUG("deviceName: {}", deviceName);
sw_stats.deviceName = deviceName;
if (deviceName.find("Radeon") != std::string::npos
|| deviceName.find("AMD") != std::string::npos){
@ -136,7 +138,8 @@ void imgui_create(void *ctx)
vendorID = 0x10de;
}
init_gpu_stats(vendorID, 0, params);
get_device_name(vendorID, deviceID, sw_stats);
sw_stats.gpuName = gpu = get_device_name(vendorID, deviceID);
SPDLOG_DEBUG("gpu: {}", gpu);
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGuiContext *saved_ctx = ImGui::GetCurrentContext();

@ -786,19 +786,19 @@ void init_system_info(){
SPDLOG_DEBUG("Cpu:{}", cpu);
SPDLOG_DEBUG("Kernel:{}", kernel);
SPDLOG_DEBUG("Os:{}", os);
SPDLOG_DEBUG("Gpu:{}", gpu);
SPDLOG_DEBUG("Driver:{}", driver);
SPDLOG_DEBUG("CPU Scheduler:{}", cpusched);
#endif
}
void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats& sw_stats)
std::string get_device_name(int32_t vendorID, int32_t deviceID)
{
string desc;
#ifdef __linux__
if (pci_ids.find(vendorID) == pci_ids.end())
parse_pciids();
string desc = pci_ids[vendorID].second[deviceID].desc;
desc = pci_ids[vendorID].second[deviceID].desc;
size_t position = desc.find("[");
if (position != std::string::npos) {
desc = desc.substr(position);
@ -806,7 +806,7 @@ void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats&
for (char c: chars)
desc.erase(remove(desc.begin(), desc.end(), c), desc.end());
}
gpu = sw_stats.gpuName = desc;
trim(sw_stats.gpuName); trim(gpu);
trim(desc);
#endif
return desc;
}

@ -158,7 +158,7 @@ void init_cpu_stats(overlay_params& params);
void check_keybinds(overlay_params& params, uint32_t vendorID);
void init_system_info(void);
void FpsLimiter(struct fps_limit& stats);
void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats& sw_stats);
std::string get_device_name(int32_t vendorID, int32_t deviceID);
void calculate_benchmark_data(overlay_params* params);
void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font);
void right_aligned_text(ImVec4& col, float off_x, const char *fmt, ...);

@ -1516,7 +1516,7 @@ static VkResult overlay_CreateSwapchainKHR(
std::string deviceName = prop.deviceName;
if (!is_blacklisted()) {
#ifdef __linux__
get_device_name(prop.vendorID, prop.deviceID, swapchain_data->sw_stats);
swapchain_data->sw_stats.gpuName = get_device_name(prop.vendorID, prop.deviceID);
#endif
}
swapchain_data->sw_stats.driverName = driverProps.driverInfo;
@ -1797,6 +1797,10 @@ static VkResult overlay_CreateDevice(
if (!is_blacklisted()) {
device_map_queues(device_data, pCreateInfo);
#ifdef __linux__
gpu = get_device_name(device_data->properties.vendorID, device_data->properties.deviceID);
SPDLOG_DEBUG("gpu: {}", gpu);
#endif
init_gpu_stats(device_data->properties.vendorID, device_data->properties.deviceID, device_data->instance->params);
}

Loading…
Cancel
Save