HLSL: Additional attribute support: [[]], namespace, parameters:

- support C++11 style brackets [[...]]
- support namespaces [[vk::...]]
- support these on parameter declarations in functions
- support location, binding/set, input attachments
This commit is contained in:
John Kessenich 2017-09-30 14:34:50 -06:00
parent 3693e631f5
commit 77ea30bdc9
8 changed files with 310 additions and 16 deletions

View file

@ -40,11 +40,27 @@
namespace glslang {
// Map the given string to an attribute enum from TAttributeType,
// or EatNone if invalid.
TAttributeType TAttributeMap::attributeFromName(const TString& name)
TAttributeType TAttributeMap::attributeFromName(const TString& nameSpace, const TString& name)
{
// These are case insensitive.
TString lowername(name);
std::transform(lowername.begin(), lowername.end(), lowername.begin(), ::tolower);
TString lowernameSpace(nameSpace);
std::transform(lowernameSpace.begin(), lowernameSpace.end(), lowernameSpace.begin(), ::tolower);
// handle names within a namespace
if (lowernameSpace == "vk") {
if (lowername == "input_attachment_index")
return EatInputAttachment;
else if (lowername == "location")
return EatLocation;
else if (lowername == "binding")
return EatBinding;
} else if (lowernameSpace.size() > 0)
return EatNone;
// handle names with no namespace
if (lowername == "allow_uav_condition")
return EatAllow_uav_condition;
@ -88,12 +104,12 @@ namespace glslang {
// Look up entry, inserting if it's not there, and if name is a valid attribute name
// as known by attributeFromName.
TAttributeType TAttributeMap::setAttribute(const TString* name, TIntermAggregate* value)
TAttributeType TAttributeMap::setAttribute(const TString& nameSpace, const TString* name, TIntermAggregate* value)
{
if (name == nullptr)
return EatNone;
const TAttributeType attr = attributeFromName(*name);
const TAttributeType attr = attributeFromName(nameSpace, *name);
if (attr != EatNone)
attributes[attr] = value;