HLSL: Add back in the [subcomponent] part of a 'register' decl.
This commit is contained in:
@@ -2523,10 +2523,10 @@ void HlslGrammar::acceptArraySpecifier(TArraySizes*& arraySizes)
|
||||
}
|
||||
|
||||
// post_decls
|
||||
// : COLON semantic // optional
|
||||
// COLON PACKOFFSET LEFT_PAREN c[Subcomponent][.component] RIGHT_PAREN // optional
|
||||
// COLON REGISTER LEFT_PAREN [shader_profile,] Type# RIGHT_PAREN // optional
|
||||
// annotations // optional
|
||||
// : COLON semantic // optional
|
||||
// COLON PACKOFFSET LEFT_PAREN c[Subcomponent][.component] RIGHT_PAREN // optional
|
||||
// COLON REGISTER LEFT_PAREN [shader_profile,] Type#[subcomp]opt RIGHT_PAREN // optional
|
||||
// annotations // optional
|
||||
//
|
||||
void HlslGrammar::acceptPostDecls(TType& type)
|
||||
{
|
||||
@@ -2561,31 +2561,45 @@ void HlslGrammar::acceptPostDecls(TType& type)
|
||||
expected("semantic or packoffset or register");
|
||||
return;
|
||||
} else if (*idToken.string == "register") {
|
||||
// REGISTER LEFT_PAREN [shader_profile,] Type# RIGHT_PAREN
|
||||
// REGISTER LEFT_PAREN [shader_profile,] Type#[subcomp]opt RIGHT_PAREN
|
||||
if (! acceptTokenClass(EHTokLeftParen)) {
|
||||
expected("(");
|
||||
return;
|
||||
}
|
||||
HlslToken registerDesc;
|
||||
HlslToken registerDesc; // for Type#
|
||||
HlslToken profile;
|
||||
if (! acceptIdentifier(registerDesc)) {
|
||||
expected("register number description");
|
||||
return;
|
||||
}
|
||||
HlslToken profile;
|
||||
if (acceptTokenClass(EHTokComma)) {
|
||||
// then we didn't really see the registerDesc yet, it was
|
||||
// actually the profile
|
||||
// Then we didn't really see the registerDesc yet, it was
|
||||
// actually the profile. Adjust...
|
||||
profile = registerDesc;
|
||||
if (! acceptIdentifier(registerDesc)) {
|
||||
expected("register number description");
|
||||
return;
|
||||
}
|
||||
}
|
||||
int subComponent = 0;
|
||||
if (acceptTokenClass(EHTokLeftBracket)) {
|
||||
// LEFT_BRACKET subcomponent RIGHT_BRACKET
|
||||
if (! peekTokenClass(EHTokIntConstant)) {
|
||||
expected("literal integer");
|
||||
return;
|
||||
}
|
||||
subComponent = token.i;
|
||||
advanceToken();
|
||||
if (! acceptTokenClass(EHTokRightBracket)) {
|
||||
expected("]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! acceptTokenClass(EHTokRightParen)) {
|
||||
expected(")");
|
||||
break;
|
||||
}
|
||||
parseContext.handleRegister(registerDesc.loc, type, profile.string, *registerDesc.string);
|
||||
parseContext.handleRegister(registerDesc.loc, type, profile.string, *registerDesc.string, subComponent);
|
||||
} else {
|
||||
// semantic, in idToken.string
|
||||
parseContext.handleSemantic(type, *idToken.string);
|
||||
|
||||
@@ -2181,27 +2181,34 @@ void HlslParseContext::handlePackOffset(const TSourceLoc& loc, TType& type, cons
|
||||
// 'desc' is the type# part.
|
||||
//
|
||||
void HlslParseContext::handleRegister(const TSourceLoc& loc, TType& type, const glslang::TString* profile,
|
||||
const glslang::TString& desc)
|
||||
const glslang::TString& desc,
|
||||
int subComponent)
|
||||
{
|
||||
if (profile != nullptr)
|
||||
warn(loc, "ignoring shader_profile", "register", "");
|
||||
|
||||
if (desc.size() < 2) {
|
||||
error(loc, "expected register type and number", "register", "");
|
||||
if (desc.size() < 1) {
|
||||
error(loc, "expected register type", "register", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (! isdigit(desc[1])) {
|
||||
error(loc, "expected register number after register type", "register", "");
|
||||
return;
|
||||
int regNumber = 0;
|
||||
if (desc.size() > 1) {
|
||||
if (isdigit(desc[1]))
|
||||
regNumber = atoi(desc.substr(1, desc.size()).c_str());
|
||||
else {
|
||||
error(loc, "expected register number after register type", "register", "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: learn what all these really mean and how they interact with regNumber and subComponent
|
||||
switch (desc[0]) {
|
||||
case 'b':
|
||||
case 't':
|
||||
case 'c':
|
||||
case 's':
|
||||
type.getQualifier().layoutBinding = atoi(desc.substr(1, desc.size()).c_str());
|
||||
type.getQualifier().layoutBinding = regNumber + subComponent;
|
||||
break;
|
||||
default:
|
||||
warn(loc, "ignoring unrecognized register type", "register", "%c", desc[0]);
|
||||
|
||||
@@ -95,8 +95,10 @@ public:
|
||||
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
|
||||
TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
|
||||
void handleSemantic(TType& type, const TString& semantic);
|
||||
void handlePackOffset(const TSourceLoc&, TType& type, const glslang::TString& location, const glslang::TString* component);
|
||||
void handleRegister(const TSourceLoc&, TType& type, const glslang::TString* profile, const glslang::TString& desc);
|
||||
void handlePackOffset(const TSourceLoc&, TType& type, const glslang::TString& location,
|
||||
const glslang::TString* component);
|
||||
void handleRegister(const TSourceLoc&, TType& type, const glslang::TString* profile, const glslang::TString& desc,
|
||||
int subComponent);
|
||||
|
||||
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user