Fix crash with --resource-set-binding [n] (common set form, not per-register form)
--resource-set-binding has a mode which allows per-register assignments of bindings and descriptor sets on the command line, and another accepting a single descriptor set value to assign to all variables. The former worked, but the latter would crash when assigning the values. This fixes it, and makes the former case a bit more robust against premature termination of the pre-register values, which must come in (regname,set,binding) triples. This also allows the form "--resource-set-binding stage setnum", which was mentioned in the usage message, but did not parse. The operation of the per-register form of this option is unchanged.
This commit is contained in:
@@ -5370,7 +5370,7 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi
|
||||
}
|
||||
|
||||
// TODO: learn what all these really mean and how they interact with regNumber and subComponent
|
||||
std::vector<std::string> resourceInfo = intermediate.getResourceSetBinding();
|
||||
const std::vector<std::string>& resourceInfo = intermediate.getResourceSetBinding();
|
||||
switch (std::tolower(desc[0])) {
|
||||
case 'b':
|
||||
case 't':
|
||||
@@ -5378,11 +5378,17 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi
|
||||
case 's':
|
||||
case 'u':
|
||||
qualifier.layoutBinding = regNumber + subComponent;
|
||||
for (auto it = resourceInfo.cbegin(); it != resourceInfo.cend(); it = it + 3) {
|
||||
if (strcmp(desc.c_str(), it[0].c_str()) == 0) {
|
||||
qualifier.layoutSet = atoi(it[1].c_str());
|
||||
qualifier.layoutBinding = atoi(it[2].c_str()) + subComponent;
|
||||
break;
|
||||
|
||||
// This handles per-register layout sets numbers. For the global mode which sets
|
||||
// every symbol to the same value, see setLinkageLayoutSets().
|
||||
if ((resourceInfo.size() % 3) == 0) {
|
||||
// Apply per-symbol resource set and binding.
|
||||
for (auto it = resourceInfo.cbegin(); it != resourceInfo.cend(); it = it + 3) {
|
||||
if (strcmp(desc.c_str(), it[0].c_str()) == 0) {
|
||||
qualifier.layoutSet = atoi(it[1].c_str());
|
||||
qualifier.layoutBinding = atoi(it[2].c_str()) + subComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user