mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
Fill in the GPU vendor automatically
This commit is contained in:
parent
0847d3b452
commit
91deffb6b4
@ -73,9 +73,6 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
||||
/* Get the config parameters */
|
||||
new_info->device = config_get_gpu_device(config);
|
||||
|
||||
/* TODO fill in GPU vendor */
|
||||
new_info->vendor = 0;
|
||||
|
||||
/* verify device ID */
|
||||
if (new_info->device == -1) {
|
||||
LOG_ERROR(
|
||||
@ -85,10 +82,28 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Fill in GPU vendor */
|
||||
char path[64] = { 0 };
|
||||
if (snprintf(path, 64, "/sys/class/drm/card%ld/device/vendor", new_info->device) < 0) {
|
||||
LOG_ERROR("snprintf failed, will not apply gpu optimisations!\n");
|
||||
return -1;
|
||||
}
|
||||
FILE *vendor = fopen(path, "r");
|
||||
if (!vendor) {
|
||||
LOG_ERROR("Couldn't open vendor file at %s, will not apply gpu optimisations!\n", path);
|
||||
return -1;
|
||||
}
|
||||
char buff[64];
|
||||
if (fgets(buff, 64, vendor) != NULL) {
|
||||
new_info->vendor = strtol(buff, NULL, 0);
|
||||
} else {
|
||||
LOG_ERROR("Coudn't read contents of file %s, will not apply optimisations!\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify GPU vendor */
|
||||
if (!GPUVendorValid(new_info->vendor)) {
|
||||
LOG_ERROR(
|
||||
"Unknown vendor value (0x%04x) found, cannot apply optimisations!\n",
|
||||
LOG_ERROR("Unknown vendor value (0x%04x) found, cannot apply optimisations!\n",
|
||||
(unsigned int)new_info->vendor);
|
||||
LOG_ERROR("Known values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
|
||||
Vendor_NVIDIA,
|
||||
|
Loading…
x
Reference in New Issue
Block a user