From: John Kessenich Date: Mon, 5 Sep 2016 22:03:12 +0000 (-0600) Subject: HLSL: Support register(..., spaceN) for setting the descriptor set. X-Git-Tag: upstream/11.4.0~1519 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfd7ce87cd10191c3d5afec077865c7c6dc9dd77;p=platform%2Fupstream%2Fglslang.git HLSL: Support register(..., spaceN) for setting the descriptor set. This was suggested in issue #454. --- diff --git a/Test/baseResults/hlsl.buffer.frag.out b/Test/baseResults/hlsl.buffer.frag.out index d1b36fb..79b8acd 100755 --- a/Test/baseResults/hlsl.buffer.frag.out +++ b/Test/baseResults/hlsl.buffer.frag.out @@ -23,7 +23,7 @@ gl_FragCoord origin is upper left 0:27 Constant: 0:27 0 (const uint) 0:27 v3: direct index for structure (layout(column_major std140 ) uniform 4-component vector of float) -0:27 'anon@2' (layout(binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) +0:27 'anon@2' (layout(set=10 binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) 0:27 Constant: 0:27 0 (const uint) 0:27 v4: direct index for structure (layout(column_major std430 offset=16 ) buffer 4-component vector of float) @@ -34,7 +34,7 @@ gl_FragCoord origin is upper left 0:? Linker Objects 0:? 'anon@0' (layout(column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v1}) 0:? 'anon@1' (layout(column_major std430 ) buffer block{layout(column_major std430 ) buffer 4-component vector of float v2}) -0:? 'anon@2' (layout(binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) +0:? 'anon@2' (layout(set=10 binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) 0:? 'anon@3' (layout(binding=8 column_major std430 ) buffer block{layout(column_major std430 offset=16 ) buffer 4-component vector of float v4, layout(column_major std430 offset=48 ) buffer int i4, layout(column_major std430 offset=60 ) buffer float f1, layout(column_major std430 offset=64 ) buffer float f3, layout(column_major std430 offset=68 ) buffer float f4, layout(column_major std430 offset=72 ) buffer float f5, layout(column_major std430 ) buffer float f6, layout(column_major std430 ) buffer float f7}) @@ -65,7 +65,7 @@ gl_FragCoord origin is upper left 0:27 Constant: 0:27 0 (const uint) 0:27 v3: direct index for structure (layout(column_major std140 ) uniform 4-component vector of float) -0:27 'anon@2' (layout(binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) +0:27 'anon@2' (layout(set=10 binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) 0:27 Constant: 0:27 0 (const uint) 0:27 v4: direct index for structure (layout(column_major std430 offset=16 ) buffer 4-component vector of float) @@ -76,7 +76,7 @@ gl_FragCoord origin is upper left 0:? Linker Objects 0:? 'anon@0' (layout(column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v1}) 0:? 'anon@1' (layout(column_major std430 ) buffer block{layout(column_major std430 ) buffer 4-component vector of float v2}) -0:? 'anon@2' (layout(binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) +0:? 'anon@2' (layout(set=10 binding=2 column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float v3, layout(column_major std140 offset=20 ) uniform int i3}) 0:? 'anon@3' (layout(binding=8 column_major std430 ) buffer block{layout(column_major std430 offset=16 ) buffer 4-component vector of float v4, layout(column_major std430 offset=48 ) buffer int i4, layout(column_major std430 offset=60 ) buffer float f1, layout(column_major std430 offset=64 ) buffer float f3, layout(column_major std430 offset=68 ) buffer float f4, layout(column_major std430 offset=72 ) buffer float f5, layout(column_major std430 ) buffer float f6, layout(column_major std430 ) buffer float f7}) // Module Version 10000 @@ -122,7 +122,7 @@ gl_FragCoord origin is upper left MemberDecorate 28 0 Offset 0 MemberDecorate 28 1 Offset 20 Decorate 28 Block - Decorate 30 DescriptorSet 0 + Decorate 30 DescriptorSet 10 Decorate 30 Binding 2 MemberDecorate 34 0 Offset 16 MemberDecorate 34 1 Offset 48 diff --git a/Test/hlsl.buffer.frag b/Test/hlsl.buffer.frag index e01e4fc..4e28043 100644 --- a/Test/hlsl.buffer.frag +++ b/Test/hlsl.buffer.frag @@ -6,7 +6,7 @@ tbuffer { float4 v2; }; -cbuffer cbufName : register(b2) { +cbuffer cbufName : register(b2, space10) { float4 v3; int i3 : packoffset(c1.y); }; diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 06fd80a..01a7e43 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.1470" +#define GLSLANG_REVISION "Overload400-PrecQual.1472" #define GLSLANG_DATE "05-Sep-2016" diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index d627b15..e94d6eb 100755 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -2591,11 +2591,11 @@ 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#[subcomp]opt RIGHT_PAREN // optional +// : COLON semantic // optional +// COLON PACKOFFSET LEFT_PAREN c[Subcomponent][.component] RIGHT_PAREN // optional +// COLON REGISTER LEFT_PAREN [shader_profile,] Type#[subcomp]opt (COMMA SPACEN)opt RIGHT_PAREN // optional // COLON LAYOUT layout_qualifier_list -// annotations // optional +// annotations // optional // void HlslGrammar::acceptPostDecls(TQualifier& qualifier) { @@ -2632,7 +2632,8 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier) expected("layout, semantic, packoffset, or register"); return; } else if (*idToken.string == "register") { - // REGISTER LEFT_PAREN [shader_profile,] Type#[subcomp]opt RIGHT_PAREN + // REGISTER LEFT_PAREN [shader_profile,] Type#[subcomp]opt (COMMA SPACEN)opt RIGHT_PAREN + // LEFT_PAREN if (! acceptTokenClass(EHTokLeftParen)) { expected("("); return; @@ -2643,7 +2644,8 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier) expected("register number description"); return; } - if (acceptTokenClass(EHTokComma)) { + if (registerDesc.string->size() > 1 && !isdigit((*registerDesc.string)[1]) && + acceptTokenClass(EHTokComma)) { // Then we didn't really see the registerDesc yet, it was // actually the profile. Adjust... profile = registerDesc; @@ -2666,11 +2668,20 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier) break; } } + // (COMMA SPACEN)opt + HlslToken spaceDesc; + if (acceptTokenClass(EHTokComma)) { + if (! acceptIdentifier(spaceDesc)) { + expected ("space identifier"); + return; + } + } + // RIGHT_PAREN if (! acceptTokenClass(EHTokRightParen)) { expected(")"); break; } - parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent); + parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent, spaceDesc.string); } else { // semantic, in idToken.string parseContext.handleSemantic(idToken.loc, qualifier, *idToken.string); diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 185f8ad..282fabd 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -2523,7 +2523,7 @@ void HlslParseContext::handlePackOffset(const TSourceLoc& loc, TQualifier& quali // 'desc' is the type# part. // void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifier, const glslang::TString* profile, - const glslang::TString& desc, int subComponent) + const glslang::TString& desc, int subComponent, const glslang::TString* spaceDesc) { if (profile != nullptr) warn(loc, "ignoring shader_profile", "register", ""); @@ -2555,6 +2555,28 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi warn(loc, "ignoring unrecognized register type", "register", "%c", desc[0]); break; } + + // space + unsigned int setNumber; + const auto crackSpace = [&]() { + const int spaceLen = 5; + if (spaceDesc->size() < spaceLen + 1) + return false; + if (spaceDesc->compare(0, spaceLen, "space") != 0) + return false; + if (! isdigit((*spaceDesc)[spaceLen])) + return false; + setNumber = atoi(spaceDesc->substr(spaceLen, spaceDesc->size()).c_str()); + return true; + }; + + if (spaceDesc) { + if (! crackSpace()) { + error(loc, "expected spaceN", "register", ""); + return; + } + qualifier.layoutSet = setNumber; + } } // diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h index c80dfca..f422b3e 100755 --- a/hlsl/hlslParseHelper.h +++ b/hlsl/hlslParseHelper.h @@ -102,7 +102,7 @@ public: void handlePackOffset(const TSourceLoc&, TQualifier&, const glslang::TString& location, const glslang::TString* component); void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc, - int subComponent); + int subComponent, const glslang::TString*); TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);