From 7c8527d20e433c3a10736136d31e4cd882a3baaa Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 4 Oct 2019 09:46:03 -0400 Subject: IR types for subset of Attributes (#1067) * IROutputControlPointsDecoration * IROutputTopologyDecoration * IRPartitioningDecoration * IRDomainDecoration * Use IRPatchConstantDecoration alone for hlsl output. * IRMaxVertexCountDecoration * IRInstanceDecoration * Removed _emitHLSLAttributeSingleString and _emitHLSLAttributeSingleInt Removed GLSLBindingAttribute and just use NumThreadsAttribute * Added IRNumThreadsDecoration. * Added IRNumThreadsDecoration * Fix build problem on x86. Improve diagnostic text based on review. --- source/slang/slang-parser.cpp | 46 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-parser.cpp') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index fffbf2c62..dad84a4b6 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4450,6 +4450,8 @@ namespace Slang { ModifierListBuilder listBuilder; + RefPtr numThreadsAttrib; + listBuilder.add(new GLSLLayoutModifierGroupBegin()); parser->ReadToken(TokenType::LParent); @@ -4458,7 +4460,41 @@ namespace Slang auto nameAndLoc = expectIdentifier(parser); const String& nameText = nameAndLoc.name->text; - if (nameText == "binding" || + const char localSizePrefix[] = "local_size_"; + + int localSizeIndex = -1; + if (nameText.startsWith(localSizePrefix) && nameText.getLength() == SLANG_COUNT_OF(localSizePrefix) - 1 + 1) + { + char lastChar = nameText[SLANG_COUNT_OF(localSizePrefix) - 1]; + localSizeIndex = (lastChar >= 'x' && lastChar <= 'z') ? (lastChar - 'x') : -1; + } + + if (localSizeIndex >= 0) + { + if (!numThreadsAttrib) + { + numThreadsAttrib = new UncheckedAttribute; + numThreadsAttrib->args.setCount(3); + + // Just mark the loc and name from the first in the list + numThreadsAttrib->name = getName(parser, "numthreads"); + numThreadsAttrib->loc = nameAndLoc.loc; + numThreadsAttrib->scope = parser->currentScope; + } + + if (AdvanceIf(parser, TokenType::OpAssign)) + { + auto expr = parseAtomicExpr(parser); + //SLANG_ASSERT(expr); + if (!expr) + { + return nullptr; + } + + numThreadsAttrib->args[localSizeIndex] = expr; + } + } + else if (nameText == "binding" || nameText == "set") { GLSLBindingAttribute* attr = listBuilder.find(); @@ -4499,9 +4535,6 @@ namespace Slang 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) { modifier = new GLSLUnparsedLayoutModifier(); } @@ -4528,6 +4561,11 @@ namespace Slang parser->ReadToken(TokenType::Comma); } + if (numThreadsAttrib) + { + listBuilder.add(numThreadsAttrib); + } + listBuilder.add(new GLSLLayoutModifierGroupEnd()); return listBuilder.getFirst(); -- cgit v1.2.3