Disable overclocking if set and gpu supports CUDA_DISABLE_PERF_BOOST

This commit is contained in:
dec05eba
2025-11-08 13:35:30 +01:00
parent 96c62f2db2
commit 9e59f5f5cd
4 changed files with 46 additions and 35 deletions

View File

@@ -58,4 +58,6 @@ vec2i scale_keep_aspect_ratio(vec2i from, vec2i to);
unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal_format, unsigned int format, int filter); unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal_format, unsigned int format, int filter);
bool get_nvidia_driver_version(int *major, int *minor);
#endif /* GSR_UTILS_H */ #endif /* GSR_UTILS_H */

View File

@@ -55,40 +55,6 @@ static uint32_t get_output_id_from_display_name(NVFBC_RANDR_OUTPUT_INFO *outputs
return 0; return 0;
} }
/* TODO: Test with optimus and open kernel modules */
static bool get_driver_version(int *major, int *minor) {
*major = 0;
*minor = 0;
FILE *f = fopen("/proc/driver/nvidia/version", "rb");
if(!f) {
fprintf(stderr, "gsr warning: failed to get nvidia driver version (failed to read /proc/driver/nvidia/version)\n");
return false;
}
char buffer[2048];
size_t bytes_read = fread(buffer, 1, sizeof(buffer) - 1, f);
buffer[bytes_read] = '\0';
bool success = false;
const char *p = strstr(buffer, "Kernel Module");
if(p) {
p += 13;
int driver_major_version = 0, driver_minor_version = 0;
if(sscanf(p, "%d.%d", &driver_major_version, &driver_minor_version) == 2) {
*major = driver_major_version;
*minor = driver_minor_version;
success = true;
}
}
if(!success)
fprintf(stderr, "gsr warning: failed to get nvidia driver version\n");
fclose(f);
return success;
}
static bool version_at_least(int major, int minor, int expected_major, int expected_minor) { static bool version_at_least(int major, int minor, int expected_major, int expected_minor) {
return major > expected_major || (major == expected_major && minor >= expected_minor); return major > expected_major || (major == expected_major && minor >= expected_minor);
} }
@@ -288,7 +254,7 @@ static int gsr_capture_nvfbc_start(gsr_capture *cap, gsr_capture_metadata *captu
self->supports_direct_cursor = false; self->supports_direct_cursor = false;
int driver_major_version = 0; int driver_major_version = 0;
int driver_minor_version = 0; int driver_minor_version = 0;
if(self->params.direct_capture && get_driver_version(&driver_major_version, &driver_minor_version)) { if(self->params.direct_capture && get_nvidia_driver_version(&driver_major_version, &driver_minor_version)) {
fprintf(stderr, "gsr info: detected nvidia version: %d.%d\n", driver_major_version, driver_minor_version); fprintf(stderr, "gsr info: detected nvidia version: %d.%d\n", driver_major_version, driver_minor_version);
// TODO: // TODO:

View File

@@ -3143,6 +3143,15 @@ int main(int argc, char **argv) {
if(!args_parser_parse(&arg_parser, argc, argv, &arg_handlers, NULL)) if(!args_parser_parse(&arg_parser, argc, argv, &arg_handlers, NULL))
_exit(1); _exit(1);
if(arg_parser.overclock) {
int driver_major_version = 0;
int driver_minor_version = 0;
if(get_nvidia_driver_version(&driver_major_version, &driver_minor_version) && (driver_major_version > 580 || (driver_major_version == 580 && driver_minor_version >= 105))) {
fprintf(stderr, "gsr info: overclocking was set by has been forcefully disabled since your gpu supports CUDA_DISABLE_PERF_BOOST to workaround driver issue (overclocking is not needed)\n");
arg_parser.overclock = false;
}
}
//av_log_set_level(AV_LOG_TRACE); //av_log_set_level(AV_LOG_TRACE);
const Arg *audio_input_arg = args_parser_get_arg(&arg_parser, "-a"); const Arg *audio_input_arg = args_parser_get_arg(&arg_parser, "-a");

View File

@@ -606,3 +606,37 @@ unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal
egl->glBindTexture(GL_TEXTURE_2D, 0); egl->glBindTexture(GL_TEXTURE_2D, 0);
return texture_id; return texture_id;
} }
/* TODO: Test with optimus and open kernel modules */
bool get_nvidia_driver_version(int *major, int *minor) {
*major = 0;
*minor = 0;
FILE *f = fopen("/proc/driver/nvidia/version", "rb");
if(!f) {
fprintf(stderr, "gsr warning: failed to get nvidia driver version (failed to read /proc/driver/nvidia/version)\n");
return false;
}
char buffer[2048];
size_t bytes_read = fread(buffer, 1, sizeof(buffer) - 1, f);
buffer[bytes_read] = '\0';
bool success = false;
const char *p = strstr(buffer, "Kernel Module");
if(p) {
p += 13;
int driver_major_version = 0, driver_minor_version = 0;
if(sscanf(p, "%d.%d", &driver_major_version, &driver_minor_version) == 2) {
*major = driver_major_version;
*minor = driver_minor_version;
success = true;
}
}
if(!success)
fprintf(stderr, "gsr warning: failed to get nvidia driver version\n");
fclose(f);
return success;
}