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 */
|
/* Get the config parameters */
|
||||||
new_info->device = config_get_gpu_device(config);
|
new_info->device = config_get_gpu_device(config);
|
||||||
|
|
||||||
/* TODO fill in GPU vendor */
|
|
||||||
new_info->vendor = 0;
|
|
||||||
|
|
||||||
/* verify device ID */
|
/* verify device ID */
|
||||||
if (new_info->device == -1) {
|
if (new_info->device == -1) {
|
||||||
LOG_ERROR(
|
LOG_ERROR(
|
||||||
@ -85,11 +82,29 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
|||||||
return -1;
|
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 */
|
/* verify GPU vendor */
|
||||||
if (!GPUVendorValid(new_info->vendor)) {
|
if (!GPUVendorValid(new_info->vendor)) {
|
||||||
LOG_ERROR(
|
LOG_ERROR("Unknown vendor value (0x%04x) found, cannot apply optimisations!\n",
|
||||||
"Unknown vendor value (0x%04x) found, cannot apply optimisations!\n",
|
(unsigned int)new_info->vendor);
|
||||||
(unsigned int)new_info->vendor);
|
|
||||||
LOG_ERROR("Known values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
|
LOG_ERROR("Known values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
|
||||||
Vendor_NVIDIA,
|
Vendor_NVIDIA,
|
||||||
Vendor_AMD,
|
Vendor_AMD,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user