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
28be4543
Commit
28be4543
authored
Dec 11, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Infrastructure: Generalize and broaden per-variable extension checking.
parent
69932ab4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
74 deletions
+136
-74
Initialize.cpp
glslang/MachineIndependent/Initialize.cpp
+24
-16
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+24
-11
ParseHelper.h
glslang/MachineIndependent/ParseHelper.h
+1
-1
SymbolTable.cpp
glslang/MachineIndependent/SymbolTable.cpp
+18
-13
SymbolTable.h
glslang/MachineIndependent/SymbolTable.h
+69
-24
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+0
-9
No files found.
glslang/MachineIndependent/Initialize.cpp
View file @
28be4543
...
@@ -7737,11 +7737,12 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
...
@@ -7737,11 +7737,12 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
static
void
SpecialQualifier
(
const
char
*
name
,
TStorageQualifier
qualifier
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
static
void
SpecialQualifier
(
const
char
*
name
,
TStorageQualifier
qualifier
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
{
{
TSymbol
*
symbol
=
symbolTable
.
find
(
name
);
TSymbol
*
symbol
=
symbolTable
.
find
(
name
);
if
(
symbol
)
{
if
(
symbol
==
nullptr
)
TQualifier
&
symQualifier
=
symbol
->
getWritableType
().
getQualifier
();
return
;
symQualifier
.
storage
=
qualifier
;
symQualifier
.
builtIn
=
builtIn
;
TQualifier
&
symQualifier
=
symbol
->
getWritableType
().
getQualifier
();
}
symQualifier
.
storage
=
qualifier
;
symQualifier
.
builtIn
=
builtIn
;
}
}
//
//
...
@@ -7757,7 +7758,7 @@ static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBui
...
@@ -7757,7 +7758,7 @@ static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBui
static
void
BuiltInVariable
(
const
char
*
name
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
static
void
BuiltInVariable
(
const
char
*
name
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
{
{
TSymbol
*
symbol
=
symbolTable
.
find
(
name
);
TSymbol
*
symbol
=
symbolTable
.
find
(
name
);
if
(
!
symbol
)
if
(
symbol
==
nullptr
)
return
;
return
;
TQualifier
&
symQualifier
=
symbol
->
getWritableType
().
getQualifier
();
TQualifier
&
symQualifier
=
symbol
->
getWritableType
().
getQualifier
();
...
@@ -7774,7 +7775,7 @@ static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolT
...
@@ -7774,7 +7775,7 @@ static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolT
static
void
BuiltInVariable
(
const
char
*
blockName
,
const
char
*
name
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
static
void
BuiltInVariable
(
const
char
*
blockName
,
const
char
*
name
,
TBuiltInVariable
builtIn
,
TSymbolTable
&
symbolTable
)
{
{
TSymbol
*
symbol
=
symbolTable
.
find
(
blockName
);
TSymbol
*
symbol
=
symbolTable
.
find
(
blockName
);
if
(
!
symbol
)
if
(
symbol
==
nullptr
)
return
;
return
;
TTypeList
&
structure
=
*
symbol
->
getWritableType
().
getWritableStruct
();
TTypeList
&
structure
=
*
symbol
->
getWritableType
().
getWritableStruct
();
...
@@ -8076,15 +8077,16 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
...
@@ -8076,15 +8077,16 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
// gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
// gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
// (Sometimes with an instance name, sometimes anonymous).
// (Sometimes with an instance name, sometimes anonymous).
// However, the current automatic extension scheme does not work per block member,
if
(
profile
==
EEsProfile
)
{
// so for now check when parsing.
if
(
language
==
EShLangGeometry
)
{
//
symbolTable
.
setVariableExtensions
(
"gl_PointSize"
,
Num_AEP_geometry_point_size
,
AEP_geometry_point_size
);
// if (profile == EEsProfile) {
symbolTable
.
setVariableExtensions
(
"gl_in"
,
"gl_PointSize"
,
Num_AEP_geometry_point_size
,
AEP_geometry_point_size
);
// if (language == EShLangGeometry)
}
else
if
(
language
==
EShLangTessEvaluation
||
language
==
EShLangTessControl
)
{
// symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
// gl_in tessellation settings of gl_PointSize are in the context-dependent paths
// else if (language == EShLangTessEvaluation || language == EShLangTessControl)
symbolTable
.
setVariableExtensions
(
"gl_PointSize"
,
Num_AEP_tessellation_point_size
,
AEP_tessellation_point_size
);
// symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
symbolTable
.
setVariableExtensions
(
"gl_out"
,
"gl_PointSize"
,
Num_AEP_tessellation_point_size
,
AEP_tessellation_point_size
);
//}
}
}
if
((
profile
!=
EEsProfile
&&
version
>=
140
)
||
if
((
profile
!=
EEsProfile
&&
version
>=
140
)
||
(
profile
==
EEsProfile
&&
version
>=
310
))
{
(
profile
==
EEsProfile
&&
version
>=
310
))
{
...
@@ -9511,6 +9513,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
...
@@ -9511,6 +9513,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable
(
"gl_in"
,
"gl_BackSecondaryColor"
,
EbvBackSecondaryColor
,
symbolTable
);
BuiltInVariable
(
"gl_in"
,
"gl_BackSecondaryColor"
,
EbvBackSecondaryColor
,
symbolTable
);
BuiltInVariable
(
"gl_in"
,
"gl_TexCoord"
,
EbvTexCoord
,
symbolTable
);
BuiltInVariable
(
"gl_in"
,
"gl_TexCoord"
,
EbvTexCoord
,
symbolTable
);
BuiltInVariable
(
"gl_in"
,
"gl_FogFragCoord"
,
EbvFogFragCoord
,
symbolTable
);
BuiltInVariable
(
"gl_in"
,
"gl_FogFragCoord"
,
EbvFogFragCoord
,
symbolTable
);
// extension requirements
if
(
profile
==
EEsProfile
)
{
symbolTable
.
setVariableExtensions
(
"gl_in"
,
"gl_PointSize"
,
Num_AEP_tessellation_point_size
,
AEP_tessellation_point_size
);
}
break
;
break
;
default
:
default
:
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
28be4543
...
@@ -312,9 +312,6 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
...
@@ -312,9 +312,6 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
if
(
anon
)
{
if
(
anon
)
{
// It was a member of an anonymous container.
// It was a member of an anonymous container.
// The "getNumExtensions()" mechanism above doesn't yet work for block members
blockMemberExtensionCheck
(
loc
,
nullptr
,
*
string
);
// Create a subtree for its dereference.
// Create a subtree for its dereference.
variable
=
anon
->
getAnonContainer
().
getAsVariable
();
variable
=
anon
->
getAnonContainer
().
getAsVariable
();
TIntermTyped
*
container
=
intermediate
.
addSymbol
(
*
variable
,
loc
);
TIntermTyped
*
container
=
intermediate
.
addSymbol
(
*
variable
,
loc
);
...
@@ -834,7 +831,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
...
@@ -834,7 +831,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
if
(
base
->
getType
().
getQualifier
().
isFrontEndConstant
())
if
(
base
->
getType
().
getQualifier
().
isFrontEndConstant
())
result
=
intermediate
.
foldDereference
(
base
,
member
,
loc
);
result
=
intermediate
.
foldDereference
(
base
,
member
,
loc
);
else
{
else
{
blockMemberExtensionCheck
(
loc
,
base
,
field
);
blockMemberExtensionCheck
(
loc
,
base
,
member
,
field
);
TIntermTyped
*
index
=
intermediate
.
addConstantUnion
(
member
,
loc
);
TIntermTyped
*
index
=
intermediate
.
addConstantUnion
(
member
,
loc
);
result
=
intermediate
.
addIndex
(
EOpIndexDirectStruct
,
base
,
index
,
loc
);
result
=
intermediate
.
addIndex
(
EOpIndexDirectStruct
,
base
,
index
,
loc
);
result
->
setType
(
*
(
*
fields
)[
member
].
type
);
result
->
setType
(
*
(
*
fields
)[
member
].
type
);
...
@@ -857,14 +854,30 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
...
@@ -857,14 +854,30 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
return
result
;
return
result
;
}
}
void
TParseContext
::
blockMemberExtensionCheck
(
const
TSourceLoc
&
loc
,
const
TIntermTyped
*
/*base*/
,
const
TString
&
field
)
void
TParseContext
::
blockMemberExtensionCheck
(
const
TSourceLoc
&
loc
,
const
TIntermTyped
*
base
,
int
member
,
const
TString
&
memberName
)
{
{
if
(
profile
==
EEsProfile
&&
field
==
"gl_PointSize"
)
{
// a block that needs extension checking is either 'base', or if arrayed,
if
(
language
==
EShLangGeometry
)
// one level removed to the left
requireExtensions
(
loc
,
Num_AEP_geometry_point_size
,
AEP_geometry_point_size
,
"gl_PointSize"
);
const
TIntermSymbol
*
baseSymbol
=
nullptr
;
else
if
(
language
==
EShLangTessControl
||
language
==
EShLangTessEvaluation
)
if
(
base
->
getAsBinaryNode
()
==
nullptr
)
requireExtensions
(
loc
,
Num_AEP_tessellation_point_size
,
AEP_tessellation_point_size
,
"gl_PointSize"
);
baseSymbol
=
base
->
getAsSymbolNode
();
}
else
baseSymbol
=
base
->
getAsBinaryNode
()
->
getLeft
()
->
getAsSymbolNode
();
if
(
baseSymbol
==
nullptr
)
return
;
const
TSymbol
*
symbol
=
symbolTable
.
find
(
baseSymbol
->
getName
());
if
(
symbol
==
nullptr
)
return
;
const
TVariable
*
variable
=
symbol
->
getAsVariable
();
if
(
variable
==
nullptr
)
return
;
if
(
!
variable
->
hasMemberExtensions
())
return
;
// We now have a variable that is the base of a dot reference
// with members that need extension checking.
if
(
variable
->
getNumMemberExtensions
(
member
)
>
0
)
requireExtensions
(
loc
,
variable
->
getNumMemberExtensions
(
member
),
variable
->
getMemberExtensions
(
member
),
memberName
.
c_str
());
}
}
//
//
...
...
glslang/MachineIndependent/ParseHelper.h
View file @
28be4543
...
@@ -306,7 +306,7 @@ public:
...
@@ -306,7 +306,7 @@ public:
TIntermTyped
*
handleBinaryMath
(
const
TSourceLoc
&
,
const
char
*
str
,
TOperator
op
,
TIntermTyped
*
left
,
TIntermTyped
*
right
);
TIntermTyped
*
handleBinaryMath
(
const
TSourceLoc
&
,
const
char
*
str
,
TOperator
op
,
TIntermTyped
*
left
,
TIntermTyped
*
right
);
TIntermTyped
*
handleUnaryMath
(
const
TSourceLoc
&
,
const
char
*
str
,
TOperator
op
,
TIntermTyped
*
childNode
);
TIntermTyped
*
handleUnaryMath
(
const
TSourceLoc
&
,
const
char
*
str
,
TOperator
op
,
TIntermTyped
*
childNode
);
TIntermTyped
*
handleDotDereference
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
TIntermTyped
*
handleDotDereference
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
void
blockMemberExtensionCheck
(
const
TSourceLoc
&
,
const
TIntermTyped
*
base
,
const
TString
&
field
);
void
blockMemberExtensionCheck
(
const
TSourceLoc
&
,
const
TIntermTyped
*
base
,
int
member
,
const
TString
&
memberName
);
TFunction
*
handleFunctionDeclarator
(
const
TSourceLoc
&
,
TFunction
&
function
,
bool
prototype
);
TFunction
*
handleFunctionDeclarator
(
const
TSourceLoc
&
,
TFunction
&
function
,
bool
prototype
);
TIntermAggregate
*
handleFunctionDefinition
(
const
TSourceLoc
&
,
TFunction
&
);
TIntermAggregate
*
handleFunctionDefinition
(
const
TSourceLoc
&
,
TFunction
&
);
TIntermTyped
*
handleFunctionCall
(
const
TSourceLoc
&
,
TFunction
*
,
TIntermNode
*
);
TIntermTyped
*
handleFunctionCall
(
const
TSourceLoc
&
,
TFunction
*
,
TIntermNode
*
);
...
...
glslang/MachineIndependent/SymbolTable.cpp
View file @
28be4543
...
@@ -287,19 +287,25 @@ TVariable::TVariable(const TVariable& copyOf) : TSymbol(copyOf)
...
@@ -287,19 +287,25 @@ TVariable::TVariable(const TVariable& copyOf) : TSymbol(copyOf)
{
{
type
.
deepCopy
(
copyOf
.
type
);
type
.
deepCopy
(
copyOf
.
type
);
userType
=
copyOf
.
userType
;
userType
=
copyOf
.
userType
;
numExtensions
=
0
;
extensions
=
0
;
// we don't support specialization-constant subtrees in cloned tables, only extensions
if
(
copyOf
.
numExtensions
!=
0
)
constSubtree
=
nullptr
;
setExtensions
(
copyOf
.
numExtensions
,
copyOf
.
extensions
);
extensions
=
nullptr
;
memberExtensions
=
nullptr
;
if
(
copyOf
.
getNumExtensions
()
>
0
)
setExtensions
(
copyOf
.
getNumExtensions
(),
copyOf
.
getExtensions
());
if
(
copyOf
.
hasMemberExtensions
())
{
for
(
int
m
=
0
;
m
<
copyOf
.
type
.
getStruct
()
->
size
();
++
m
)
{
if
(
copyOf
.
getNumMemberExtensions
(
m
)
>
0
)
setMemberExtensions
(
m
,
copyOf
.
getNumMemberExtensions
(
m
),
copyOf
.
getMemberExtensions
(
m
));
}
}
if
(
!
copyOf
.
constArray
.
empty
())
{
if
(
!
copyOf
.
constArray
.
empty
())
{
assert
(
!
copyOf
.
type
.
isStruct
());
assert
(
!
copyOf
.
type
.
isStruct
());
TConstUnionArray
newArray
(
copyOf
.
constArray
,
0
,
copyOf
.
constArray
.
size
());
TConstUnionArray
newArray
(
copyOf
.
constArray
,
0
,
copyOf
.
constArray
.
size
());
constArray
=
newArray
;
constArray
=
newArray
;
}
}
// don't support specialization-constant subtrees in cloned tables
constSubtree
=
nullptr
;
}
}
TVariable
*
TVariable
::
clone
()
const
TVariable
*
TVariable
::
clone
()
const
...
@@ -317,10 +323,9 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
...
@@ -317,10 +323,9 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
parameters
.
back
().
copyParam
(
copyOf
.
parameters
[
i
]);
parameters
.
back
().
copyParam
(
copyOf
.
parameters
[
i
]);
}
}
numExtensions
=
0
;
extensions
=
nullptr
;
extensions
=
0
;
if
(
copyOf
.
getNumExtensions
()
>
0
)
if
(
copyOf
.
extensions
!=
0
)
setExtensions
(
copyOf
.
getNumExtensions
(),
copyOf
.
getExtensions
());
setExtensions
(
copyOf
.
numExtensions
,
copyOf
.
extensions
);
returnType
.
deepCopy
(
copyOf
.
returnType
);
returnType
.
deepCopy
(
copyOf
.
returnType
);
mangledName
=
copyOf
.
mangledName
;
mangledName
=
copyOf
.
mangledName
;
op
=
copyOf
.
op
;
op
=
copyOf
.
op
;
...
@@ -359,12 +364,12 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
...
@@ -359,12 +364,12 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
const
TAnonMember
*
anon
=
iter
->
second
->
getAsAnonMember
();
const
TAnonMember
*
anon
=
iter
->
second
->
getAsAnonMember
();
if
(
anon
)
{
if
(
anon
)
{
// Insert all the anonymous members of this same container at once,
// Insert all the anonymous members of this same container at once,
// avoid inserting the
other
members in the future, once this has been done,
// avoid inserting the
remaining
members in the future, once this has been done,
// allowing them to all be part of the same new container.
// allowing them to all be part of the same new container.
if
(
!
containerCopied
[
anon
->
getAnonId
()])
{
if
(
!
containerCopied
[
anon
->
getAnonId
()])
{
TVariable
*
container
=
anon
->
getAnonContainer
().
clone
();
TVariable
*
container
=
anon
->
getAnonContainer
().
clone
();
container
->
changeName
(
NewPoolTString
(
""
));
container
->
changeName
(
NewPoolTString
(
""
));
// insert the
whole container
// insert the
container and all its members
symTableLevel
->
insert
(
*
container
,
false
);
symTableLevel
->
insert
(
*
container
,
false
);
containerCopied
[
anon
->
getAnonId
()]
=
true
;
containerCopied
[
anon
->
getAnonId
()]
=
true
;
}
}
...
...
glslang/MachineIndependent/SymbolTable.h
View file @
28be4543
...
@@ -79,10 +79,12 @@ class TVariable;
...
@@ -79,10 +79,12 @@ class TVariable;
class
TFunction
;
class
TFunction
;
class
TAnonMember
;
class
TAnonMember
;
typedef
TVector
<
const
char
*>
TExtensionList
;
class
TSymbol
{
class
TSymbol
{
public
:
public
:
POOL_ALLOCATOR_NEW_DELETE
(
GetThreadPoolAllocator
())
POOL_ALLOCATOR_NEW_DELETE
(
GetThreadPoolAllocator
())
explicit
TSymbol
(
const
TString
*
n
)
:
name
(
n
),
numExtensions
(
0
),
extensions
(
0
),
writable
(
true
)
{
}
explicit
TSymbol
(
const
TString
*
n
)
:
name
(
n
),
extensions
(
0
),
writable
(
true
)
{
}
virtual
TSymbol
*
clone
()
const
=
0
;
virtual
TSymbol
*
clone
()
const
=
0
;
virtual
~
TSymbol
()
{
}
// rely on all symbol owned memory coming from the pool
virtual
~
TSymbol
()
{
}
// rely on all symbol owned memory coming from the pool
...
@@ -104,17 +106,16 @@ public:
...
@@ -104,17 +106,16 @@ public:
virtual
TType
&
getWritableType
()
=
0
;
virtual
TType
&
getWritableType
()
=
0
;
virtual
void
setUniqueId
(
int
id
)
{
uniqueId
=
id
;
}
virtual
void
setUniqueId
(
int
id
)
{
uniqueId
=
id
;
}
virtual
int
getUniqueId
()
const
{
return
uniqueId
;
}
virtual
int
getUniqueId
()
const
{
return
uniqueId
;
}
virtual
void
setExtensions
(
int
num
,
const
char
*
const
exts
[])
virtual
void
setExtensions
(
int
num
Exts
,
const
char
*
const
exts
[])
{
{
assert
(
extensions
==
0
);
assert
(
extensions
==
0
);
assert
(
num
>
0
);
assert
(
numExts
>
0
);
numExtensions
=
num
;
extensions
=
NewPoolObject
(
extensions
);
extensions
=
NewPoolObject
(
exts
[
0
],
num
);
for
(
int
e
=
0
;
e
<
numExts
;
++
e
)
for
(
int
e
=
0
;
e
<
num
;
++
e
)
extensions
->
push_back
(
exts
[
e
]);
extensions
[
e
]
=
exts
[
e
];
}
}
virtual
int
getNumExtensions
()
const
{
return
extensions
==
nullptr
?
0
:
(
int
)
extensions
->
size
();
}
virtual
int
getNumExtensions
()
const
{
return
numExtensions
;
}
virtual
const
char
**
getExtensions
()
const
{
return
extensions
->
data
();
}
virtual
const
char
**
getExtensions
()
const
{
return
extensions
;
}
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
=
0
;
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
=
0
;
virtual
bool
isReadOnly
()
const
{
return
!
writable
;
}
virtual
bool
isReadOnly
()
const
{
return
!
writable
;
}
...
@@ -129,8 +130,7 @@ protected:
...
@@ -129,8 +130,7 @@ protected:
// For tracking what extensions must be present
// For tracking what extensions must be present
// (don't use if correct version/profile is present).
// (don't use if correct version/profile is present).
int
numExtensions
;
TExtensionList
*
extensions
;
// an array of pointers to existing constant char strings
const
char
**
extensions
;
// an array of pointers to existing constant char strings
//
//
// N.B.: Non-const functions that will be generally used should assert on this,
// N.B.: Non-const functions that will be generally used should assert on this,
...
@@ -155,7 +155,9 @@ public:
...
@@ -155,7 +155,9 @@ public:
:
TSymbol
(
name
),
:
TSymbol
(
name
),
userType
(
uT
),
userType
(
uT
),
constSubtree
(
nullptr
),
constSubtree
(
nullptr
),
anonId
(
-
1
)
{
type
.
shallowCopy
(
t
);
}
memberExtensions
(
nullptr
),
anonId
(
-
1
)
{
type
.
shallowCopy
(
t
);
}
virtual
TVariable
*
clone
()
const
;
virtual
TVariable
*
clone
()
const
;
virtual
~
TVariable
()
{
}
virtual
~
TVariable
()
{
}
...
@@ -172,6 +174,24 @@ public:
...
@@ -172,6 +174,24 @@ public:
virtual
void
setAnonId
(
int
i
)
{
anonId
=
i
;
}
virtual
void
setAnonId
(
int
i
)
{
anonId
=
i
;
}
virtual
int
getAnonId
()
const
{
return
anonId
;
}
virtual
int
getAnonId
()
const
{
return
anonId
;
}
virtual
void
setMemberExtensions
(
int
member
,
int
numExts
,
const
char
*
const
exts
[])
{
assert
(
type
.
isStruct
());
assert
(
numExts
>
0
);
if
(
memberExtensions
==
nullptr
)
{
memberExtensions
=
NewPoolObject
(
memberExtensions
);
memberExtensions
->
resize
(
type
.
getStruct
()
->
size
());
}
for
(
int
e
=
0
;
e
<
numExts
;
++
e
)
(
*
memberExtensions
)[
member
].
push_back
(
exts
[
e
]);
}
virtual
bool
hasMemberExtensions
()
const
{
return
memberExtensions
!=
nullptr
;
}
virtual
int
getNumMemberExtensions
(
int
member
)
const
{
return
memberExtensions
==
nullptr
?
0
:
(
int
)(
*
memberExtensions
)[
member
].
size
();
}
virtual
const
char
**
getMemberExtensions
(
int
member
)
const
{
return
(
*
memberExtensions
)[
member
].
data
();
}
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
;
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
;
protected
:
protected
:
...
@@ -180,15 +200,14 @@ protected:
...
@@ -180,15 +200,14 @@ protected:
TType
type
;
TType
type
;
bool
userType
;
bool
userType
;
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed
// when this object is destroyed
// TODO: these two should be a union
TConstUnionArray
constArray
;
// for compile-time constant value
// A variable could be a compile-time constant, or a specialization
TIntermTyped
*
constSubtree
;
// for specialization constant computation
// constant, or neither, but never both.
TVector
<
TExtensionList
>*
memberExtensions
;
// per-member extension list, allocated only when needed
TConstUnionArray
constArray
;
// for compile-time constant value
int
anonId
;
// the ID used for anonymous blocks: TODO: see if uniqueId could serve a dual purpose
TIntermTyped
*
constSubtree
;
// for specialization constant computation
int
anonId
;
// the ID used for anonymous blocks: TODO: see if uniqueId could serve a dual purpose
};
};
//
//
...
@@ -325,7 +344,7 @@ protected:
...
@@ -325,7 +344,7 @@ protected:
//
//
class
TAnonMember
:
public
TSymbol
{
class
TAnonMember
:
public
TSymbol
{
public
:
public
:
TAnonMember
(
const
TString
*
n
,
unsigned
int
m
,
const
TVariable
&
a
,
int
an
)
:
TSymbol
(
n
),
anonContainer
(
a
),
memberNumber
(
m
),
anonId
(
an
)
{
}
TAnonMember
(
const
TString
*
n
,
unsigned
int
m
,
TVariable
&
a
,
int
an
)
:
TSymbol
(
n
),
anonContainer
(
a
),
memberNumber
(
m
),
anonId
(
an
)
{
}
virtual
TAnonMember
*
clone
()
const
;
virtual
TAnonMember
*
clone
()
const
;
virtual
~
TAnonMember
()
{
}
virtual
~
TAnonMember
()
{
}
...
@@ -346,6 +365,13 @@ public:
...
@@ -346,6 +365,13 @@ public:
return
*
types
[
memberNumber
].
type
;
return
*
types
[
memberNumber
].
type
;
}
}
virtual
void
setExtensions
(
int
numExts
,
const
char
*
const
exts
[])
override
{
anonContainer
.
setMemberExtensions
(
memberNumber
,
numExts
,
exts
);
}
virtual
int
getNumExtensions
()
const
override
{
return
anonContainer
.
getNumMemberExtensions
(
memberNumber
);
}
virtual
const
char
**
getExtensions
()
const
override
{
return
anonContainer
.
getMemberExtensions
(
memberNumber
);
}
virtual
int
getAnonId
()
const
{
return
anonId
;
}
virtual
int
getAnonId
()
const
{
return
anonId
;
}
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
;
virtual
void
dump
(
TInfoSink
&
infoSink
)
const
;
...
@@ -353,7 +379,7 @@ protected:
...
@@ -353,7 +379,7 @@ protected:
explicit
TAnonMember
(
const
TAnonMember
&
);
explicit
TAnonMember
(
const
TAnonMember
&
);
TAnonMember
&
operator
=
(
const
TAnonMember
&
);
TAnonMember
&
operator
=
(
const
TAnonMember
&
);
const
TVariable
&
anonContainer
;
TVariable
&
anonContainer
;
unsigned
int
memberNumber
;
unsigned
int
memberNumber
;
int
anonId
;
int
anonId
;
};
};
...
@@ -789,11 +815,30 @@ public:
...
@@ -789,11 +815,30 @@ public:
table
[
level
]
->
setFunctionExtensions
(
name
,
num
,
extensions
);
table
[
level
]
->
setFunctionExtensions
(
name
,
num
,
extensions
);
}
}
void
setVariableExtensions
(
const
char
*
name
,
int
num
,
const
char
*
const
extensions
[])
void
setVariableExtensions
(
const
char
*
name
,
int
num
Exts
,
const
char
*
const
extensions
[])
{
{
TSymbol
*
symbol
=
find
(
TString
(
name
));
TSymbol
*
symbol
=
find
(
TString
(
name
));
if
(
symbol
)
if
(
symbol
==
nullptr
)
symbol
->
setExtensions
(
num
,
extensions
);
return
;
symbol
->
setExtensions
(
numExts
,
extensions
);
}
void
setVariableExtensions
(
const
char
*
blockName
,
const
char
*
name
,
int
numExts
,
const
char
*
const
extensions
[])
{
TSymbol
*
symbol
=
find
(
TString
(
blockName
));
if
(
symbol
==
nullptr
)
return
;
TVariable
*
variable
=
symbol
->
getAsVariable
();
assert
(
variable
!=
nullptr
);
const
TTypeList
&
structure
=
*
variable
->
getAsVariable
()
->
getType
().
getStruct
();
for
(
int
member
=
0
;
member
<
(
int
)
structure
.
size
();
++
member
)
{
if
(
structure
[
member
].
type
->
getFieldName
().
compare
(
name
)
==
0
)
{
variable
->
setMemberExtensions
(
member
,
numExts
,
extensions
);
return
;
}
}
}
}
int
getMaxSymbolId
()
{
return
uniqueId
;
}
int
getMaxSymbolId
()
{
return
uniqueId
;
}
...
...
hlsl/hlslParseHelper.cpp
View file @
28be4543
...
@@ -653,10 +653,6 @@ TIntermTyped* HlslParseContext::handleVariable(const TSourceLoc& loc, const TStr
...
@@ -653,10 +653,6 @@ TIntermTyped* HlslParseContext::handleVariable(const TSourceLoc& loc, const TStr
return
nullptr
;
return
nullptr
;
}
}
// Error check for requiring specific extensions present.
if
(
symbol
&&
symbol
->
getNumExtensions
())
requireExtensions
(
loc
,
symbol
->
getNumExtensions
(),
symbol
->
getExtensions
(),
symbol
->
getName
().
c_str
());
const
TVariable
*
variable
=
nullptr
;
const
TVariable
*
variable
=
nullptr
;
const
TAnonMember
*
anon
=
symbol
?
symbol
->
getAsAnonMember
()
:
nullptr
;
const
TAnonMember
*
anon
=
symbol
?
symbol
->
getAsAnonMember
()
:
nullptr
;
TIntermTyped
*
node
=
nullptr
;
TIntermTyped
*
node
=
nullptr
;
...
@@ -5321,11 +5317,6 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
...
@@ -5321,11 +5317,6 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
// - a built-in function not mapped to an operator, or
// - a built-in function not mapped to an operator, or
// - a user function.
// - a user function.
// Error check for a function requiring specific extensions present.
if
(
builtIn
&&
fnCandidate
->
getNumExtensions
())
requireExtensions
(
loc
,
fnCandidate
->
getNumExtensions
(),
fnCandidate
->
getExtensions
(),
fnCandidate
->
getName
().
c_str
());
// turn an implicit member-function resolution into an explicit call
// turn an implicit member-function resolution into an explicit call
TString
callerName
;
TString
callerName
;
if
(
thisDepth
==
0
)
if
(
thisDepth
==
0
)
...
...
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