mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
Rename the core and mem stats to nv_ prefix
These will be NV only going forward, as AMD needs a different chunk of work
This commit is contained in:
parent
cc9f78fe0a
commit
20efaaa33f
@ -116,23 +116,23 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
||||
/* Load the config based on GPU and also verify the values are sane */
|
||||
switch (new_info->vendor) {
|
||||
case Vendor_NVIDIA:
|
||||
new_info->core = config_get_nv_core_clock_mhz_offset(config);
|
||||
new_info->mem = config_get_nv_mem_clock_mhz_offset(config);
|
||||
new_info->nv_core = config_get_nv_core_clock_mhz_offset(config);
|
||||
new_info->nv_mem = config_get_nv_mem_clock_mhz_offset(config);
|
||||
|
||||
/* Reject values over some guessed values
|
||||
* If a user wants to go into very unsafe levels they can recompile
|
||||
*/
|
||||
const int nv_core_hard_limit = 200;
|
||||
const int nv_mem_hard_limit = 2000;
|
||||
if (new_info->core > nv_core_hard_limit || new_info->mem > nv_mem_hard_limit) {
|
||||
if (new_info->nv_core > nv_core_hard_limit || new_info->nv_mem > nv_mem_hard_limit) {
|
||||
LOG_ERROR(
|
||||
"NVIDIA Overclock value above safety levels of +%d (core) +%d (mem), will "
|
||||
"not overclock!\n",
|
||||
nv_core_hard_limit,
|
||||
nv_mem_hard_limit);
|
||||
LOG_ERROR("nv_core_clock_mhz_offset:%ld nv_mem_clock_mhz_offset:%ld\n",
|
||||
new_info->core,
|
||||
new_info->mem);
|
||||
new_info->nv_core,
|
||||
new_info->nv_mem);
|
||||
free(new_info);
|
||||
return -1;
|
||||
}
|
||||
@ -150,20 +150,20 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
||||
|
||||
break;
|
||||
case Vendor_AMD:
|
||||
new_info->core = config_get_amd_core_clock_percentage(config);
|
||||
new_info->mem = config_get_amd_mem_clock_percentage(config);
|
||||
new_info->nv_core = config_get_amd_core_clock_percentage(config);
|
||||
new_info->nv_mem = config_get_amd_mem_clock_percentage(config);
|
||||
|
||||
/* Reject values over 20%
|
||||
* If a user wants to go into very unsafe levels they can recompile
|
||||
* As far as I can tell the driver doesn't allow values over 20 anyway
|
||||
*/
|
||||
const int amd_hard_limit = 20;
|
||||
if (new_info->core > amd_hard_limit || new_info->mem > amd_hard_limit) {
|
||||
if (new_info->nv_core > amd_hard_limit || new_info->nv_mem > amd_hard_limit) {
|
||||
LOG_ERROR("AMD Overclock value above safety level of %d%%, will not overclock!\n",
|
||||
amd_hard_limit);
|
||||
LOG_ERROR("amd_core_clock_percentage:%ld amd_mem_clock_percentage:%ld\n",
|
||||
new_info->core,
|
||||
new_info->mem);
|
||||
new_info->nv_core,
|
||||
new_info->nv_mem);
|
||||
free(new_info);
|
||||
return -1;
|
||||
}
|
||||
@ -199,20 +199,20 @@ int game_mode_apply_gpu(const GameModeGPUInfo *info, bool apply)
|
||||
if (!info)
|
||||
return 0;
|
||||
|
||||
LOG_MSG("Requesting GPU optimisations on device:%ld with settings core:%ld clock:%ld\n",
|
||||
LOG_MSG("Requesting GPU optimisations on device:%ld with settings nv_core:%ld clock:%ld\n",
|
||||
info->device,
|
||||
info->core,
|
||||
info->mem);
|
||||
info->nv_core,
|
||||
info->nv_mem);
|
||||
|
||||
/* Generate the input strings */
|
||||
char vendor[7];
|
||||
snprintf(vendor, 7, "0x%04x", (short)info->vendor);
|
||||
char device[4];
|
||||
snprintf(device, 4, "%ld", info->device);
|
||||
char core[8];
|
||||
snprintf(core, 8, "%ld", info->core);
|
||||
char mem[8];
|
||||
snprintf(mem, 8, "%ld", info->mem);
|
||||
char nv_core[8];
|
||||
snprintf(nv_core, 8, "%ld", info->nv_core);
|
||||
char nv_mem[8];
|
||||
snprintf(nv_mem, 8, "%ld", info->nv_mem);
|
||||
char nv_perf_level[4];
|
||||
snprintf(nv_perf_level, 4, "%ld", info->nv_perf_level);
|
||||
|
||||
@ -223,8 +223,8 @@ int game_mode_apply_gpu(const GameModeGPUInfo *info, bool apply)
|
||||
vendor,
|
||||
device,
|
||||
"set",
|
||||
apply ? core : "0",
|
||||
apply ? mem : "0",
|
||||
apply ? nv_core : "0",
|
||||
apply ? nv_mem : "0",
|
||||
info->vendor == Vendor_NVIDIA ? nv_perf_level : NULL, /* Only use this if Nvidia */
|
||||
NULL,
|
||||
};
|
||||
@ -267,15 +267,15 @@ int game_mode_get_gpu(GameModeGPUInfo *info)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int core = 0;
|
||||
int mem = 0;
|
||||
if (sscanf(buffer, "%i %i", &core, &mem) != 2) {
|
||||
int nv_core = 0;
|
||||
int nv_mem = 0;
|
||||
if (sscanf(buffer, "%i %i", &nv_core, &nv_mem) != 2) {
|
||||
LOG_ERROR("Failed to parse gpuclockctl output: %s\n", buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
info->core = core;
|
||||
info->mem = mem;
|
||||
info->nv_core = nv_core;
|
||||
info->nv_mem = nv_mem;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -442,15 +442,15 @@ int run_gpu_optimisation_tests(struct GameModeConfig *config)
|
||||
}
|
||||
|
||||
/* Grab the expected values */
|
||||
long expected_core = gpuinfo->core;
|
||||
long expected_mem = gpuinfo->mem;
|
||||
long expected_core = gpuinfo->nv_core;
|
||||
long expected_mem = gpuinfo->nv_mem;
|
||||
|
||||
/* Get current stats */
|
||||
game_mode_get_gpu(gpuinfo);
|
||||
long original_core = gpuinfo->core;
|
||||
long original_mem = gpuinfo->mem;
|
||||
long original_core = gpuinfo->nv_core;
|
||||
long original_mem = gpuinfo->nv_mem;
|
||||
|
||||
LOG_MSG("Configured with vendor:0x%04x device:%ld core:%ld mem:%ld (nv_perf_level:%ld)\n",
|
||||
LOG_MSG("Configured with vendor:0x%04x device:%ld nv_core:%ld nv_mem:%ld (nv_perf_level:%ld)\n",
|
||||
(unsigned int)gpuinfo->vendor,
|
||||
gpuinfo->device,
|
||||
expected_core,
|
||||
@ -467,14 +467,14 @@ int run_gpu_optimisation_tests(struct GameModeConfig *config)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpuinfo->core != expected_core || gpuinfo->mem != expected_mem) {
|
||||
if (gpuinfo->nv_core != expected_core || gpuinfo->nv_mem != expected_mem) {
|
||||
LOG_ERROR(
|
||||
"Current GPU clocks during gamemode do not match requested values!\n"
|
||||
"\tcore - expected:%ld was:%ld | mem - expected:%ld was:%ld\n",
|
||||
"\tnv_core - expected:%ld was:%ld | nv_mem - expected:%ld was:%ld\n",
|
||||
expected_core,
|
||||
gpuinfo->core,
|
||||
gpuinfo->nv_core,
|
||||
expected_mem,
|
||||
gpuinfo->mem);
|
||||
gpuinfo->nv_mem);
|
||||
gpustatus = -1;
|
||||
}
|
||||
|
||||
@ -487,14 +487,14 @@ int run_gpu_optimisation_tests(struct GameModeConfig *config)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpuinfo->core != original_core || gpuinfo->mem != original_mem) {
|
||||
if (gpuinfo->nv_core != original_core || gpuinfo->nv_mem != original_mem) {
|
||||
LOG_ERROR(
|
||||
"Current GPU clocks after gamemode do not matcch original values!\n"
|
||||
"\tcore - original:%ld was:%ld | mem - original:%ld was:%ld\n",
|
||||
"\tcore - original:%ld was:%ld | nv_mem - original:%ld was:%ld\n",
|
||||
original_core,
|
||||
gpuinfo->core,
|
||||
gpuinfo->nv_core,
|
||||
original_mem,
|
||||
gpuinfo->mem);
|
||||
gpuinfo->nv_mem);
|
||||
gpustatus = -1;
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ struct GameModeGPUInfo {
|
||||
long vendor;
|
||||
long device; /* path to device, ie. /sys/class/drm/card#/ */
|
||||
|
||||
long core; /* Core clock to apply */
|
||||
long mem; /* Mem clock to apply */
|
||||
long nv_core; /* Core clock to apply */
|
||||
long nv_mem; /* Mem clock to apply */
|
||||
|
||||
long nv_perf_level; /* The Nvidia Performance Level to adjust */
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ static int get_gpu_state_nv(struct GameModeGPUInfo *info)
|
||||
return -1;
|
||||
}
|
||||
|
||||
info->core = strtol(buf, &end, 10);
|
||||
info->nv_core = strtol(buf, &end, 10);
|
||||
if (end == buf) {
|
||||
LOG_ERROR("Failed to parse output for \"%s\" output was \"%s\"!\n", arg, buf);
|
||||
return -1;
|
||||
@ -103,7 +103,7 @@ static int get_gpu_state_nv(struct GameModeGPUInfo *info)
|
||||
return -1;
|
||||
}
|
||||
|
||||
info->mem = strtol(buf, &end, 10);
|
||||
info->nv_mem = strtol(buf, &end, 10);
|
||||
if (end == buf) {
|
||||
LOG_ERROR("Failed to parse output for \"%s\" output was \"%s\"!\n", arg, buf);
|
||||
return -1;
|
||||
@ -143,7 +143,7 @@ static int set_gpu_state_nv(struct GameModeGPUInfo *info)
|
||||
info->device,
|
||||
NV_CORE_OFFSET_ATTRIBUTE,
|
||||
info->nv_perf_level,
|
||||
info->core);
|
||||
info->nv_core);
|
||||
const char *exec_args_core[] = { "/usr/bin/nvidia-settings", "-a", core_arg, NULL };
|
||||
if (run_external_process(exec_args_core, NULL, -1) != 0) {
|
||||
LOG_ERROR("Failed to set %s!\n", core_arg);
|
||||
@ -158,7 +158,7 @@ static int set_gpu_state_nv(struct GameModeGPUInfo *info)
|
||||
info->device,
|
||||
NV_MEM_OFFSET_ATTRIBUTE,
|
||||
info->nv_perf_level,
|
||||
info->mem);
|
||||
info->nv_mem);
|
||||
const char *exec_args_mem[] = { "/usr/bin/nvidia-settings", "-a", mem_arg, NULL };
|
||||
if (run_external_process(exec_args_mem, NULL, -1) != 0) {
|
||||
LOG_ERROR("Failed to set %s!\n", mem_arg);
|
||||
@ -212,10 +212,10 @@ static int set_gpu_state_amd(struct GameModeGPUInfo *info)
|
||||
print_usage_and_exit();
|
||||
}
|
||||
|
||||
// Set the the core and mem clock speeds using the OverDrive files
|
||||
if (set_gpu_state_amd_file("pp_sclk_od", info->device, info->core) != 0)
|
||||
// Set the the nv_core and nv_mem clock speeds using the OverDrive files
|
||||
if (set_gpu_state_amd_file("pp_sclk_od", info->device, info->nv_core) != 0)
|
||||
return -1;
|
||||
if (set_gpu_state_amd_file("pp_mclk_od", info->device, info->mem) != 0)
|
||||
if (set_gpu_state_amd_file("pp_mclk_od", info->device, info->nv_mem) != 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -245,7 +245,7 @@ static long get_device(const char *val)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Helper to get and verify core and mem value */
|
||||
/* Helper to get and verify nv_core and nv_mem value */
|
||||
static long get_generic_value(const char *val)
|
||||
{
|
||||
char *end;
|
||||
@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|
||||
printf("Currently unsupported GPU vendor 0x%04x, doing nothing!\n", (short)info.vendor);
|
||||
break;
|
||||
}
|
||||
printf("%ld %ld\n", info.core, info.mem);
|
||||
printf("%ld %ld\n", info.nv_core, info.nv_mem);
|
||||
|
||||
} else if (argc >= 6 && argc <= 7 && strncmp(argv[3], "set", 3) == 0) {
|
||||
/* Get and verify the vendor and device */
|
||||
@ -295,15 +295,15 @@ int main(int argc, char *argv[])
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.vendor = get_vendor(argv[1]);
|
||||
info.device = get_device(argv[2]);
|
||||
info.core = get_generic_value(argv[4]);
|
||||
info.mem = get_generic_value(argv[5]);
|
||||
info.nv_core = get_generic_value(argv[4]);
|
||||
info.nv_mem = get_generic_value(argv[5]);
|
||||
|
||||
if (info.vendor == Vendor_NVIDIA && argc > 6)
|
||||
info.nv_perf_level = get_generic_value(argv[6]);
|
||||
|
||||
printf("gpuclockctl setting core:%ld mem:%ld on device:%ld with vendor 0x%04x\n",
|
||||
info.core,
|
||||
info.mem,
|
||||
printf("gpuclockctl setting nv_core:%ld nv_mem:%ld on device:%ld with vendor 0x%04x\n",
|
||||
info.nv_core,
|
||||
info.nv_mem,
|
||||
info.device,
|
||||
(unsigned short)info.vendor);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user