Skip to content

Commit 532a178

Browse files
scottp101igcbot
authored andcommitted
Refactor state programming
Refactor state programming
1 parent 775c770 commit 532a178

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ CShader::CShader(Function *pFunc, CShaderProgram *pProgram, GenericShaderState &
3737
, encoder()
3838
{
3939
m_ctx = m_parent->GetContext();
40-
41-
bool SepSpillPvtSS = SeparateSpillAndScratch(m_ctx);
42-
bool SeparateScratchWA =
43-
IGC_IS_FLAG_ENABLED(EnableSeparateScratchWA) &&
44-
!m_ctx->getModuleMetaData()->disableSeparateScratchWA;
45-
m_simdProgram.init(!m_ctx->platform.hasScratchSurface(),
46-
m_ctx->platform.maxPerThreadScratchSpace(
47-
),
48-
GetContext()->getModuleMetaData()->compOpt.UseScratchSpacePrivateMemory,
49-
SepSpillPvtSS, SeparateScratchWA);
40+
GenericShaderState::setScratchUsage(*m_ctx, m_simdProgram);
5041
}
5142

5243
bool CShader::IsRecompilationRequestForced()

IGC/Compiler/CISACodeGen/GenericShaderState.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ namespace IGC
124124
}
125125
}
126126

127+
void GenericShaderState::setScratchUsage(CodeGenContext& Ctx, SProgramOutput& Prog)
128+
{
129+
bool SepSpillPvtSS = SeparateSpillAndScratch(&Ctx);
130+
bool SeparateScratchWA =
131+
IGC_IS_FLAG_ENABLED(EnableSeparateScratchWA) &&
132+
!Ctx.getModuleMetaData()->disableSeparateScratchWA;
133+
Prog.init(!Ctx.platform.hasScratchSurface(),
134+
Ctx.platform.maxPerThreadScratchSpace(
135+
),
136+
Ctx.getModuleMetaData()->compOpt.UseScratchSpacePrivateMemory,
137+
SepSpillPvtSS, SeparateScratchWA);
138+
}
139+
140+
void GenericShaderState::setScratchUsage(SProgramOutput& Prog)
141+
{
142+
setScratchUsage(Ctx, Prog);
143+
}
144+
127145
uint32_t GenericShaderState::GetShaderThreadUsageRate()
128146
{
129147
uint32_t grfNum = GetContext().getNumGRFPerThread();

IGC/Compiler/CISACodeGen/GenericShaderState.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ namespace IGC
102102
void SetHasEval() { m_HasEval = true; }
103103
void CreateGatherMap();
104104
void CreateConstantBufferOutput(SKernelProgram* pKernelProgram);
105+
static void setScratchUsage(CodeGenContext &Ctx, SProgramOutput& Prog);
106+
void setScratchUsage(SProgramOutput& Prog);
105107
uint32_t GetShaderThreadUsageRate();
106108

107109
const llvm::Function& Entry;

0 commit comments

Comments
 (0)