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
a26a5170
Commit
a26a5170
authored
Jul 28, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Non-functional: Rationalize location and use of mapTypeToConstructor().
parent
c552aece
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
163 additions
and
288 deletions
+163
-288
revision.h
glslang/Include/revision.h
+2
-2
Intermediate.cpp
glslang/MachineIndependent/Intermediate.cpp
+144
-0
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+7
-150
ParseHelper.h
glslang/MachineIndependent/ParseHelper.h
+1
-2
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+1
-0
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+7
-132
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-2
No files found.
glslang/Include/revision.h
View file @
a26a5170
...
@@ -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 "SPIRV99.135
3
"
#define GLSLANG_REVISION "SPIRV99.135
4
"
#define GLSLANG_DATE "2
7
-Jul-2016"
#define GLSLANG_DATE "2
8
-Jul-2016"
glslang/MachineIndependent/Intermediate.cpp
View file @
a26a5170
...
@@ -752,6 +752,150 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to) const
...
@@ -752,6 +752,150 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to) const
}
}
//
//
// Given a type, find what operation would fully construct it.
//
TOperator
TIntermediate
::
mapTypeToConstructorOp
(
const
TType
&
type
)
const
{
TOperator
op
=
EOpNull
;
switch
(
type
.
getBasicType
())
{
case
EbtStruct
:
op
=
EOpConstructStruct
;
break
;
case
EbtSampler
:
if
(
type
.
getSampler
().
combined
)
op
=
EOpConstructTextureSampler
;
break
;
case
EbtFloat
:
if
(
type
.
isMatrix
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat2x2
;
break
;
case
3
:
op
=
EOpConstructMat2x3
;
break
;
case
4
:
op
=
EOpConstructMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat3x2
;
break
;
case
3
:
op
=
EOpConstructMat3x3
;
break
;
case
4
:
op
=
EOpConstructMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat4x2
;
break
;
case
3
:
op
=
EOpConstructMat4x3
;
break
;
case
4
:
op
=
EOpConstructMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
// some compilers want this
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructFloat
;
break
;
case
2
:
op
=
EOpConstructVec2
;
break
;
case
3
:
op
=
EOpConstructVec3
;
break
;
case
4
:
op
=
EOpConstructVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtDouble
:
if
(
type
.
getMatrixCols
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat2x2
;
break
;
case
3
:
op
=
EOpConstructDMat2x3
;
break
;
case
4
:
op
=
EOpConstructDMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat3x2
;
break
;
case
3
:
op
=
EOpConstructDMat3x3
;
break
;
case
4
:
op
=
EOpConstructDMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat4x2
;
break
;
case
3
:
op
=
EOpConstructDMat4x3
;
break
;
case
4
:
op
=
EOpConstructDMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructDouble
;
break
;
case
2
:
op
=
EOpConstructDVec2
;
break
;
case
3
:
op
=
EOpConstructDVec3
;
break
;
case
4
:
op
=
EOpConstructDVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtInt
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructInt
;
break
;
case
2
:
op
=
EOpConstructIVec2
;
break
;
case
3
:
op
=
EOpConstructIVec3
;
break
;
case
4
:
op
=
EOpConstructIVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtUint
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructUint
;
break
;
case
2
:
op
=
EOpConstructUVec2
;
break
;
case
3
:
op
=
EOpConstructUVec3
;
break
;
case
4
:
op
=
EOpConstructUVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtInt64
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructInt64
;
break
;
case
2
:
op
=
EOpConstructI64Vec2
;
break
;
case
3
:
op
=
EOpConstructI64Vec3
;
break
;
case
4
:
op
=
EOpConstructI64Vec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtUint64
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructUint64
;
break
;
case
2
:
op
=
EOpConstructU64Vec2
;
break
;
case
3
:
op
=
EOpConstructU64Vec3
;
break
;
case
4
:
op
=
EOpConstructU64Vec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtBool
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructBool
;
break
;
case
2
:
op
=
EOpConstructBVec2
;
break
;
case
3
:
op
=
EOpConstructBVec3
;
break
;
case
4
:
op
=
EOpConstructBVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
}
return
op
;
}
//
// Safe way to combine two nodes into an aggregate. Works with null pointers,
// Safe way to combine two nodes into an aggregate. Works with null pointers,
// a node that's not a aggregate yet, etc.
// a node that's not a aggregate yet, etc.
//
//
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
a26a5170
...
@@ -850,7 +850,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
...
@@ -850,7 +850,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
// Swizzle operations propagate specialization-constantness
// Swizzle operations propagate specialization-constantness
if
(
base
->
getQualifier
().
isSpecConstant
())
if
(
base
->
getQualifier
().
isSpecConstant
())
type
.
getQualifier
().
makeSpecConstant
();
type
.
getQualifier
().
makeSpecConstant
();
return
addConstructor
(
loc
,
base
,
type
,
mapTypeToConstructorOp
(
type
)
);
return
addConstructor
(
loc
,
base
,
type
);
}
}
}
}
...
@@ -1092,7 +1092,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
...
@@ -1092,7 +1092,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
//
//
// It's a constructor, of type 'type'.
// It's a constructor, of type 'type'.
//
//
result
=
addConstructor
(
loc
,
arguments
,
type
,
op
);
result
=
addConstructor
(
loc
,
arguments
,
type
);
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
}
}
...
@@ -1736,7 +1736,7 @@ TFunction* TParseContext::handleConstructorCall(const TSourceLoc& loc, const TPu
...
@@ -1736,7 +1736,7 @@ TFunction* TParseContext::handleConstructorCall(const TSourceLoc& loc, const TPu
profileRequires
(
loc
,
EEsProfile
,
300
,
nullptr
,
"arrayed constructor"
);
profileRequires
(
loc
,
EEsProfile
,
300
,
nullptr
,
"arrayed constructor"
);
}
}
TOperator
op
=
mapTypeToConstructorOp
(
type
);
TOperator
op
=
intermediate
.
mapTypeToConstructorOp
(
type
);
if
(
op
==
EOpNull
)
{
if
(
op
==
EOpNull
)
{
error
(
loc
,
"cannot construct this type"
,
type
.
getBasicString
(),
""
);
error
(
loc
,
"cannot construct this type"
,
type
.
getBasicString
(),
""
);
...
@@ -1751,150 +1751,6 @@ TFunction* TParseContext::handleConstructorCall(const TSourceLoc& loc, const TPu
...
@@ -1751,150 +1751,6 @@ TFunction* TParseContext::handleConstructorCall(const TSourceLoc& loc, const TPu
}
}
//
//
// Given a type, find what operation would fully construct it.
//
TOperator
TParseContext
::
mapTypeToConstructorOp
(
const
TType
&
type
)
const
{
TOperator
op
=
EOpNull
;
switch
(
type
.
getBasicType
())
{
case
EbtStruct
:
op
=
EOpConstructStruct
;
break
;
case
EbtSampler
:
if
(
type
.
getSampler
().
combined
)
op
=
EOpConstructTextureSampler
;
break
;
case
EbtFloat
:
if
(
type
.
isMatrix
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat2x2
;
break
;
case
3
:
op
=
EOpConstructMat2x3
;
break
;
case
4
:
op
=
EOpConstructMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat3x2
;
break
;
case
3
:
op
=
EOpConstructMat3x3
;
break
;
case
4
:
op
=
EOpConstructMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat4x2
;
break
;
case
3
:
op
=
EOpConstructMat4x3
;
break
;
case
4
:
op
=
EOpConstructMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
// some compilers want this
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructFloat
;
break
;
case
2
:
op
=
EOpConstructVec2
;
break
;
case
3
:
op
=
EOpConstructVec3
;
break
;
case
4
:
op
=
EOpConstructVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtDouble
:
if
(
type
.
getMatrixCols
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat2x2
;
break
;
case
3
:
op
=
EOpConstructDMat2x3
;
break
;
case
4
:
op
=
EOpConstructDMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat3x2
;
break
;
case
3
:
op
=
EOpConstructDMat3x3
;
break
;
case
4
:
op
=
EOpConstructDMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat4x2
;
break
;
case
3
:
op
=
EOpConstructDMat4x3
;
break
;
case
4
:
op
=
EOpConstructDMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructDouble
;
break
;
case
2
:
op
=
EOpConstructDVec2
;
break
;
case
3
:
op
=
EOpConstructDVec3
;
break
;
case
4
:
op
=
EOpConstructDVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtInt
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructInt
;
break
;
case
2
:
op
=
EOpConstructIVec2
;
break
;
case
3
:
op
=
EOpConstructIVec3
;
break
;
case
4
:
op
=
EOpConstructIVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtUint
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructUint
;
break
;
case
2
:
op
=
EOpConstructUVec2
;
break
;
case
3
:
op
=
EOpConstructUVec3
;
break
;
case
4
:
op
=
EOpConstructUVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtInt64
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructInt64
;
break
;
case
2
:
op
=
EOpConstructI64Vec2
;
break
;
case
3
:
op
=
EOpConstructI64Vec3
;
break
;
case
4
:
op
=
EOpConstructI64Vec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtUint64
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructUint64
;
break
;
case
2
:
op
=
EOpConstructU64Vec2
;
break
;
case
3
:
op
=
EOpConstructU64Vec3
;
break
;
case
4
:
op
=
EOpConstructU64Vec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtBool
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructBool
;
break
;
case
2
:
op
=
EOpConstructBVec2
;
break
;
case
3
:
op
=
EOpConstructBVec3
;
break
;
case
4
:
op
=
EOpConstructBVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
}
return
op
;
}
//
// Same error message for all places assignments don't work.
// Same error message for all places assignments don't work.
//
//
void
TParseContext
::
assignError
(
const
TSourceLoc
&
loc
,
const
char
*
op
,
TString
left
,
TString
right
)
void
TParseContext
::
assignError
(
const
TSourceLoc
&
loc
,
const
char
*
op
,
TString
left
,
TString
right
)
...
@@ -5257,7 +5113,7 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
...
@@ -5257,7 +5113,7 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
return
nullptr
;
return
nullptr
;
}
}
return
addConstructor
(
loc
,
initList
,
arrayType
,
mapTypeToConstructorOp
(
arrayType
)
);
return
addConstructor
(
loc
,
initList
,
arrayType
);
}
else
if
(
type
.
isStruct
())
{
}
else
if
(
type
.
isStruct
())
{
if
(
type
.
getStruct
()
->
size
()
!=
initList
->
getSequence
().
size
())
{
if
(
type
.
getStruct
()
->
size
()
!=
initList
->
getSequence
().
size
())
{
error
(
loc
,
"wrong number of structure members"
,
"initializer list"
,
""
);
error
(
loc
,
"wrong number of structure members"
,
"initializer list"
,
""
);
...
@@ -5290,7 +5146,7 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
...
@@ -5290,7 +5146,7 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
}
}
// now that the subtree is processed, process this node
// now that the subtree is processed, process this node
return
addConstructor
(
loc
,
initList
,
type
,
mapTypeToConstructorOp
(
type
)
);
return
addConstructor
(
loc
,
initList
,
type
);
}
}
//
//
...
@@ -5299,13 +5155,14 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
...
@@ -5299,13 +5155,14 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
//
//
// Returns nullptr for an error or the constructed node (aggregate or typed) for no error.
// Returns nullptr for an error or the constructed node (aggregate or typed) for no error.
//
//
TIntermTyped
*
TParseContext
::
addConstructor
(
const
TSourceLoc
&
loc
,
TIntermNode
*
node
,
const
TType
&
type
,
TOperator
op
)
TIntermTyped
*
TParseContext
::
addConstructor
(
const
TSourceLoc
&
loc
,
TIntermNode
*
node
,
const
TType
&
type
)
{
{
if
(
node
==
nullptr
||
node
->
getAsTyped
()
==
nullptr
)
if
(
node
==
nullptr
||
node
->
getAsTyped
()
==
nullptr
)
return
nullptr
;
return
nullptr
;
rValueErrorCheck
(
loc
,
"constructor"
,
node
->
getAsTyped
());
rValueErrorCheck
(
loc
,
"constructor"
,
node
->
getAsTyped
());
TIntermAggregate
*
aggrNode
=
node
->
getAsAggregate
();
TIntermAggregate
*
aggrNode
=
node
->
getAsAggregate
();
TOperator
op
=
intermediate
.
mapTypeToConstructorOp
(
type
);
// Combined texture-sampler constructors are completely semantic checked
// Combined texture-sampler constructors are completely semantic checked
// in constructorTextureSamplerError()
// in constructorTextureSamplerError()
...
...
glslang/MachineIndependent/ParseHelper.h
View file @
a26a5170
...
@@ -276,7 +276,7 @@ public:
...
@@ -276,7 +276,7 @@ public:
const
TFunction
*
findFunction400
(
const
TSourceLoc
&
loc
,
const
TFunction
&
call
,
bool
&
builtIn
);
const
TFunction
*
findFunction400
(
const
TSourceLoc
&
loc
,
const
TFunction
&
call
,
bool
&
builtIn
);
void
declareTypeDefaults
(
const
TSourceLoc
&
,
const
TPublicType
&
);
void
declareTypeDefaults
(
const
TSourceLoc
&
,
const
TPublicType
&
);
TIntermNode
*
declareVariable
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TPublicType
&
,
TArraySizes
*
typeArray
=
0
,
TIntermTyped
*
initializer
=
0
);
TIntermNode
*
declareVariable
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TPublicType
&
,
TArraySizes
*
typeArray
=
0
,
TIntermTyped
*
initializer
=
0
);
TIntermTyped
*
addConstructor
(
const
TSourceLoc
&
,
TIntermNode
*
,
const
TType
&
,
TOperator
);
TIntermTyped
*
addConstructor
(
const
TSourceLoc
&
,
TIntermNode
*
,
const
TType
&
);
TIntermTyped
*
constructAggregate
(
TIntermNode
*
,
const
TType
&
,
int
,
const
TSourceLoc
&
);
TIntermTyped
*
constructAggregate
(
TIntermNode
*
,
const
TType
&
,
int
,
const
TSourceLoc
&
);
TIntermTyped
*
constructBuiltIn
(
const
TType
&
,
TOperator
,
TIntermTyped
*
,
const
TSourceLoc
&
,
bool
subset
);
TIntermTyped
*
constructBuiltIn
(
const
TType
&
,
TOperator
,
TIntermTyped
*
,
const
TSourceLoc
&
,
bool
subset
);
void
declareBlock
(
const
TSourceLoc
&
,
TTypeList
&
typeList
,
const
TString
*
instanceName
=
0
,
TArraySizes
*
arraySizes
=
0
);
void
declareBlock
(
const
TSourceLoc
&
,
TTypeList
&
typeList
,
const
TString
*
instanceName
=
0
,
TArraySizes
*
arraySizes
=
0
);
...
@@ -302,7 +302,6 @@ protected:
...
@@ -302,7 +302,6 @@ protected:
void
declareArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TSymbol
*&
,
bool
&
newDeclaration
);
void
declareArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TSymbol
*&
,
bool
&
newDeclaration
);
TIntermNode
*
executeInitializer
(
const
TSourceLoc
&
,
TIntermTyped
*
initializer
,
TVariable
*
variable
);
TIntermNode
*
executeInitializer
(
const
TSourceLoc
&
,
TIntermTyped
*
initializer
,
TVariable
*
variable
);
TIntermTyped
*
convertInitializerList
(
const
TSourceLoc
&
,
const
TType
&
,
TIntermTyped
*
initializer
);
TIntermTyped
*
convertInitializerList
(
const
TSourceLoc
&
,
const
TType
&
,
TIntermTyped
*
initializer
);
TOperator
mapTypeToConstructorOp
(
const
TType
&
)
const
;
void
finalErrorCheck
();
void
finalErrorCheck
();
void
outputMessage
(
const
TSourceLoc
&
,
const
char
*
szReason
,
const
char
*
szToken
,
void
outputMessage
(
const
TSourceLoc
&
,
const
char
*
szReason
,
const
char
*
szToken
,
const
char
*
szExtraInfoFormat
,
TPrefixType
prefix
,
const
char
*
szExtraInfoFormat
,
TPrefixType
prefix
,
...
...
glslang/MachineIndependent/localintermediate.h
View file @
a26a5170
...
@@ -189,6 +189,7 @@ public:
...
@@ -189,6 +189,7 @@ public:
TIntermTyped
*
addUnaryMath
(
TOperator
,
TIntermTyped
*
child
,
TSourceLoc
);
TIntermTyped
*
addUnaryMath
(
TOperator
,
TIntermTyped
*
child
,
TSourceLoc
);
TIntermTyped
*
addBuiltInFunctionCall
(
const
TSourceLoc
&
line
,
TOperator
,
bool
unary
,
TIntermNode
*
,
const
TType
&
returnType
);
TIntermTyped
*
addBuiltInFunctionCall
(
const
TSourceLoc
&
line
,
TOperator
,
bool
unary
,
TIntermNode
*
,
const
TType
&
returnType
);
bool
canImplicitlyPromote
(
TBasicType
from
,
TBasicType
to
)
const
;
bool
canImplicitlyPromote
(
TBasicType
from
,
TBasicType
to
)
const
;
TOperator
mapTypeToConstructorOp
(
const
TType
&
)
const
;
TIntermAggregate
*
growAggregate
(
TIntermNode
*
left
,
TIntermNode
*
right
);
TIntermAggregate
*
growAggregate
(
TIntermNode
*
left
,
TIntermNode
*
right
);
TIntermAggregate
*
growAggregate
(
TIntermNode
*
left
,
TIntermNode
*
right
,
const
TSourceLoc
&
);
TIntermAggregate
*
growAggregate
(
TIntermNode
*
left
,
TIntermNode
*
right
,
const
TSourceLoc
&
);
TIntermAggregate
*
makeAggregate
(
TIntermNode
*
node
);
TIntermAggregate
*
makeAggregate
(
TIntermNode
*
node
);
...
...
hlsl/hlslParseHelper.cpp
View file @
a26a5170
...
@@ -624,7 +624,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
...
@@ -624,7 +624,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
return
result
;
return
result
;
else
{
else
{
TType
type
(
base
->
getBasicType
(),
EvqTemporary
,
fields
.
num
);
TType
type
(
base
->
getBasicType
(),
EvqTemporary
,
fields
.
num
);
return
addConstructor
(
loc
,
base
,
type
,
mapTypeToConstructorOp
(
type
)
);
return
addConstructor
(
loc
,
base
,
type
);
}
}
}
}
...
@@ -1684,7 +1684,7 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
...
@@ -1684,7 +1684,7 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
//
//
// It's a constructor, of type 'type'.
// It's a constructor, of type 'type'.
//
//
result
=
addConstructor
(
loc
,
arguments
,
type
,
op
);
result
=
addConstructor
(
loc
,
arguments
,
type
);
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
}
}
...
@@ -2090,7 +2090,7 @@ void HlslParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fn
...
@@ -2090,7 +2090,7 @@ void HlslParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fn
//
//
TFunction
*
HlslParseContext
::
handleConstructorCall
(
const
TSourceLoc
&
loc
,
const
TType
&
type
)
TFunction
*
HlslParseContext
::
handleConstructorCall
(
const
TSourceLoc
&
loc
,
const
TType
&
type
)
{
{
TOperator
op
=
mapTypeToConstructorOp
(
type
);
TOperator
op
=
intermediate
.
mapTypeToConstructorOp
(
type
);
if
(
op
==
EOpNull
)
{
if
(
op
==
EOpNull
)
{
error
(
loc
,
"cannot construct this type"
,
type
.
getBasicString
(),
""
);
error
(
loc
,
"cannot construct this type"
,
type
.
getBasicString
(),
""
);
...
@@ -2135,132 +2135,6 @@ void HlslParseContext::handleSemantic(TType& type, const TString& semantic)
...
@@ -2135,132 +2135,6 @@ void HlslParseContext::handleSemantic(TType& type, const TString& semantic)
}
}
//
//
// Given a type, find what operation would fully construct it.
//
TOperator
HlslParseContext
::
mapTypeToConstructorOp
(
const
TType
&
type
)
const
{
TOperator
op
=
EOpNull
;
switch
(
type
.
getBasicType
())
{
case
EbtStruct
:
op
=
EOpConstructStruct
;
break
;
case
EbtSampler
:
if
(
type
.
getSampler
().
combined
)
op
=
EOpConstructTextureSampler
;
break
;
case
EbtFloat
:
if
(
type
.
isMatrix
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat2x2
;
break
;
case
3
:
op
=
EOpConstructMat2x3
;
break
;
case
4
:
op
=
EOpConstructMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat3x2
;
break
;
case
3
:
op
=
EOpConstructMat3x3
;
break
;
case
4
:
op
=
EOpConstructMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructMat4x2
;
break
;
case
3
:
op
=
EOpConstructMat4x3
;
break
;
case
4
:
op
=
EOpConstructMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
// some compilers want this
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructFloat
;
break
;
case
2
:
op
=
EOpConstructVec2
;
break
;
case
3
:
op
=
EOpConstructVec3
;
break
;
case
4
:
op
=
EOpConstructVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtDouble
:
if
(
type
.
getMatrixCols
())
{
switch
(
type
.
getMatrixCols
())
{
case
2
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat2x2
;
break
;
case
3
:
op
=
EOpConstructDMat2x3
;
break
;
case
4
:
op
=
EOpConstructDMat2x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
3
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat3x2
;
break
;
case
3
:
op
=
EOpConstructDMat3x3
;
break
;
case
4
:
op
=
EOpConstructDMat3x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
4
:
switch
(
type
.
getMatrixRows
())
{
case
2
:
op
=
EOpConstructDMat4x2
;
break
;
case
3
:
op
=
EOpConstructDMat4x3
;
break
;
case
4
:
op
=
EOpConstructDMat4x4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
}
}
else
{
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructDouble
;
break
;
case
2
:
op
=
EOpConstructDVec2
;
break
;
case
3
:
op
=
EOpConstructDVec3
;
break
;
case
4
:
op
=
EOpConstructDVec4
;
break
;
default
:
break
;
// some compilers want this
}
}
break
;
case
EbtInt
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructInt
;
break
;
case
2
:
op
=
EOpConstructIVec2
;
break
;
case
3
:
op
=
EOpConstructIVec3
;
break
;
case
4
:
op
=
EOpConstructIVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtUint
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructUint
;
break
;
case
2
:
op
=
EOpConstructUVec2
;
break
;
case
3
:
op
=
EOpConstructUVec3
;
break
;
case
4
:
op
=
EOpConstructUVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
case
EbtBool
:
switch
(
type
.
getVectorSize
())
{
case
1
:
op
=
EOpConstructBool
;
break
;
case
2
:
op
=
EOpConstructBVec2
;
break
;
case
3
:
op
=
EOpConstructBVec3
;
break
;
case
4
:
op
=
EOpConstructBVec4
;
break
;
default
:
break
;
// some compilers want this
}
break
;
default
:
break
;
}
return
op
;
}
//
// Same error message for all places assignments don't work.
// Same error message for all places assignments don't work.
//
//
void
HlslParseContext
::
assignError
(
const
TSourceLoc
&
loc
,
const
char
*
op
,
TString
left
,
TString
right
)
void
HlslParseContext
::
assignError
(
const
TSourceLoc
&
loc
,
const
char
*
op
,
TString
left
,
TString
right
)
...
@@ -3744,7 +3618,7 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
...
@@ -3744,7 +3618,7 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
return
nullptr
;
return
nullptr
;
}
}
return
addConstructor
(
loc
,
initList
,
arrayType
,
mapTypeToConstructorOp
(
arrayType
)
);
return
addConstructor
(
loc
,
initList
,
arrayType
);
}
else
if
(
type
.
isStruct
())
{
}
else
if
(
type
.
isStruct
())
{
if
(
type
.
getStruct
()
->
size
()
!=
initList
->
getSequence
().
size
())
{
if
(
type
.
getStruct
()
->
size
()
!=
initList
->
getSequence
().
size
())
{
error
(
loc
,
"wrong number of structure members"
,
"initializer list"
,
""
);
error
(
loc
,
"wrong number of structure members"
,
"initializer list"
,
""
);
...
@@ -3777,7 +3651,7 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
...
@@ -3777,7 +3651,7 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
}
}
// now that the subtree is processed, process this node
// now that the subtree is processed, process this node
return
addConstructor
(
loc
,
initList
,
type
,
mapTypeToConstructorOp
(
type
)
);
return
addConstructor
(
loc
,
initList
,
type
);
}
}
//
//
...
@@ -3786,12 +3660,13 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
...
@@ -3786,12 +3660,13 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
//
//
// Returns nullptr for an error or the constructed node (aggregate or typed) for no error.
// Returns nullptr for an error or the constructed node (aggregate or typed) for no error.
//
//
TIntermTyped
*
HlslParseContext
::
addConstructor
(
const
TSourceLoc
&
loc
,
TIntermNode
*
node
,
const
TType
&
type
,
TOperator
op
)
TIntermTyped
*
HlslParseContext
::
addConstructor
(
const
TSourceLoc
&
loc
,
TIntermNode
*
node
,
const
TType
&
type
)
{
{
if
(
node
==
nullptr
||
node
->
getAsTyped
()
==
nullptr
)
if
(
node
==
nullptr
||
node
->
getAsTyped
()
==
nullptr
)
return
nullptr
;
return
nullptr
;
TIntermAggregate
*
aggrNode
=
node
->
getAsAggregate
();
TIntermAggregate
*
aggrNode
=
node
->
getAsAggregate
();
TOperator
op
=
intermediate
.
mapTypeToConstructorOp
(
type
);
// Combined texture-sampler constructors are completely semantic checked
// Combined texture-sampler constructors are completely semantic checked
// in constructorTextureSamplerError()
// in constructorTextureSamplerError()
...
...
hlsl/hlslParseHelper.h
View file @
a26a5170
...
@@ -131,7 +131,7 @@ public:
...
@@ -131,7 +131,7 @@ public:
const
TFunction
*
findFunction
(
const
TSourceLoc
&
loc
,
const
TFunction
&
call
,
bool
&
builtIn
);
const
TFunction
*
findFunction
(
const
TSourceLoc
&
loc
,
const
TFunction
&
call
,
bool
&
builtIn
);
void
declareTypedef
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TArraySizes
*
typeArray
=
0
);
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
,
const
TType
&
,
TArraySizes
*
typeArray
=
0
,
TIntermTyped
*
initializer
=
0
);
TIntermTyped
*
addConstructor
(
const
TSourceLoc
&
,
TIntermNode
*
,
const
TType
&
,
TOperator
);
TIntermTyped
*
addConstructor
(
const
TSourceLoc
&
,
TIntermNode
*
,
const
TType
&
);
TIntermTyped
*
constructAggregate
(
TIntermNode
*
,
const
TType
&
,
int
,
const
TSourceLoc
&
);
TIntermTyped
*
constructAggregate
(
TIntermNode
*
,
const
TType
&
,
int
,
const
TSourceLoc
&
);
TIntermTyped
*
constructBuiltIn
(
const
TType
&
,
TOperator
,
TIntermTyped
*
,
const
TSourceLoc
&
,
bool
subset
);
TIntermTyped
*
constructBuiltIn
(
const
TType
&
,
TOperator
,
TIntermTyped
*
,
const
TSourceLoc
&
,
bool
subset
);
void
declareBlock
(
const
TSourceLoc
&
,
TType
&
,
const
TString
*
instanceName
=
0
,
TArraySizes
*
arraySizes
=
0
);
void
declareBlock
(
const
TSourceLoc
&
,
TType
&
,
const
TString
*
instanceName
=
0
,
TArraySizes
*
arraySizes
=
0
);
...
@@ -161,7 +161,6 @@ protected:
...
@@ -161,7 +161,6 @@ protected:
void
declareArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TSymbol
*&
,
bool
&
newDeclaration
);
void
declareArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TSymbol
*&
,
bool
&
newDeclaration
);
TIntermNode
*
executeInitializer
(
const
TSourceLoc
&
,
TIntermTyped
*
initializer
,
TVariable
*
variable
);
TIntermNode
*
executeInitializer
(
const
TSourceLoc
&
,
TIntermTyped
*
initializer
,
TVariable
*
variable
);
TIntermTyped
*
convertInitializerList
(
const
TSourceLoc
&
,
const
TType
&
,
TIntermTyped
*
initializer
);
TIntermTyped
*
convertInitializerList
(
const
TSourceLoc
&
,
const
TType
&
,
TIntermTyped
*
initializer
);
TOperator
mapTypeToConstructorOp
(
const
TType
&
)
const
;
TOperator
mapAtomicOp
(
const
TSourceLoc
&
loc
,
TOperator
op
,
bool
isImage
);
TOperator
mapAtomicOp
(
const
TSourceLoc
&
loc
,
TOperator
op
,
bool
isImage
);
void
outputMessage
(
const
TSourceLoc
&
,
const
char
*
szReason
,
const
char
*
szToken
,
void
outputMessage
(
const
TSourceLoc
&
,
const
char
*
szReason
,
const
char
*
szToken
,
const
char
*
szExtraInfoFormat
,
TPrefixType
prefix
,
const
char
*
szExtraInfoFormat
,
TPrefixType
prefix
,
...
...
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