Add -low-power option to allow prevent the gpu to go into a high power mode on amd, useful for replay running 24/7

This commit is contained in:
dec05eba
2026-01-15 20:20:01 +01:00
parent 8af761f9bd
commit f4d061eee7
5 changed files with 32 additions and 9 deletions

View File

@@ -3652,13 +3652,6 @@ int main(int argc, char **argv) {
// If this is set to 1 then cuGraphicsGLRegisterImage will fail for egl context with error: invalid OpenGL or DirectX context,
// so we overwrite it
setenv("__GL_THREADED_OPTIMIZATIONS", "0", true);
// Forces low latency encoding mode. Use this environment variable until vaapi supports setting this as a parameter.
// The downside of this is that it always uses maximum power, which is not ideal for replay mode that runs on system startup.
// This option was added in mesa 24.1.4, released in july 17, 2024.
// TODO: Add an option to enable/disable this?
// Seems like the performance issue is not in encoding, but rendering the frame.
// Some frames end up taking 10 times longer. Seems to be an issue with amd gpu power management when letting the application sleep on the cpu side?
setenv("AMD_DEBUG", "lowlatencyenc", true);
// Some people set this to nvidia (for nvdec) or vdpau (for nvidia vdpau), which breaks gpu screen recorder since
// nvidia doesn't support vaapi and nvidia-vaapi-driver doesn't support encoding yet.
// Let vaapi find the right vaapi driver instead of forcing a specific one.
@@ -3685,6 +3678,15 @@ int main(int argc, char **argv) {
if(!args_parser_parse(&arg_parser, argc, argv, &arg_handlers, NULL))
_exit(1);
if(!arg_parser.low_power) {
// Forces low latency encoding mode. Use this environment variable until vaapi supports setting this as a parameter.
// The downside of this is that it always uses maximum power, which is not ideal for replay mode that runs on system startup.
// This option was added in mesa 24.1.4, released in july 17, 2024.
// Seems like the performance issue is not in encoding, but rendering the frame.
// Some frames end up taking 10 times longer. Seems to be an issue with amd gpu power management when letting the application sleep on the cpu side?
setenv("AMD_DEBUG", "lowlatencyenc", true);
}
std::vector<CaptureSource> capture_sources = parse_capture_source_arg(arg_parser.capture_source, arg_parser);
if(capture_sources.empty()) {
fprintf(stderr, "gsr error: option -w can't be empty. You need to capture video from at least one source\n");