@@ -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 (
0 commit comments