HLSL: Fix #1154: Support PointSize, as an attribute.

This commit is contained in:
John Kessenich
2017-12-06 07:33:36 -07:00
parent b0159f8565
commit cc951f8183
9 changed files with 255 additions and 5 deletions

View File

@@ -60,6 +60,8 @@ namespace glslang {
return EatBinding;
else if (lowername == "global_cbuffer_binding")
return EatGlobalBinding;
else if (lowername == "builtin")
return EatBuiltIn;
} else if (lowernameSpace.size() > 0)
return EatNone;
@@ -177,7 +179,7 @@ namespace glslang {
const TConstUnion* constVal = &attrAgg->getSequence()[argNum]->getAsConstantUnion()->getConstArray()[0];
if (constVal == nullptr || constVal->getType() != basicType)
return nullptr;
return constVal;
}

View File

@@ -66,7 +66,8 @@ namespace glslang {
EatBinding,
EatGlobalBinding,
EatLocation,
EatInputAttachment
EatInputAttachment,
EatBuiltIn
};
}
@@ -84,6 +85,8 @@ namespace glslang {
class TAttributeMap {
public:
int size() const { return (int)attributes.size(); }
// Search for and potentially add the attribute into the map. Return the
// attribute type enum for it, if found, else EatNone.
TAttributeType setAttribute(const TString& nameSpace, const TString* name, TIntermAggregate* value);

View File

@@ -2302,8 +2302,8 @@ bool HlslGrammar::acceptStructBufferType(TType& type)
// : struct_declaration SEMI_COLON struct_declaration SEMI_COLON ...
//
// struct_declaration
// : fully_specified_type struct_declarator COMMA struct_declarator ...
// | fully_specified_type IDENTIFIER function_parameters post_decls compound_statement // member-function definition
// : attributes fully_specified_type struct_declarator COMMA struct_declarator ...
// | attributes fully_specified_type IDENTIFIER function_parameters post_decls compound_statement // member-function definition
//
// struct_declarator
// : IDENTIFIER post_decls
@@ -2322,7 +2322,11 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
break;
// struct_declaration
// attributes
TAttributeMap attributes;
acceptAttributes(attributes);
bool declarator_list = false;
// fully_specified_type
@@ -2332,6 +2336,8 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
return false;
}
parseContext.transferTypeAttributes(attributes, memberType);
// struct_declarator COMMA struct_declarator ...
bool functionDefinitionAccepted = false;
do {

View File

@@ -1854,6 +1854,9 @@ void HlslParseContext::handleEntryPointAttributes(const TSourceLoc& loc, const T
// attributes.
void HlslParseContext::transferTypeAttributes(const TAttributeMap& attributes, TType& type)
{
if (attributes.size() == 0)
return;
// location
int value;
if (attributes.getInt(EatLocation, value))
@@ -1880,6 +1883,13 @@ void HlslParseContext::transferTypeAttributes(const TAttributeMap& attributes, T
// input attachment
if (attributes.getInt(EatInputAttachment, value))
type.getQualifier().layoutAttachment = value;
// PointSize built-in
TString builtInString;
if (attributes.getString(EatBuiltIn, builtInString, 0, false)) {
if (builtInString == "PointSize")
type.getQualifier().builtIn = EbvPointSize;
}
}
//