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
6d2b07dc
Commit
6d2b07dc
authored
Mar 20, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Front-end: propagate specialization-constness through conversions and swizzles.
parent
a5845766
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
Types.h
glslang/Include/Types.h
+1
-0
Intermediate.cpp
glslang/MachineIndependent/Intermediate.cpp
+8
-2
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+6
-0
No files found.
glslang/Include/Types.h
View file @
6d2b07dc
...
@@ -740,6 +740,7 @@ public:
...
@@ -740,6 +740,7 @@ public:
}
}
void
makeSpecConstant
()
void
makeSpecConstant
()
{
{
storage
=
EvqConst
;
specConstant
=
true
;
specConstant
=
true
;
}
}
static
const
char
*
getLayoutPackingString
(
TLayoutPacking
packing
)
static
const
char
*
getLayoutPackingString
(
TLayoutPacking
packing
)
...
...
glslang/MachineIndependent/Intermediate.cpp
View file @
6d2b07dc
...
@@ -262,6 +262,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
...
@@ -262,6 +262,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
//
//
// For constructors, we are now done, it was all in the conversion.
// For constructors, we are now done, it was all in the conversion.
// TODO: but, did this bypass constant folding?
//
//
switch
(
op
)
{
switch
(
op
)
{
case
EOpConstructInt
:
case
EOpConstructInt
:
...
@@ -291,7 +292,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
...
@@ -291,7 +292,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
if
(
child
->
getAsConstantUnion
())
if
(
child
->
getAsConstantUnion
())
return
child
->
getAsConstantUnion
()
->
fold
(
op
,
node
->
getType
());
return
child
->
getAsConstantUnion
()
->
fold
(
op
,
node
->
getType
());
// If it's a specialiation constant, the result is too.
// If it's a speciali
z
ation constant, the result is too.
if
(
child
->
getType
().
getQualifier
().
isSpecConstant
())
if
(
child
->
getType
().
getQualifier
().
isSpecConstant
())
node
->
getWritableType
().
getQualifier
().
makeSpecConstant
();
node
->
getWritableType
().
getQualifier
().
makeSpecConstant
();
...
@@ -616,6 +617,12 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
...
@@ -616,6 +617,12 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
newNode
->
setLoc
(
node
->
getLoc
());
newNode
->
setLoc
(
node
->
getLoc
());
newNode
->
setOperand
(
node
);
newNode
->
setOperand
(
node
);
// TODO: it seems that some unary folding operations should occur here, but are not
// Propagate specialization-constant-ness.
if
(
node
->
getType
().
getQualifier
().
isSpecConstant
())
newNode
->
getWritableType
().
getQualifier
().
makeSpecConstant
();
return
newNode
;
return
newNode
;
}
}
...
@@ -883,7 +890,6 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseT
...
@@ -883,7 +890,6 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseT
TIntermTyped
*
TIntermediate
::
addSwizzle
(
TVectorFields
&
fields
,
const
TSourceLoc
&
loc
)
TIntermTyped
*
TIntermediate
::
addSwizzle
(
TVectorFields
&
fields
,
const
TSourceLoc
&
loc
)
{
{
TIntermAggregate
*
node
=
new
TIntermAggregate
(
EOpSequence
);
TIntermAggregate
*
node
=
new
TIntermAggregate
(
EOpSequence
);
node
->
setLoc
(
loc
);
node
->
setLoc
(
loc
);
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
6d2b07dc
...
@@ -820,6 +820,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
...
@@ -820,6 +820,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
return
result
;
return
result
;
else
{
else
{
TType
type
(
base
->
getBasicType
(),
EvqTemporary
,
fields
.
num
);
TType
type
(
base
->
getBasicType
(),
EvqTemporary
,
fields
.
num
);
// Swizzle operations propagate specialization-constantness
if
(
base
->
getQualifier
().
isSpecConstant
())
type
.
getQualifier
().
makeSpecConstant
();
return
addConstructor
(
loc
,
base
,
type
,
mapTypeToConstructorOp
(
type
));
return
addConstructor
(
loc
,
base
,
type
,
mapTypeToConstructorOp
(
type
));
}
}
}
}
...
@@ -837,6 +840,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
...
@@ -837,6 +840,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
result
=
intermediate
.
addIndex
(
EOpVectorSwizzle
,
base
,
index
,
loc
);
result
=
intermediate
.
addIndex
(
EOpVectorSwizzle
,
base
,
index
,
loc
);
result
->
setType
(
TType
(
base
->
getBasicType
(),
EvqTemporary
,
base
->
getType
().
getQualifier
().
precision
,
(
int
)
vectorString
.
size
()));
result
->
setType
(
TType
(
base
->
getBasicType
(),
EvqTemporary
,
base
->
getType
().
getQualifier
().
precision
,
(
int
)
vectorString
.
size
()));
}
}
// Swizzle operations propagate specialization-constantness
if
(
base
->
getType
().
getQualifier
().
isSpecConstant
())
result
->
getWritableType
().
getQualifier
().
makeSpecConstant
();
}
}
}
else
if
(
base
->
getBasicType
()
==
EbtStruct
||
base
->
getBasicType
()
==
EbtBlock
)
{
}
else
if
(
base
->
getBasicType
()
==
EbtStruct
||
base
->
getBasicType
()
==
EbtBlock
)
{
const
TTypeList
*
fields
=
base
->
getType
().
getStruct
();
const
TTypeList
*
fields
=
base
->
getType
().
getStruct
();
...
...
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