From 9758d2a286670cce49c916ce1f41863ef041fed9 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Sun, 2 Jan 2022 12:04:22 +0100 Subject: [PATCH] Try to get correct amd gpu when multiple --- src/gl/imgui_hud.cpp | 2 +- src/overlay.cpp | 12 ++++++++++-- src/overlay.h | 2 +- src/vulkan.cpp | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gl/imgui_hud.cpp b/src/gl/imgui_hud.cpp index 8ffe64f8..c59e01d4 100644 --- a/src/gl/imgui_hud.cpp +++ b/src/gl/imgui_hud.cpp @@ -135,7 +135,7 @@ void imgui_create(void *ctx) } else { vendorID = 0x10de; } - init_gpu_stats(vendorID, params); + init_gpu_stats(vendorID, 0, params); get_device_name(vendorID, deviceID, sw_stats); // Setup Dear ImGui context IMGUI_CHECKVERSION(); diff --git a/src/overlay.cpp b/src/overlay.cpp index a32e1009..aaecf66e 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -555,7 +555,7 @@ struct pci_bus { int func; }; -void init_gpu_stats(uint32_t& vendorID, overlay_params& params) +void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_params& params) { //if (!params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats]) // return; @@ -618,12 +618,20 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params) string device = path + "/device/device"; if (fp = fopen(device.c_str(), "r")){ fscanf(fp, "%s", str); - deviceID = strtol(str, NULL, 16); + uint32_t temp = strtol(str, NULL, 16); + if (temp != reported_deviceID && deviceID != 0){ + SPDLOG_DEBUG("DeviceID does not match vulkan report {}", reported_deviceID); + continue; + } + deviceID = temp; fclose(fp); } string vendor = path + "/device/vendor"; if (fp = fopen(vendor.c_str(), "r")){ fscanf(fp, "%s", str); + uint32_t temp = strtol(str, NULL, 16); + if (temp != vendorID) + continue; fclose(fp); } string line = str; diff --git a/src/overlay.h b/src/overlay.h index 18b839a2..08745ba9 100644 --- a/src/overlay.h +++ b/src/overlay.h @@ -147,7 +147,7 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID); void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns); void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID); -void init_gpu_stats(uint32_t& vendorID, overlay_params& params); +void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_params& params); void init_cpu_stats(overlay_params& params); void check_keybinds(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID); void init_system_info(void); diff --git a/src/vulkan.cpp b/src/vulkan.cpp index b9187b86..7741302f 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -1795,7 +1795,7 @@ static VkResult overlay_CreateDevice( if (!is_blacklisted()) { device_map_queues(device_data, pCreateInfo); - init_gpu_stats(device_data->properties.vendorID, device_data->instance->params); + init_gpu_stats(device_data->properties.vendorID, device_data->properties.deviceID, device_data->instance->params); } return result;