ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.21k stars 174 forks source link

Support GALLIUM_HUD in Steam overlay for users of OSS graphics #4150

Open boombatower opened 8 years ago

boombatower commented 8 years ago

Given the addition of the FPS counter to the Steam overlay it is clear such information is highly desired probably more so on Linux which has not seen as much development of game related tools. The open source openGL implementation provided by Mesa provides a hud that presents useful performance information. The hud can be controlled using the environment variable GALLIUM_HUD (see http://www.mesa3d.org/envvars.html). I developed a patch to allow the hud to be toggle on and off at runtime which makes it more suitable for general use.

By providing a simple toggle in the UI, just like the existing FPS counter, the more advanced GALLIUM_HUD could be utilized. An expert field could allow for control of what is placed in the variable with a default of something simple like just fps. Since the Steam overlay is already aware of the game proccess ID it should be relatively simple to send a signal to the process (as Steam can also control the environment variable that determine which signal is attached).

An example of a more detailed HUD listening for SIGUSR1:

# export GALLIUM_HUD=fps
export GALLIUM_HUD="fps,cpu,GPU-load,VRAM-usage,draw-calls"
export GALLIUM_HUD_VISIBLE=false
export GALLIUM_HUD_TOGGLE_SIGNAL=10

This can be added to the top hl2.sh for Valve games.

A keyboard shortcut can be configured to toggle by issuing the following command.

kill -10 $(xprop -id `xdotool getwindowfocus` | grep '_NET_WM_PID' | grep -oE '[[:digit:]]*$')

Granted the above command only works in an X environment, but that generally works prior to Steam supporting. Steam would not require such a roundabout approach.

Note that the toggle feature is only present in Mesa 11.1.0-rc1 and beyond so Steam should check for such versions.

For a quick demo of hud:

GALLIUM_HUD=fps glxgears

I created a video demonstration: https://www.youtube.com/watch?v=6RUE9rOvDEw.

JoshuaMurphynz commented 8 years ago

What advantage does this have over the native FPS counter in the steam client?

boombatower commented 8 years ago
  1. It can show much much more than just FPS.
  2. It's a graph so you don't have to squint at it the whole time to see fps drops. Just look up at the graph once in a while.
  3. It's actually native since it is built into driver.
boombatower commented 7 years ago

To be honest, having some sort of environment variable configuration either globally for all games, filter, or single games to alleviate having to re-edit launch script after game update would be a great step forward.

Tele42 commented 7 years ago

For what it's worth, I've been using the gallium hud with the per-game launch options in steam like passing any other env variable to a game: GALLIUM_HUD="fps" %command%

I'm lazy, so I only remove one % to break the pattern matching when I'm not doing a general profile.

boombatower commented 7 years ago

Even though I've used %command% elsewhere it hadn't occurred to me to use it for this. I am glad I commented and got your response. Example for others with standard launch options mixed in.

GALLIUM_HUD="fps,cpu,GPU-load,VRAM-usage,draw-calls" GALLIUM_HUD_VISIBLE=false GALLIUM_HUD_TOGGLE_SIGNAL=10 %command% -console
papajo-r commented 6 years ago

Is there an other way to inject these commands to a steam game? because other than the default valve games and a few more many games on steam dont start using an sh file/dont have one especially games that start with a launcher

grmat commented 6 years ago

@papajo-r as a last resort, you could run steam itself with the environment variables set. They will get passed on to the games that steam launches.

@gdrewb-valve is there any update on this? It has been reviewed 2.5 years ago.

SteveHeist commented 5 years ago

I know I'm a few months late @grmat - but GALLIUM_HUD is now supported as a Launch Option (dunno when it happened, just know it works). This goes for Native OpenGL titles like CSGO, Proton-enabled OpenGL titles like DOOM 2016 (of course, in OpenGL mode), and games being translated from DirectX to OpenGL by Proton, such as Call of Duty: World at War.

Simply put GALLIUM_HUD=[options] %command%.

boombatower commented 5 years ago

This worked when I originally posted 3 years ago...and is what I wrote.

grmat commented 5 years ago

@SteveHeist yeah, I know that it works. The request was about adding options to Steam HUD UI settings, so users won't have to configure environment variables per-game and e.g. could set a global shortcut to toggle GALLIUM_HUD for all steam games instead. But anyway, thanks for trying to help.

SteveHeist commented 5 years ago

Yeah, that would be nice :P

Also, sorry boomba - I misinterpreted it as you having had to make a bash script and pass that along as opposed to just putting the line in Launch Options. My bad.