MCPcopy Create free account
hub / github.com/ConfettiFX/The-Forge / parseGPUConfigurationLine

Function parseGPUConfigurationLine

Common_3/Graphics/GraphicsConfig.cpp:1488–1547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486}
1487
1488void parseGPUConfigurationLine(char* currentLine, uint32_t preferedGpuId)
1489{
1490 char propertyName[MAX_GPU_VENDOR_STRING_LENGTH] = {};
1491 char ruleParameters[MAX_GPU_VENDOR_STRING_LENGTH] = {};
1492 char assignmentValue[MAX_GPU_VENDOR_STRING_LENGTH] = {};
1493
1494 // parse selection rule
1495 size_t ruleLength = strcspn(currentLine, "#");
1496 const char* pLineEnd = currentLine + ruleLength;
1497 GPUConfigurationRule* currentConfigurationRule =
1498 &gGraphicsConfigRules.mGPUConfigurationRules[gGraphicsConfigRules.mGPUConfigurationRulesCount];
1499 *currentConfigurationRule = {};
1500 char* tokens[] = { propertyName, ruleParameters, assignmentValue };
1501 tokenizeLine(currentLine, pLineEnd, ";", MAX_GPU_VENDOR_STRING_LENGTH, TF_ARRAY_COUNT(tokens), tokens);
1502 char* rulesBegin = ruleParameters;
1503 currentConfigurationRule->pUpdateProperty = propertyNameToGpuProperty(stringToLower(propertyName));
1504 if (currentConfigurationRule->pUpdateProperty)
1505 {
1506 // check assignment value
1507 int base = ((strcmp(currentConfigurationRule->pUpdateProperty->name, "vendorid") == 0) ||
1508 (strcmp(currentConfigurationRule->pUpdateProperty->name, "deviceid") == 0))
1509 ? 16
1510 : 10;
1511 bool validConversion = false;
1512 if (strcmp(currentConfigurationRule->pUpdateProperty->name, "gpupresetlevel") == 0)
1513 {
1514 currentConfigurationRule->assignmentValue = stringToPresetLevel(assignmentValue);
1515 validConversion = currentConfigurationRule->assignmentValue != GPU_PRESET_NONE;
1516 ASSERT(validConversion);
1517 }
1518 else
1519 {
1520 validConversion = stringToLargeInteger(assignmentValue, &currentConfigurationRule->assignmentValue, base);
1521 }
1522 // parse comparison rules separated by ","
1523 parseConfigurationRules(&currentConfigurationRule->pConfigurationRules, &currentConfigurationRule->comparisonRulesCount, rulesBegin,
1524 preferedGpuId);
1525 if (currentConfigurationRule->pConfigurationRules == NULL)
1526 {
1527 LOGF(eDEBUG, "parseGPUConfigurationSetting: invalid rules for Field name: '%s'.",
1528 currentConfigurationRule->pUpdateProperty->name);
1529 tf_free(currentConfigurationRule->pConfigurationRules);
1530 }
1531 else if (!validConversion)
1532 {
1533 LOGF(eDEBUG, "parseGPUConfigurationSetting: cannot convert %s for Field name: '%s'.", assignmentValue,
1534 currentConfigurationRule->pUpdateProperty->name);
1535 tf_free(currentConfigurationRule->pConfigurationRules);
1536 }
1537 else
1538 {
1539 gGraphicsConfigRules.mGPUConfigurationRulesCount++;
1540 }
1541 }
1542 else
1543 {
1544 LOGF(eDEBUG, "parseGPUConfigurationSetting: invalid property: '%s'.", propertyName);
1545 tf_free(currentConfigurationRule->pConfigurationRules);

Callers 2

parseGPUConfigFileFunction · 0.85

Calls 7

tokenizeLineFunction · 0.85
stringToLowerFunction · 0.85
stringToPresetLevelFunction · 0.85
stringToLargeIntegerFunction · 0.85
parseConfigurationRulesFunction · 0.85
tf_freeFunction · 0.85

Tested by

no test coverage detected