Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
a1e2d495
Commit
a1e2d495
authored
Sep 20, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Move to correct parsing of annotations, improving all annotations and recent string grammar.
parent
2572b19e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
56 deletions
+40
-56
hlsl.string.frag
Test/hlsl.string.frag
+1
-1
revision.h
glslang/Include/revision.h
+2
-2
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+18
-42
hlslGrammar.h
hlsl/hlslGrammar.h
+1
-1
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+8
-3
hlslParseHelper.h
hlsl/hlslParseHelper.h
+7
-4
hlslScanContext.cpp
hlsl/hlslScanContext.cpp
+2
-2
hlslTokens.h
hlsl/hlslTokens.h
+1
-1
No files found.
Test/hlsl.string.frag
View file @
a1e2d495
string
s
=
"string1"
;
string
s
=
"string1"
;
string
e
=
""
;
string
e
=
""
;
string
bracket
<
string
a
=
"nested"
;
>
;
string
bracket
<
string
a
=
"nested"
;
>
;
string
brackets
<
string
b
=
"nest1"
;
string
c
=
"nest2"
;
string
d
=
"nest3"
;
>
;
string
brackets
<
string
b
=
"nest1"
;
string
c
=
"nest2"
;
float
test
[
4
]
=
{
1
.
0
,
1
.
0
,
1
.
0
,
1
.
0
}
;
vector
<
float
,
3
>
a
=
float3
(
2
.
0
)
;
>
;
string
brackete1
<
>
;
string
brackete1
<
>
;
string
brackete2
<
;
>
;
string
brackete2
<
;
>
;
string
brackete3
<
;
;
>
;
string
brackete3
<
;
;
>
;
...
...
glslang/Include/revision.h
View file @
a1e2d495
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// 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).
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.150
2
"
#define GLSLANG_REVISION "Overload400-PrecQual.150
3
"
#define GLSLANG_DATE "
19
-Sep-2016"
#define GLSLANG_DATE "
20
-Sep-2016"
hlsl/hlslGrammar.cpp
View file @
a1e2d495
...
@@ -721,36 +721,16 @@ bool HlslGrammar::acceptMatrixTemplateType(TType& type)
...
@@ -721,36 +721,16 @@ bool HlslGrammar::acceptMatrixTemplateType(TType& type)
return
true
;
return
true
;
}
}
// string_template_type
// annotations
// : STRING
// : LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
// | STRING identifier LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
//
//
bool
HlslGrammar
::
accept
StringTemplateType
(
TType
&
type
)
bool
HlslGrammar
::
accept
Annotations
(
TQualifier
&
)
{
{
// STRING
if
(
!
acceptTokenClass
(
EHTokLeftAngle
))
if
(
!
acceptTokenClass
(
EHTokString
))
return
false
;
return
false
;
// no matter what happens next, we recognized a string type
// note that we are nesting a name space
new
(
&
type
)
TType
(
EbtString
);
parseContext
.
nestAnnotations
();
// identifier LEFT_ANGLE, or not?
if
(
!
acceptTokenClass
(
EHTokIdentifier
))
{
expected
(
"identifier following 'string'"
);
return
false
;
}
if
(
!
peekTokenClass
(
EHTokLeftAngle
))
{
// then it must be the non-template version, back up and let
// normal declaration code handle it
// recede the identifier
recedeToken
();
return
true
;
}
// move past the LEFT_ANGLE
advanceToken
();
// declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
// declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
do
{
do
{
...
@@ -759,15 +739,18 @@ bool HlslGrammar::acceptStringTemplateType(TType& type)
...
@@ -759,15 +739,18 @@ bool HlslGrammar::acceptStringTemplateType(TType& type)
;
;
if
(
acceptTokenClass
(
EHTokRightAngle
))
if
(
acceptTokenClass
(
EHTokRightAngle
))
return
true
;
break
;
// declaration
// declaration
TIntermNode
*
node
;
TIntermNode
*
node
;
if
(
!
acceptDeclaration
(
node
))
{
if
(
!
acceptDeclaration
(
node
))
{
expected
(
"declaration in
string list
"
);
expected
(
"declaration in
annotation
"
);
return
false
;
return
false
;
}
}
}
while
(
true
);
}
while
(
true
);
parseContext
.
unnestAnnotations
();
return
true
;
}
}
// sampler_type
// sampler_type
...
@@ -942,10 +925,6 @@ bool HlslGrammar::acceptType(TType& type)
...
@@ -942,10 +925,6 @@ bool HlslGrammar::acceptType(TType& type)
return
acceptMatrixTemplateType
(
type
);
return
acceptMatrixTemplateType
(
type
);
break
;
break
;
case
EHTokString
:
return
acceptStringTemplateType
(
type
);
break
;
case
EHTokSampler
:
// fall through
case
EHTokSampler
:
// fall through
case
EHTokSampler1d
:
// ...
case
EHTokSampler1d
:
// ...
case
EHTokSampler2d
:
// ...
case
EHTokSampler2d
:
// ...
...
@@ -991,6 +970,10 @@ bool HlslGrammar::acceptType(TType& type)
...
@@ -991,6 +970,10 @@ bool HlslGrammar::acceptType(TType& type)
new
(
&
type
)
TType
(
EbtVoid
);
new
(
&
type
)
TType
(
EbtVoid
);
break
;
break
;
case
EHTokString
:
new
(
&
type
)
TType
(
EbtString
);
break
;
case
EHTokFloat
:
case
EHTokFloat
:
new
(
&
type
)
TType
(
EbtFloat
);
new
(
&
type
)
TType
(
EbtFloat
);
break
;
break
;
...
@@ -2740,16 +2723,9 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier)
...
@@ -2740,16 +2723,9 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier)
// semantic, in idToken.string
// semantic, in idToken.string
parseContext
.
handleSemantic
(
idToken
.
loc
,
qualifier
,
*
idToken
.
string
);
parseContext
.
handleSemantic
(
idToken
.
loc
,
qualifier
,
*
idToken
.
string
);
}
}
}
else
if
(
acceptTokenClass
(
EHTokLeftAngle
))
{
}
else
if
(
peekTokenClass
(
EHTokLeftAngle
))
// TODO: process annotations, just accepting them for now
acceptAnnotations
(
qualifier
);
do
{
else
if
(
peekTokenClass
(
EHTokNone
))
return
;
if
(
acceptTokenClass
(
EHTokRightAngle
))
break
;
advanceToken
();
}
while
(
true
);
}
else
break
;
break
;
}
while
(
true
);
}
while
(
true
);
...
...
hlsl/hlslGrammar.h
View file @
a1e2d495
...
@@ -73,7 +73,7 @@ namespace glslang {
...
@@ -73,7 +73,7 @@ namespace glslang {
bool
acceptTemplateType
(
TBasicType
&
);
bool
acceptTemplateType
(
TBasicType
&
);
bool
acceptVectorTemplateType
(
TType
&
);
bool
acceptVectorTemplateType
(
TType
&
);
bool
acceptMatrixTemplateType
(
TType
&
);
bool
acceptMatrixTemplateType
(
TType
&
);
bool
accept
StringTemplateType
(
TType
&
);
bool
accept
Annotations
(
TQualifier
&
);
bool
acceptSamplerType
(
TType
&
);
bool
acceptSamplerType
(
TType
&
);
bool
acceptTextureType
(
TType
&
);
bool
acceptTextureType
(
TType
&
);
bool
acceptStruct
(
TType
&
);
bool
acceptStruct
(
TType
&
);
...
...
hlsl/hlslParseHelper.cpp
View file @
a1e2d495
...
@@ -52,7 +52,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
...
@@ -52,7 +52,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
int
version
,
EProfile
profile
,
const
SpvVersion
&
spvVersion
,
EShLanguage
language
,
TInfoSink
&
infoSink
,
int
version
,
EProfile
profile
,
const
SpvVersion
&
spvVersion
,
EShLanguage
language
,
TInfoSink
&
infoSink
,
bool
forwardCompatible
,
EShMessages
messages
)
:
bool
forwardCompatible
,
EShMessages
messages
)
:
TParseContextBase
(
symbolTable
,
interm
,
version
,
profile
,
spvVersion
,
language
,
infoSink
,
forwardCompatible
,
messages
),
TParseContextBase
(
symbolTable
,
interm
,
version
,
profile
,
spvVersion
,
language
,
infoSink
,
forwardCompatible
,
messages
),
contextPragma
(
true
,
false
),
loopNestingLevel
(
0
),
structNestingLevel
(
0
),
controlFlowNestingLevel
(
0
),
contextPragma
(
true
,
false
),
loopNestingLevel
(
0
),
annotationNestingLevel
(
0
),
structNestingLevel
(
0
),
controlFlowNestingLevel
(
0
),
postMainReturn
(
false
),
postMainReturn
(
false
),
limits
(
resources
.
limits
),
limits
(
resources
.
limits
),
entryPointOutput
(
nullptr
),
entryPointOutput
(
nullptr
),
...
@@ -4059,8 +4060,12 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
...
@@ -4059,8 +4060,12 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
//
//
TIntermNode
*
HlslParseContext
::
declareVariable
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
const
TType
&
parseType
,
TArraySizes
*
arraySizes
,
TIntermTyped
*
initializer
)
TIntermNode
*
HlslParseContext
::
declareVariable
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
const
TType
&
parseType
,
TArraySizes
*
arraySizes
,
TIntermTyped
*
initializer
)
{
{
// string identifiers can nest inside < ... >, apparently with their own namespace,
// TODO: things scoped within an annotation need their own name space;
// which is not implemented
// haven't done that yet
if
(
annotationNestingLevel
>
0
)
return
nullptr
;
// TODO: strings are not yet handled
if
(
parseType
.
getBasicType
()
==
EbtString
)
if
(
parseType
.
getBasicType
()
==
EbtString
)
return
nullptr
;
return
nullptr
;
...
...
hlsl/hlslParseHelper.h
View file @
a1e2d495
...
@@ -159,10 +159,12 @@ public:
...
@@ -159,10 +159,12 @@ public:
void
updateImplicitArraySize
(
const
TSourceLoc
&
,
TIntermNode
*
,
int
index
);
void
updateImplicitArraySize
(
const
TSourceLoc
&
,
TIntermNode
*
,
int
index
);
void
nestLooping
()
{
++
loopNestingLevel
;
}
void
nestLooping
()
{
++
loopNestingLevel
;
}
void
unnestLooping
()
{
--
loopNestingLevel
;
}
void
unnestLooping
()
{
--
loopNestingLevel
;
}
void
pushScope
()
{
symbolTable
.
push
();
}
void
nestAnnotations
()
{
++
annotationNestingLevel
;
}
void
popScope
()
{
symbolTable
.
pop
(
0
);
}
void
unnestAnnotations
()
{
--
annotationNestingLevel
;
}
void
pushScope
()
{
symbolTable
.
push
();
}
void
popScope
()
{
symbolTable
.
pop
(
0
);
}
void
pushSwitchSequence
(
TIntermSequence
*
sequence
)
{
switchSequenceStack
.
push_back
(
sequence
);
}
void
pushSwitchSequence
(
TIntermSequence
*
sequence
)
{
switchSequenceStack
.
push_back
(
sequence
);
}
void
popSwitchSequence
()
{
switchSequenceStack
.
pop_back
();
}
void
popSwitchSequence
()
{
switchSequenceStack
.
pop_back
();
}
...
@@ -182,6 +184,7 @@ protected:
...
@@ -182,6 +184,7 @@ protected:
// Current state of parsing
// Current state of parsing
struct
TPragma
contextPragma
;
struct
TPragma
contextPragma
;
int
loopNestingLevel
;
// 0 if outside all loops
int
loopNestingLevel
;
// 0 if outside all loops
int
annotationNestingLevel
;
// 0 if outside all annotations
int
structNestingLevel
;
// 0 if outside blocks and structures
int
structNestingLevel
;
// 0 if outside blocks and structures
int
controlFlowNestingLevel
;
// 0 if outside all flow control
int
controlFlowNestingLevel
;
// 0 if outside all flow control
TList
<
TIntermSequence
*>
switchSequenceStack
;
// case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
TList
<
TIntermSequence
*>
switchSequenceStack
;
// case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
...
...
hlsl/hlslScanContext.cpp
View file @
a1e2d495
...
@@ -122,9 +122,9 @@ void HlslScanContext::fillInKeywordMap()
...
@@ -122,9 +122,9 @@ void HlslScanContext::fillInKeywordMap()
(
*
KeywordMap
)[
"Buffer"
]
=
EHTokBuffer
;
(
*
KeywordMap
)[
"Buffer"
]
=
EHTokBuffer
;
(
*
KeywordMap
)[
"vector"
]
=
EHTokVector
;
(
*
KeywordMap
)[
"vector"
]
=
EHTokVector
;
(
*
KeywordMap
)[
"matrix"
]
=
EHTokMatrix
;
(
*
KeywordMap
)[
"matrix"
]
=
EHTokMatrix
;
(
*
KeywordMap
)[
"string"
]
=
EHTokString
;
(
*
KeywordMap
)[
"void"
]
=
EHTokVoid
;
(
*
KeywordMap
)[
"void"
]
=
EHTokVoid
;
(
*
KeywordMap
)[
"string"
]
=
EHTokString
;
(
*
KeywordMap
)[
"bool"
]
=
EHTokBool
;
(
*
KeywordMap
)[
"bool"
]
=
EHTokBool
;
(
*
KeywordMap
)[
"int"
]
=
EHTokInt
;
(
*
KeywordMap
)[
"int"
]
=
EHTokInt
;
(
*
KeywordMap
)[
"uint"
]
=
EHTokUint
;
(
*
KeywordMap
)[
"uint"
]
=
EHTokUint
;
...
@@ -472,11 +472,11 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
...
@@ -472,11 +472,11 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
case
EHTokBuffer
:
case
EHTokBuffer
:
case
EHTokVector
:
case
EHTokVector
:
case
EHTokMatrix
:
case
EHTokMatrix
:
case
EHTokString
:
return
keyword
;
return
keyword
;
// scalar types
// scalar types
case
EHTokVoid
:
case
EHTokVoid
:
case
EHTokString
:
case
EHTokBool
:
case
EHTokBool
:
case
EHTokInt
:
case
EHTokInt
:
case
EHTokUint
:
case
EHTokUint
:
...
...
hlsl/hlslTokens.h
View file @
a1e2d495
...
@@ -70,10 +70,10 @@ enum EHlslTokenClass {
...
@@ -70,10 +70,10 @@ enum EHlslTokenClass {
EHTokBuffer
,
EHTokBuffer
,
EHTokVector
,
EHTokVector
,
EHTokMatrix
,
EHTokMatrix
,
EHTokString
,
// scalar types
// scalar types
EHTokVoid
,
EHTokVoid
,
EHTokString
,
EHTokBool
,
EHTokBool
,
EHTokInt
,
EHTokInt
,
EHTokUint
,
EHTokUint
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment