Skip to content

Commit 435db02

Browse files
Jay-Jiewu-Lugfxbot
authored andcommitted
refactor
Change-Id: I455026f17f358e36b939af7d14e7943b1d261615
1 parent 793e799 commit 435db02

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

IGC/Compiler/CodeGenPublic.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ namespace IGC
113113
//true means we separate pvtmem and spillfill. pvtmem could go into stateless.
114114
//false means all of them are together
115115
bool m_separatePvtSpill = false;
116-
116+
bool m_roundPower2KBytes = false;
117+
117118
void Destroy()
118119
{
119120
if (m_programBin)
@@ -129,15 +130,21 @@ namespace IGC
129130
IGC::aligned_free(m_debugDataGenISA);
130131
}
131132
}
132-
133-
void setSeparatePvtSpill(bool setSeparatePvtSpillT)
133+
134+
void setSeparatePvtSpill(bool setSeparatePvtSpillT, bool roundPower2KBytes)
134135
{
135136
m_separatePvtSpill = setSeparatePvtSpillT;
137+
m_roundPower2KBytes = roundPower2KBytes;
136138
}
137139

138140
unsigned int getScratchSpaceUsage() const
139141
{
140-
return m_scratchSpaceUsedBySpills + m_scratchSpaceUsedByGtpin + (m_separatePvtSpill ? 0 : m_scratchSpaceUsedByShader);
142+
unsigned int size = m_scratchSpaceUsedBySpills + m_scratchSpaceUsedByGtpin + (m_separatePvtSpill ? 0 : m_scratchSpaceUsedByShader);
143+
if (m_roundPower2KBytes)
144+
{
145+
size = roundPower2KBbyte(size);
146+
}
147+
return size;
141148
}
142149

143150
unsigned int getScratchPrivateUsage() const
@@ -161,6 +168,12 @@ namespace IGC
161168
{
162169
return (m_separatePvtSpill ? m_scratchSpaceUsedByStateless : 0);
163170
}
171+
private:
172+
unsigned int roundPower2KBbyte(unsigned int size) const
173+
{
174+
return (size ? iSTD::RoundPower2(iSTD::Max(int_cast<DWORD>(size), static_cast<DWORD>(sizeof(KILOBYTE)))) : 0);
175+
}
176+
164177
};
165178

166179
enum InstrStatTypes

0 commit comments

Comments
 (0)