Skip to content

Commit e96a0bf

Browse files
Param: dx_api
This option tries to figure out the underlying DirectX API being used for the application
1 parent ff6e595 commit e96a0bf

File tree

6 files changed

+63
-42
lines changed

6 files changed

+63
-42
lines changed

src/engine_types.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/hud_elements.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -811,20 +811,7 @@ void HudElements::procmem()
811811
void HudElements::fps(){
812812
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps] && !HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps_only]){
813813
ImguiNextColumnFirstItem();
814-
if (HUDElements.params->fps_text.empty()){
815-
if(HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_engine_short_names])
816-
if(HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_hide_engine_names])
817-
HUDElements.TextColored(HUDElements.colors.engine, "%s", "FPS");
818-
else
819-
HUDElements.TextColored(HUDElements.colors.engine, "%s", engines_short[HUDElements.sw_stats->engine]);
820-
else
821-
if(HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_hide_engine_names])
822-
HUDElements.TextColored(HUDElements.colors.engine, "%s", "FPS");
823-
else
824-
HUDElements.TextColored(HUDElements.colors.engine, "%s", engines[HUDElements.sw_stats->engine]);
825-
} else {
826-
HUDElements.TextColored(HUDElements.colors.engine, "%s", HUDElements.params->fps_text.c_str());
827-
}
814+
HUDElements.TextColored(HUDElements.colors.engine, "%s", engine_name(*HUDElements.sw_stats));
828815

829816
ImguiNextColumnOrNewRow();
830817
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_fps_color_change]){

src/overlay.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ struct benchmark_stats benchmark;
4545
struct fps_limit fps_limit_stats {};
4646
ImVec2 real_font_size;
4747
std::deque<logData> graph_data;
48-
const char* engines[] = {"Unknown", "OpenGL", "VULKAN", "DXVK", "VKD3D", "DAMAVAND", "ZINK", "WINED3D", "Feral3D", "ToGL", "GAMESCOPE"};
49-
const char* engines_short[] = {"Unknown", "OGL", "VK", "DXVK", "VKD3D", "DV", "ZINK", "WD3D", "Feral3D", "ToGL", "GS"};
5048
overlay_params *_params {};
5149
double min_frametime, max_frametime;
5250
bool gpu_metrics_exists = false;

src/overlay.h

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "imgui_internal.h"
1111
#include "overlay_params.h"
1212
#include "hud_elements.h"
13-
#include "engine_types.h"
1413

1514
#include "dbus_info.h"
1615
#include "logging.h"
@@ -21,6 +20,25 @@ struct frame_stat {
2120

2221
static const int kMaxGraphEntries = 50;
2322

23+
enum EngineTypes
24+
{
25+
UNKNOWN,
26+
27+
OPENGL,
28+
VULKAN,
29+
30+
DXVK,
31+
VKD3D,
32+
DAMAVAND,
33+
ZINK,
34+
35+
WINED3D,
36+
FERAL3D,
37+
TOGL,
38+
39+
GAMESCOPE
40+
};
41+
2442
struct swapchain_stats {
2543
uint64_t n_frames;
2644
enum overlay_plots stat_selector;
@@ -38,7 +56,7 @@ struct swapchain_stats {
3856
unsigned n_frames_since_update;
3957
uint64_t last_fps_update;
4058
ImVec2 main_window_pos;
41-
59+
4260
struct {
4361
int32_t major;
4462
int32_t minor;
@@ -54,6 +72,7 @@ struct swapchain_stats {
5472
std::string deviceName;
5573
std::string gpuName;
5674
std::string driverName;
75+
uint32_t applicationVersion;
5776
enum EngineTypes engine;
5877
};
5978

@@ -80,6 +99,39 @@ struct LOAD_DATA {
8099
unsigned high_load;
81100
};
82101

102+
103+
inline const char* engine_name(struct swapchain_stats& sw_stats) {
104+
const char* engines[] = {"Unknown", "OpenGL", "VULKAN", "DXVK", "VKD3D", "DAMAVAND", "ZINK", "WINED3D", "Feral3D", "ToGL", "GAMESCOPE"};
105+
const char* engines_short[] = {"Unknown", "OGL", "VK", "DXVK", "VKD3D", "DV", "ZINK", "WD3D", "Feral3D", "ToGL", "GS"};
106+
auto engine = sw_stats.engine;
107+
auto params = get_params();
108+
auto& enabled = params->enabled;
109+
110+
// if fps_text is set, we ignore all other options
111+
if (!params->fps_text.empty())
112+
return params->fps_text.c_str();
113+
114+
const bool is_compact =
115+
enabled[OVERLAY_PARAM_ENABLED_hud_compact] ||
116+
enabled[OVERLAY_PARAM_ENABLED_horizontal];
117+
118+
const bool short_pref = enabled[OVERLAY_PARAM_ENABLED_engine_short_names];
119+
120+
if (is_compact && !short_pref)
121+
return "FPS";
122+
123+
if (enabled[OVERLAY_PARAM_ENABLED_dx_api]) {
124+
if (engine == EngineTypes::VKD3D) return "DX12";
125+
if (engine == EngineTypes::DXVK) {
126+
if (sw_stats.applicationVersion == 1) return "DX9";
127+
if (sw_stats.applicationVersion == 2) return "DX11";
128+
return "DX?";
129+
}
130+
}
131+
132+
return short_pref || is_compact ? engines_short[engine] : engines[engine];
133+
}
134+
83135
extern struct fps_limit fps_limit_stats;
84136
extern uint32_t deviceID;
85137

src/overlay_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct Tracepoint;
129129
OVERLAY_PARAM_BOOL(gpu_efficiency) \
130130
OVERLAY_PARAM_BOOL(flip_efficiency) \
131131
OVERLAY_PARAM_BOOL(gpu_power_limit) \
132+
OVERLAY_PARAM_BOOL(dx_api) \
132133
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
133134
OVERLAY_PARAM_CUSTOM(output_folder) \
134135
OVERLAY_PARAM_CUSTOM(output_file) \

src/vulkan.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct instance_data {
8282
enum EngineTypes engine;
8383
notify_thread notifier;
8484
int control_client;
85+
uint32_t applicationVersion;
8586
};
8687

8788
/* Mapped from VkDevice */
@@ -1582,6 +1583,7 @@ static VkResult overlay_CreateSwapchainKHR(
15821583
swapchain_data->sw_stats.engineName = device_data->instance->engineName;
15831584
swapchain_data->sw_stats.engineVersion = device_data->instance->engineVersion;
15841585
swapchain_data->sw_stats.engine = device_data->instance->engine;
1586+
swapchain_data->sw_stats.applicationVersion = device_data->instance->applicationVersion;
15851587

15861588
HUDElements.vendorID = prop.vendorID;
15871589
std::stringstream ss;
@@ -1904,8 +1906,12 @@ static VkResult overlay_CreateInstance(
19041906
std::string engineVersion, engineName;
19051907
enum EngineTypes engine = EngineTypes::UNKNOWN;
19061908
const char* pEngineName = nullptr;
1907-
if (pCreateInfo->pApplicationInfo)
1909+
1910+
struct instance_data *instance_data = new_instance_data(*pInstance);
1911+
if (pCreateInfo->pApplicationInfo) {
19081912
pEngineName = pCreateInfo->pApplicationInfo->pEngineName;
1913+
instance_data->applicationVersion = pCreateInfo->pApplicationInfo->applicationVersion;
1914+
}
19091915
if (pEngineName)
19101916
{
19111917
engineName = pEngineName;
@@ -1953,7 +1959,6 @@ static VkResult overlay_CreateInstance(
19531959
VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
19541960
if (result != VK_SUCCESS) return result;
19551961

1956-
struct instance_data *instance_data = new_instance_data(*pInstance);
19571962
vk_load_instance_commands(instance_data->instance,
19581963
fpGetInstanceProcAddr,
19591964
&instance_data->vtable);

0 commit comments

Comments
 (0)