Skip to content

Commit 175b468

Browse files
committed
Enable LTO for tessellation - cleanup
Change-Id: Ifcff4f4b99a93bf09497ba84863806f085413159
1 parent e0acc25 commit 175b468

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

IGC/Compiler/CISACodeGen/LinkTessControlShaderMCFPass.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,31 @@ namespace IGC
346346
/* Instance Count
347347
** This field determines the number of threads(minus one) spawned per input patch.
348348
349-
** If the HS kernel uses a barrier function, software must restrict the Instance Count
350-
** to the number of threads that can be simultaneously active within a subslice.Factors
351-
** which must be considered includes scratch memory availability.
349+
** If the HS kernel uses a barrier function, software must restrict the Instance Count
350+
** to the number of threads that can be simultaneously active within a subslice.
351+
** Factors which must be considered includes scratch memory availability.
352352
** Value Description
353353
** [0, 15] representing[1, 16] instances */
354354

355-
llvm::GlobalVariable* pGlobal = GetModule()->getGlobalVariable("TessInputControlPointCount");
356-
unsigned int inputControlPointCount = int_cast<unsigned int>(llvm::cast<llvm::ConstantInt>(pGlobal->getInitializer())->getZExtValue());
355+
// Use HS single patch if WA exists and input control points >= 29 as there are not enough registers for push constants
356+
bool useSinglePatch = false;
357+
if (pCodeGenContext->platform.WaDispatchGRFHWIssueInGSAndHSUnit())
358+
{
359+
llvm::GlobalVariable* pGlobal = GetModule()->getGlobalVariable("TessInputControlPointCount");
360+
if (pGlobal && pGlobal->hasInitializer())
361+
{
362+
unsigned int inputControlPointCount = int_cast<unsigned int>(llvm::cast<llvm::ConstantInt>(pGlobal->getInitializer())->getZExtValue());
363+
if (inputControlPointCount >= 29)
364+
{
365+
useSinglePatch = true;
366+
}
367+
}
368+
}
357369

358-
// Use HS single patch if WA exists and input control points >= 29 as not enough registers for push constants
359-
bool useSinglePatch = !(pCodeGenContext->platform.WaDispatchGRFHWIssueInGSAndHSUnit() && inputControlPointCount >= 29);
360-
361370
if (pCodeGenContext->platform.useOnlyEightPatchDispatchHS() ||
362371
(pCodeGenContext->platform.supportHSEightPatchDispatch() &&
363372
!(m_useMultipleHardwareThread && mOutputControlPointCount >= 16) &&
364-
useSinglePatch &&
373+
!useSinglePatch &&
365374
IGC_IS_FLAG_DISABLED(EnableHSSinglePatchDispatch)))
366375
{
367376
Constant* cval = llvm::ConstantInt::get(

IGC/Compiler/CISACodeGen/LinkTessControlShaderPass.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,31 @@ namespace IGC
107107
/* Instance Count
108108
** This field determines the number of threads(minus one) spawned per input patch.
109109
110-
** If the HS kernel uses a barrier function, software must restrict the Instance Count
111-
** to the number of threads that can be simultaneously active within a subslice.Factors
112-
** which must be considered includes scratch memory availability.
110+
** If the HS kernel uses a barrier function, software must restrict the Instance Count
111+
** to the number of threads that can be simultaneously active within a subslice.
112+
** Factors which must be considered includes scratch memory availability.
113113
** Value Description
114114
** [0, 15] representing[1, 16] instances */
115115

116-
llvm::GlobalVariable* pGlobal = mod->getGlobalVariable("TessInputControlPointCount");
117-
unsigned int inputControlPointCount = int_cast<unsigned int>(llvm::cast<llvm::ConstantInt>(pGlobal->getInitializer())->getZExtValue());
118-
119-
//use HS single patch if WA exists and input control points >= 29 as not enough registers for push constants
120-
bool useSinglePatch = !(pCodeGenContext->platform.WaDispatchGRFHWIssueInGSAndHSUnit() && inputControlPointCount >= 29);
116+
// Use HS single patch if WA exists and input control points >= 29 as there are not enough registers for push constants
117+
bool useSinglePatch = false;
118+
if (pCodeGenContext->platform.WaDispatchGRFHWIssueInGSAndHSUnit())
119+
{
120+
llvm::GlobalVariable* pGlobal = mod->getGlobalVariable("TessInputControlPointCount");
121+
if (pGlobal && pGlobal->hasInitializer())
122+
{
123+
unsigned int inputControlPointCount = int_cast<unsigned int>(llvm::cast<llvm::ConstantInt>(pGlobal->getInitializer())->getZExtValue());
124+
if (inputControlPointCount >= 29)
125+
{
126+
useSinglePatch = true;
127+
}
128+
}
129+
}
121130

122131
if (pCodeGenContext->platform.useOnlyEightPatchDispatchHS() ||
123132
(pCodeGenContext->platform.supportHSEightPatchDispatch() &&
124133
!(m_useMultipleHardwareThread && outputControlPointCount >= 16) &&
125-
useSinglePatch &&
134+
!useSinglePatch &&
126135
IGC_IS_FLAG_DISABLED(EnableHSSinglePatchDispatch)))
127136
{
128137
Constant* cval = llvm::ConstantInt::get(

0 commit comments

Comments
 (0)