From 6a8ad6eb4cab72c18de48762768e04d08b60a21c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 22 Aug 2018 11:36:02 -0400 Subject: Support for [[vk::push_constant]] (#629) * Support for attributed [[vk::push_constant]] and [[push_constant]]. Can also use layout(push_constant). * Fix test so matches the expected output. * Add expected output to binding-push-constant-gl.hlsl * Trivial change to force travis rebuild to test the gcc linux build really has a problem. --- source/slang/parser.cpp | 55 +++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'source/slang/parser.cpp') diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index 62fed75cc..e3982aee4 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -4511,35 +4511,46 @@ namespace Slang } else { - RefPtr modifier; - - // TODO: better handling of this choice (e.g., lookup in scope) - if(0) {} - #define CASE(KEYWORD, CLASS) \ - else if(getText(nameAndLoc.name) == #KEYWORD) modifier = new CLASS() + if (nameText == "push_constant") + { + RefPtr modifier(new PushConstantAttribute); - CASE(constant_id, GLSLConstantIDLayoutModifier); - CASE(location, GLSLLocationLayoutModifier); - CASE(push_constant, GLSLPushConstantLayoutModifier); - CASE(local_size_x, GLSLLocalSizeXLayoutModifier); - CASE(local_size_y, GLSLLocalSizeYLayoutModifier); - CASE(local_size_z, GLSLLocalSizeZLayoutModifier); + modifier->name = nameAndLoc.name; + modifier->loc = nameAndLoc.loc; - #undef CASE + listBuilder.add(modifier); + } else { - modifier = new GLSLUnparsedLayoutModifier(); - } + RefPtr modifier; - modifier->name = nameAndLoc.name; - modifier->loc = nameAndLoc.loc; + // TODO: better handling of this choice (e.g., lookup in scope) + if(0) {} + #define CASE(KEYWORD, CLASS) \ + else if(nameText == #KEYWORD) modifier = new CLASS() - if(AdvanceIf(parser, TokenType::OpAssign)) - { - modifier->valToken = parser->ReadToken(TokenType::IntegerLiteral); - } + CASE(constant_id, GLSLConstantIDLayoutModifier); + CASE(location, GLSLLocationLayoutModifier); + CASE(local_size_x, GLSLLocalSizeXLayoutModifier); + CASE(local_size_y, GLSLLocalSizeYLayoutModifier); + CASE(local_size_z, GLSLLocalSizeZLayoutModifier); - listBuilder.add(modifier); + #undef CASE + else + { + modifier = new GLSLUnparsedLayoutModifier(); + } + + modifier->name = nameAndLoc.name; + modifier->loc = nameAndLoc.loc; + + if(AdvanceIf(parser, TokenType::OpAssign)) + { + modifier->valToken = parser->ReadToken(TokenType::IntegerLiteral); + } + + listBuilder.add(modifier); + } } if (AdvanceIf(parser, TokenType::RParent)) -- cgit v1.2.3