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
e82061de
Commit
e82061de
authored
Sep 27, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Rationalize combination of type arrayness and name arrayness.
parent
b1672fa0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
45 deletions
+43
-45
revision.h
glslang/Include/revision.h
+2
-2
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+36
-18
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+4
-24
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-1
No files found.
glslang/Include/revision.h
View file @
e82061de
...
...
@@ -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.15
07
"
#define GLSLANG_DATE "2
5
-Sep-2016"
#define GLSLANG_REVISION "Overload400-PrecQual.15
23
"
#define GLSLANG_DATE "2
7
-Sep-2016"
hlsl/hlslGrammar.cpp
View file @
e82061de
...
...
@@ -271,7 +271,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
// typedef
bool
typedefDecl
=
acceptTokenClass
(
EHTokTypedef
);
TType
t
ype
;
TType
declaredT
ype
;
// DX9 sampler declaration use a different syntax
// DX9 shaders need to run through HLSL compiler (fxc) via a back compat mode, it isn't going to
...
...
@@ -280,21 +280,21 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
// As such, the sampler keyword in D3D10+ turns into an automatic sampler type, and is commonly used
// For that reason, this line is commented out
// if (acceptSamplerDeclarationDX9(
t
ype))
// if (acceptSamplerDeclarationDX9(
declaredT
ype))
// return true;
// fully_specified_type
if
(
!
acceptFullySpecifiedType
(
t
ype
))
if
(
!
acceptFullySpecifiedType
(
declaredT
ype
))
return
false
;
if
(
t
ype
.
getQualifier
().
storage
==
EvqTemporary
&&
parseContext
.
symbolTable
.
atGlobalLevel
())
{
if
(
t
ype
.
getBasicType
()
==
EbtSampler
)
{
if
(
declaredT
ype
.
getQualifier
().
storage
==
EvqTemporary
&&
parseContext
.
symbolTable
.
atGlobalLevel
())
{
if
(
declaredT
ype
.
getBasicType
()
==
EbtSampler
)
{
// Sampler/textures are uniform by default (if no explicit qualifier is present) in
// HLSL. This line silently converts samplers *explicitly* declared static to uniform,
// which is incorrect but harmless.
t
ype
.
getQualifier
().
storage
=
EvqUniform
;
declaredT
ype
.
getQualifier
().
storage
=
EvqUniform
;
}
else
{
t
ype
.
getQualifier
().
storage
=
EvqGlobal
;
declaredT
ype
.
getQualifier
().
storage
=
EvqGlobal
;
}
}
...
...
@@ -302,7 +302,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
HlslToken
idToken
;
while
(
acceptIdentifier
(
idToken
))
{
// function_parameters
TFunction
&
function
=
*
new
TFunction
(
idToken
.
string
,
t
ype
);
TFunction
&
function
=
*
new
TFunction
(
idToken
.
string
,
declaredT
ype
);
if
(
acceptFunctionParameters
(
function
))
{
// post_decls
acceptPostDecls
(
function
.
getWritableType
().
getQualifier
());
...
...
@@ -320,20 +320,38 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
parseContext
.
handleFunctionDeclarator
(
idToken
.
loc
,
function
,
true
);
}
}
else
{
// a variable declaration
// A variable declaration.
// We can handle multiple variables per type declaration, so
// the number of types can expand when arrayness is different.
TType
variableType
;
variableType
.
shallowCopy
(
declaredType
);
// array_specifier
//
recognize
array_specifier
TArraySizes
*
arraySizes
=
nullptr
;
acceptArraySpecifier
(
arraySizes
);
// Fix arrayness in the variableType
if
(
declaredType
.
isImplicitlySizedArray
())
{
// Because "int[] a = int[2](...), b = int[3](...)" makes two arrays a and b
// of different sizes, for this case sharing the shallow copy of arrayness
// with the parseType oversubscribes it, so get a deep copy of the arrayness.
variableType
.
newArraySizes
(
declaredType
.
getArraySizes
());
}
if
(
arraySizes
||
variableType
.
isArray
())
{
// In the most general case, arrayness is potentially coming both from the
// declared type and from the variable: "int[] a[];" or just one or the other.
// Merge it all to the variableType, so all arrayness is part of the variableType.
parseContext
.
arrayDimMerge
(
variableType
,
arraySizes
);
}
// samplers accept immediate sampler state
if
(
t
ype
.
getBasicType
()
==
EbtSampler
)
{
if
(
variableT
ype
.
getBasicType
()
==
EbtSampler
)
{
if
(
!
acceptSamplerState
())
return
false
;
}
// post_decls
acceptPostDecls
(
t
ype
.
getQualifier
());
acceptPostDecls
(
variableT
ype
.
getQualifier
());
// EQUAL assignment_expression
TIntermTyped
*
expressionNode
=
nullptr
;
...
...
@@ -347,16 +365,16 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
}
if
(
typedefDecl
)
parseContext
.
declareTypedef
(
idToken
.
loc
,
*
idToken
.
string
,
t
ype
,
arraySizes
);
else
if
(
t
ype
.
getBasicType
()
==
EbtBlock
)
parseContext
.
declareBlock
(
idToken
.
loc
,
t
ype
,
idToken
.
string
);
parseContext
.
declareTypedef
(
idToken
.
loc
,
*
idToken
.
string
,
variableT
ype
,
arraySizes
);
else
if
(
variableT
ype
.
getBasicType
()
==
EbtBlock
)
parseContext
.
declareBlock
(
idToken
.
loc
,
variableT
ype
,
idToken
.
string
);
else
{
// Declare the variable and add any initializer code to the AST.
// The top-level node is always made into an aggregate, as that's
// historically how the AST has been.
node
=
intermediate
.
growAggregate
(
node
,
parseContext
.
declareVariable
(
idToken
.
loc
,
*
idToken
.
string
,
t
ype
,
arraySizes
,
expressionNode
),
parseContext
.
declareVariable
(
idToken
.
loc
,
*
idToken
.
string
,
variableT
ype
,
expressionNode
),
idToken
.
loc
);
}
}
...
...
@@ -412,7 +430,7 @@ bool HlslGrammar::acceptControlDeclaration(TIntermNode*& node)
return
false
;
}
node
=
parseContext
.
declareVariable
(
idToken
.
loc
,
*
idToken
.
string
,
type
,
0
,
expressionNode
);
node
=
parseContext
.
declareVariable
(
idToken
.
loc
,
*
idToken
.
string
,
type
,
expressionNode
);
return
true
;
}
...
...
hlsl/hlslParseHelper.cpp
View file @
e82061de
...
...
@@ -4160,11 +4160,6 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
TType
type
;
type
.
deepCopy
(
parseType
);
// Arrayness is potentially coming both from the type and from the
// variable: "int[] a[];" or just one or the other.
// Merge it all to the type, so all arrayness is part of the type.
arrayDimMerge
(
type
,
arraySizes
);
TVariable
*
typeSymbol
=
new
TVariable
(
&
identifier
,
type
,
true
);
if
(
!
symbolTable
.
insert
(
*
typeSymbol
))
error
(
loc
,
"name already defined"
,
"typedef"
,
identifier
.
c_str
());
...
...
@@ -4181,7 +4176,7 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
// 'parseType' is the type part of the declaration (to the left)
// 'arraySizes' is the arrayness tagged on the identifier (to the right)
//
TIntermNode
*
HlslParseContext
::
declareVariable
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
const
TType
&
parseType
,
TArraySizes
*
arraySizes
,
TIntermTyped
*
initializer
)
TIntermNode
*
HlslParseContext
::
declareVariable
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
TType
&
type
,
TIntermTyped
*
initializer
)
{
// TODO: things scoped within an annotation need their own name space;
// haven't done that yet
...
...
@@ -4189,18 +4184,9 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
return
nullptr
;
// TODO: strings are not yet handled
if
(
parseT
ype
.
getBasicType
()
==
EbtString
)
if
(
t
ype
.
getBasicType
()
==
EbtString
)
return
nullptr
;
TType
type
;
type
.
shallowCopy
(
parseType
);
if
(
type
.
isImplicitlySizedArray
())
{
// Because "int[] a = int[2](...), b = int[3](...)" makes two arrays a and b
// of different sizes, for this case sharing the shallow copy of arrayness
// with the parseType oversubscribes it, so get a deep copy of the arrayness.
type
.
newArraySizes
(
*
parseType
.
getArraySizes
());
}
if
(
voidErrorCheck
(
loc
,
identifier
,
type
.
getBasicType
()))
return
nullptr
;
...
...
@@ -4213,16 +4199,10 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
bool
flattenVar
=
false
;
// Declare the variable
if
(
arraySizes
||
type
.
isArray
())
{
// Arrayness is potentially coming both from the type and from the
// variable: "int[] a[];" or just one or the other.
// Merge it all to the type, so all arrayness is part of the type.
arrayDimMerge
(
type
,
arraySizes
);
// Safe if there are no arraySizes
if
(
type
.
isArray
())
{
// array case
declareArray
(
loc
,
identifier
,
type
,
symbol
,
newDeclaration
);
flattenVar
=
shouldFlatten
(
type
);
if
(
flattenVar
)
flatten
(
loc
,
*
symbol
->
getAsVariable
());
}
else
{
...
...
hlsl/hlslParseHelper.h
View file @
e82061de
...
...
@@ -140,7 +140,7 @@ public:
const
TFunction
*
findFunction
(
const
TSourceLoc
&
loc
,
const
TFunction
&
call
,
bool
&
builtIn
);
void
declareTypedef
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TArraySizes
*
typeArray
=
0
);
TIntermNode
*
declareVariable
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TArraySizes
*
typeArray
=
0
,
TIntermTyped
*
initializer
=
0
);
TIntermNode
*
declareVariable
(
const
TSourceLoc
&
,
TString
&
identifier
,
TType
&
,
TIntermTyped
*
initializer
=
0
);
TIntermTyped
*
addConstructor
(
const
TSourceLoc
&
,
TIntermNode
*
,
const
TType
&
);
TIntermTyped
*
constructAggregate
(
TIntermNode
*
,
const
TType
&
,
int
,
const
TSourceLoc
&
);
TIntermTyped
*
constructBuiltIn
(
const
TType
&
,
TOperator
,
TIntermTyped
*
,
const
TSourceLoc
&
,
bool
subset
);
...
...
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