Skip to content

Commit

Permalink
don't rely on std in engine detection
Browse files Browse the repository at this point in the history
  • Loading branch information
flightlessmango committed Jun 16, 2021
1 parent 5f54a9c commit 7ddf1f2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/gl/imgui_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ void imgui_init()
for (auto& item : params.blacklist) {
add_blacklist(item);
}
auto pid = getpid();
string find_wined3d = "lsof -w -lnPX -L -p " + to_string(pid) + " | grep -oh wined3d";
string ret_wined3d = exec(find_wined3d);
if (ret_wined3d == "wined3d\n" )
sw_stats.engineName = "WineD3D";
else
sw_stats.engineName = "OpenGL";
if (engineName == "ZINK")
sw_stats.engineName = engineName;
if (engine != EngineTypes::ZINK){
auto pid = getpid();
string find_wined3d = "lsof -w -lnPX -L -p " + to_string(pid) + " | grep -oh wined3d";
string ret_wined3d = exec(find_wined3d);
if (ret_wined3d == "wined3d\n" )
engine = EngineTypes::WINED3D;
else
engine = EngineTypes::OpenGL;
}
is_blacklisted(true);
notifier.params = &params;
start_notifier(notifier);
Expand Down
2 changes: 1 addition & 1 deletion src/hud_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void HudElements::ram(){
void HudElements::fps(){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps]){
ImGui::TableNextRow(); ImGui::TableNextColumn();
ImGui::TextColored(HUDElements.colors.engine, "%s", HUDElements.sw_stats->engineName.c_str());
ImGui::TextColored(HUDElements.colors.engine, "%s", engines[engine]);
ImGui::TableNextColumn();
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps_color_change]){
int fps = int(HUDElements.sw_stats->fps);
Expand Down
4 changes: 3 additions & 1 deletion src/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct benchmark_stats benchmark;
struct fps_limit fps_limit_stats {};
ImVec2 real_font_size;
std::vector<logData> graph_data;
const char* engines[] = {"OpenGL", "VULKAN", "DXVK", "VKD3D", "DAMAVAND", "ZINK", "WINED3D", "Feral3D"};
int engine;

void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID)
{
Expand Down Expand Up @@ -86,7 +88,7 @@ void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& pa
sw_stats.frames_stats[f_idx].stats[OVERLAY_PLOTS_frame_timing] =
now - sw_stats.last_present_time;
}

frametime = (now - sw_stats.last_present_time) / 1000;
if (elapsed >= params.fps_sampling_period) {
std::thread(update_hw_info, std::ref(sw_stats), std::ref(params), vendorID).detach();
Expand Down
18 changes: 17 additions & 1 deletion src/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,30 @@ struct LOAD_DATA {
unsigned high_load;
};

enum EngineTypes
{
OpenGL,
Vulkan,

DXVK,
VKD3D,
DAMAVAND,
ZINK,

WINED3D,
Feral3D
};

extern const char* engines[];
extern int engine;

extern struct fps_limit fps_limit_stats;
extern int32_t deviceID;

extern struct benchmark_stats benchmark;
extern ImVec2 real_font_size;
extern std::string wineVersion;
extern std::vector<logData> graph_data;
extern string engineName;

void position_layer(struct swapchain_stats& data, struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
Expand Down
16 changes: 13 additions & 3 deletions src/vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2150,13 +2150,23 @@ static VkResult overlay_CreateInstance(
}

if (engineName != "DXVK" && engineName != "vkd3d" && engineName != "Feral3D" && engineName != "Damavand" && engineName != "mesa zink")
engineName = "VULKAN";
engine = EngineTypes::Vulkan;

if (engineName == "DXVK")
engine = EngineTypes::DXVK;

if (engineName == "vkd3d")
engineName = "VKD3D";
engine = EngineTypes::VKD3D;

if (engineName == "mesa zink")
engineName = "ZINK";
engine = EngineTypes::ZINK;

if (engineName == "Damavand")
engine = EngineTypes::DAMAVAND;

if (engineName == "Feral3D")
engine = EngineTypes::Feral3D;

}

assert(chain_info->u.pLayerInfo);
Expand Down

0 comments on commit 7ddf1f2

Please sign in to comment.