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
1c42d4ee
Unverified
Commit
1c42d4ee
authored
Jul 22, 2020
by
John Kessenich
Committed by
GitHub
Jul 22, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2345 from mbechard/master
also search global sequences for live variables
parents
c63502cf
5727fb31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
12 deletions
+49
-12
LiveTraverser.h
glslang/MachineIndependent/LiveTraverser.h
+34
-4
iomapper.cpp
glslang/MachineIndependent/iomapper.cpp
+15
-8
No files found.
glslang/MachineIndependent/LiveTraverser.h
View file @
1c42d4ee
...
...
@@ -74,14 +74,33 @@ public:
for
(
unsigned
int
f
=
0
;
f
<
globals
.
size
();
++
f
)
{
TIntermAggregate
*
candidate
=
globals
[
f
]
->
getAsAggregate
();
if
(
candidate
&&
candidate
->
getOp
()
==
EOpFunction
&&
candidate
->
getName
()
==
name
)
{
func
tions
.
push_back
(
candidate
);
destina
tions
.
push_back
(
candidate
);
break
;
}
}
}
typedef
std
::
list
<
TIntermAggregate
*>
TFunctionStack
;
TFunctionStack
functions
;
void
pushGlobalReference
(
const
TString
&
name
)
{
TIntermSequence
&
globals
=
intermediate
.
getTreeRoot
()
->
getAsAggregate
()
->
getSequence
();
for
(
unsigned
int
f
=
0
;
f
<
globals
.
size
();
++
f
)
{
TIntermAggregate
*
candidate
=
globals
[
f
]
->
getAsAggregate
();
if
(
candidate
&&
candidate
->
getOp
()
==
EOpSequence
&&
candidate
->
getSequence
().
size
()
==
1
&&
candidate
->
getSequence
()[
0
]
->
getAsBinaryNode
())
{
TIntermBinary
*
binary
=
candidate
->
getSequence
()[
0
]
->
getAsBinaryNode
();
TIntermSymbol
*
symbol
=
binary
->
getLeft
()
->
getAsSymbolNode
();
if
(
symbol
&&
symbol
->
getQualifier
().
storage
==
EvqGlobal
&&
symbol
->
getName
()
==
name
)
{
destinations
.
push_back
(
candidate
);
break
;
}
}
}
}
typedef
std
::
list
<
TIntermAggregate
*>
TDestinationStack
;
TDestinationStack
destinations
;
protected
:
// To catch which function calls are not dead, and hence which functions must be visited.
...
...
@@ -117,16 +136,27 @@ protected:
// and only visit each function once.
void
addFunctionCall
(
TIntermAggregate
*
call
)
{
//
//
just use the map to ensure we process each function at most once
// just use the map to ensure we process each function at most once
if
(
liveFunctions
.
find
(
call
->
getName
())
==
liveFunctions
.
end
())
{
liveFunctions
.
insert
(
call
->
getName
());
pushFunction
(
call
->
getName
());
}
}
void
addGlobalReference
(
const
TString
&
name
)
{
// just use the map to ensure we process each global at most once
if
(
liveGlobals
.
find
(
name
)
==
liveGlobals
.
end
())
{
liveGlobals
.
insert
(
name
);
pushGlobalReference
(
name
);
}
}
const
TIntermediate
&
intermediate
;
typedef
std
::
unordered_set
<
TString
>
TLiveFunctions
;
TLiveFunctions
liveFunctions
;
typedef
std
::
unordered_set
<
TString
>
TLiveGlobals
;
TLiveGlobals
liveGlobals
;
bool
traverseAll
;
private
:
...
...
glslang/MachineIndependent/iomapper.cpp
View file @
1c42d4ee
...
...
@@ -79,6 +79,11 @@ public:
target
=
&
outputList
;
else
if
(
base
->
getQualifier
().
isUniformOrBuffer
()
&&
!
base
->
getQualifier
().
isPushConstant
())
target
=
&
uniformList
;
// If a global is being visited, then we should also traverse it incase it's evaluation
// ends up visiting inputs we want to tag as live
else
if
(
base
->
getQualifier
().
storage
==
EvqGlobal
)
addGlobalReference
(
base
->
getName
());
if
(
target
)
{
TVarEntryInfo
ent
=
{
base
->
getId
(),
base
,
!
traverseAll
};
ent
.
stage
=
intermediate
.
getStage
();
...
...
@@ -1105,11 +1110,12 @@ bool TIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TInfoSi
TVarGatherTraverser
iter_binding_live
(
intermediate
,
false
,
inVarMap
,
outVarMap
,
uniformVarMap
);
root
->
traverse
(
&
iter_binding_all
);
iter_binding_live
.
pushFunction
(
intermediate
.
getEntryPointMangledName
().
c_str
());
while
(
!
iter_binding_live
.
func
tions
.
empty
())
{
TIntermNode
*
function
=
iter_binding_live
.
func
tions
.
back
();
iter_binding_live
.
func
tions
.
pop_back
();
func
tion
->
traverse
(
&
iter_binding_live
);
while
(
!
iter_binding_live
.
destina
tions
.
empty
())
{
TIntermNode
*
destination
=
iter_binding_live
.
destina
tions
.
back
();
iter_binding_live
.
destina
tions
.
pop_back
();
destina
tion
->
traverse
(
&
iter_binding_live
);
}
// sort entries by priority. see TVarEntryInfo::TOrderByPriority for info.
std
::
for_each
(
inVarMap
.
begin
(),
inVarMap
.
end
(),
[
&
inVector
](
TVarLivePair
p
)
{
inVector
.
push_back
(
p
);
});
...
...
@@ -1200,11 +1206,12 @@ bool TGlslIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TIn
*
uniformVarMap
[
stage
]);
root
->
traverse
(
&
iter_binding_all
);
iter_binding_live
.
pushFunction
(
intermediate
.
getEntryPointMangledName
().
c_str
());
while
(
!
iter_binding_live
.
func
tions
.
empty
())
{
TIntermNode
*
function
=
iter_binding_live
.
func
tions
.
back
();
iter_binding_live
.
func
tions
.
pop_back
();
func
tion
->
traverse
(
&
iter_binding_live
);
while
(
!
iter_binding_live
.
destina
tions
.
empty
())
{
TIntermNode
*
destination
=
iter_binding_live
.
destina
tions
.
back
();
iter_binding_live
.
destina
tions
.
pop_back
();
destina
tion
->
traverse
(
&
iter_binding_live
);
}
TNotifyInOutAdaptor
inOutNotify
(
stage
,
*
resolver
);
TNotifyUniformAdaptor
uniformNotify
(
stage
,
*
resolver
);
// Resolve current stage input symbol location with previous stage output here,
...
...
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