@@ -71,83 +71,43 @@ static int getLayoutBindingLimit(bool relaxSetBindingLimits)
7171 return relaxSetBindingLimits ? INT_MAX : int (TQualifier::layoutBindingEnd);
7272}
7373
74- struct TVarEntryInfo {
75- long long id;
76- TIntermSymbol* symbol;
77- bool live;
78- TLayoutPacking upgradedToPushConstantPacking; // ElpNone means it hasn't been upgraded
79- int newBinding;
80- int newSet;
81- int newLocation;
82- int newComponent;
83- int newIndex;
84- EShLanguage stage;
74+ bool TVarEntryInfo::TOrderByPriority::operator ()(const TVarEntryInfo& l, const TVarEntryInfo& r)
75+ {
76+ const TQualifier& lq = l.symbol ->getQualifier ();
77+ const TQualifier& rq = r.symbol ->getQualifier ();
78+
79+ // simple rules:
80+ // has binding gives 2 points
81+ // has set gives 1 point
82+ // who has the most points is more important.
83+ int lPoints = (lq.hasBinding () ? 2 : 0 ) + (lq.hasSet () ? 1 : 0 );
84+ int rPoints = (rq.hasBinding () ? 2 : 0 ) + (rq.hasSet () ? 1 : 0 );
85+
86+ if (lPoints == rPoints)
87+ return l.id < r.id ;
88+ return lPoints > rPoints;
89+ }
8590
86- void clearNewAssignments () {
87- upgradedToPushConstantPacking = ElpNone;
88- newBinding = -1 ;
89- newSet = -1 ;
90- newLocation = -1 ;
91- newComponent = -1 ;
92- newIndex = -1 ;
93- }
94-
95- struct TOrderById {
96- inline bool operator ()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id ; }
97- };
98-
99- struct TOrderByPriority {
100- // ordering:
101- // 1) has both binding and set
102- // 2) has binding but no set
103- // 3) has no binding but set
104- // 4) has no binding and no set
105- inline bool operator ()(const TVarEntryInfo& l, const TVarEntryInfo& r) {
106- const TQualifier& lq = l.symbol ->getQualifier ();
107- const TQualifier& rq = r.symbol ->getQualifier ();
108-
109- // simple rules:
110- // has binding gives 2 points
111- // has set gives 1 point
112- // who has the most points is more important.
113- int lPoints = (lq.hasBinding () ? 2 : 0 ) + (lq.hasSet () ? 1 : 0 );
114- int rPoints = (rq.hasBinding () ? 2 : 0 ) + (rq.hasSet () ? 1 : 0 );
115-
116- if (lPoints == rPoints)
117- return l.id < r.id ;
118- return lPoints > rPoints;
119- }
120- };
121-
122- struct TOrderByPriorityAndLive {
123- // ordering:
124- // 1) do live variables first
125- // 2) has both binding and set
126- // 3) has binding but no set
127- // 4) has no binding but set
128- // 5) has no binding and no set
129- inline bool operator ()(const TVarEntryInfo& l, const TVarEntryInfo& r) {
130-
131- const TQualifier& lq = l.symbol ->getQualifier ();
132- const TQualifier& rq = r.symbol ->getQualifier ();
133-
134- // simple rules:
135- // has binding gives 2 points
136- // has set gives 1 point
137- // who has the most points is more important.
138- int lPoints = (lq.hasBinding () ? 2 : 0 ) + (lq.hasSet () ? 1 : 0 );
139- int rPoints = (rq.hasBinding () ? 2 : 0 ) + (rq.hasSet () ? 1 : 0 );
140-
141- if (l.live != r.live )
142- return l.live > r.live ;
143-
144- if (lPoints != rPoints)
145- return lPoints > rPoints;
146-
147- return l.id < r.id ;
148- }
149- };
150- };
91+ bool TVarEntryInfo::TOrderByPriorityAndLive::operator ()(const TVarEntryInfo& l, const TVarEntryInfo& r)
92+ {
93+ const TQualifier& lq = l.symbol ->getQualifier ();
94+ const TQualifier& rq = r.symbol ->getQualifier ();
95+
96+ // simple rules:
97+ // has binding gives 2 points
98+ // has set gives 1 point
99+ // who has the most points is more important.
100+ int lPoints = (lq.hasBinding () ? 2 : 0 ) + (lq.hasSet () ? 1 : 0 );
101+ int rPoints = (rq.hasBinding () ? 2 : 0 ) + (rq.hasSet () ? 1 : 0 );
102+
103+ if (l.live != r.live )
104+ return l.live > r.live ;
105+
106+ if (lPoints != rPoints)
107+ return lPoints > rPoints;
108+
109+ return l.id < r.id ;
110+ }
151111
152112// override function "operator=", if a vector<const _Kty, _Ty> being sort,
153113// when use vc++, the sort function will call :
0 commit comments