diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-11 09:41:10 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-11 09:41:10 -0500 |
| commit | 1c969b9a85e2e6d6981a31bb758647fc61cf6482 (patch) | |
| tree | 1c5df51b207c43198f360d353108666ab234cc4b /source/slang/parser.cpp | |
| parent | 9f8a92e468a626abf82d08a730e009321595da07 (diff) | |
[[vk::shader_record]] (#836)
* * Replaced ShaderRecordNVLayoutModifier with ShaderRecordAttribute
* Allowed attributed [[vk::shader_record] and [[shader_record]]
* Checking there is at most 1 ShaderRecord active
* Small typo fixes
* Slightly improve diagnostic.
Replace expected file.
Diffstat (limited to 'source/slang/parser.cpp')
| -rw-r--r-- | source/slang/parser.cpp | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index 3c879302c..38a28745a 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -4612,8 +4612,6 @@ namespace Slang return modifier; } - - static RefPtr<RefObject> parseLayoutModifier(Parser* parser, void* /*userData*/) { ModifierListBuilder listBuilder; @@ -4653,47 +4651,35 @@ namespace Slang } else { - if (nameText == "push_constant") + RefPtr<Modifier> modifier; + +#define CASE(key, type) if (nameText == #key) { modifier = new type; } else + CASE(push_constant, PushConstantAttribute) + CASE(shaderRecordNV, ShaderRecordAttribute) + CASE(constant_id, GLSLConstantIDLayoutModifier) + CASE(location, GLSLLocationLayoutModifier) + CASE(local_size_x, GLSLLocalSizeXLayoutModifier) + CASE(local_size_y, GLSLLocalSizeYLayoutModifier) + CASE(local_size_z, GLSLLocalSizeZLayoutModifier) { - RefPtr<PushConstantAttribute> modifier(new PushConstantAttribute); - - modifier->name = nameAndLoc.name; - modifier->loc = nameAndLoc.loc; - - listBuilder.add(modifier); + modifier = new GLSLUnparsedLayoutModifier(); } - else - { - RefPtr<GLSLLayoutModifier> modifier; + SLANG_ASSERT(modifier); +#undef CASE - // TODO: better handling of this choice (e.g., lookup in scope) - if(0) {} - #define CASE(KEYWORD, CLASS) \ - else if(nameText == #KEYWORD) modifier = new CLASS() + modifier->name = nameAndLoc.name; + modifier->loc = nameAndLoc.loc; - CASE(constant_id, GLSLConstantIDLayoutModifier); - CASE(location, GLSLLocationLayoutModifier); - CASE(local_size_x, GLSLLocalSizeXLayoutModifier); - CASE(local_size_y, GLSLLocalSizeYLayoutModifier); - CASE(local_size_z, GLSLLocalSizeZLayoutModifier); - CASE(shaderRecordNV, ShaderRecordNVLayoutModifier); - - #undef CASE - else - { - modifier = new GLSLUnparsedLayoutModifier(); - } - - modifier->name = nameAndLoc.name; - modifier->loc = nameAndLoc.loc; - - if(AdvanceIf(parser, TokenType::OpAssign)) + // Special handling for GLSLLayoutModifier + if (auto glslModifier = as<GLSLLayoutModifier>(modifier)) + { + if (AdvanceIf(parser, TokenType::OpAssign)) { - modifier->valToken = parser->ReadToken(TokenType::IntegerLiteral); + glslModifier->valToken = parser->ReadToken(TokenType::IntegerLiteral); } - - listBuilder.add(modifier); } + + listBuilder.add(modifier); } if (AdvanceIf(parser, TokenType::RParent)) |
