Skip to content

Commit 9b2ef77

Browse files
lfilipkogfxbot
authored andcommitted
Fix for wrong location of isoline tessellation factors in URB
patch header. Change-Id: Ia32fad8fade6bb36c4a2ae2ce3ef0b8c61100e12
1 parent b1a5438 commit 9b2ef77

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

IGC/Compiler/CISACodeGen/HullShaderLowering.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
226226
{
227227
// for each BB handle OutputHSControlPoint intrinsic instructions
228228
Value* undef = llvm::UndefValue::get(Type::getFloatTy(F.getContext()));
229-
Value* data[8] =
229+
Value* data[8] =
230230
{
231231
inst->getOperand(0),
232232
inst->getOperand(1),
@@ -253,7 +253,7 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
253253
// Parse all instructions within BB and count the Inner,Outer ScalarTessFactors factors
254254
// and get the domain type.
255255
BasicBlock* bb = dyn_cast<BasicBlock>(BI);
256-
uint32_t tessShaderDomain = GetDomainType(bb, numTEFactorsInDomain);
256+
uint32_t tessShaderDomain = GetDomainType(bb, numTEFactorsInDomain);
257257

258258
if ((numTEFactorsInDomain == 2 && tessShaderDomain == USC::TESSELLATOR_DOMAIN_ISOLINE) ||
259259
(numTEFactorsInDomain == 4 && tessShaderDomain == USC::TESSELLATOR_DOMAIN_TRI) ||
@@ -273,20 +273,20 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
273273

274274
isTEFactorURBMsgPadded = true;
275275
}
276-
}
276+
}
277277
}
278278

279279
if ((IID == GenISAIntrinsic::GenISA_OuterScalarTessFactors) ||
280280
(IID == GenISAIntrinsic::GenISA_InnerScalarTessFactors))
281281
{
282-
// The URB Location for tessellation factors spans the first two offsets
282+
// The URB Location for tessellation factors spans the first two offsets
283283
// offset 0 and 1. The tessellation factors occupy the two offsets as mentioned below
284284
// Quad domain has 4 outer and 2 inner tessellation factors
285285
// Triangle domain has 3 outer and 1 inner tessellation factor
286286
// Isolines have 2 outer tessellation factors
287287
//
288288
//----------------------------------------------------------------------------------
289-
//| URB Offset 1.3 | URB Offset 1.2 | URB Offset 1.1 | URB Offset 1.0 |
289+
//| URB Offset 1.3 | URB Offset 1.2 | URB Offset 1.1 | URB Offset 1.0 |
290290
//----------------------------------------------------------------------------------
291291
//| OUTER_QUAD_U_EQ_0 | OUTER_QUAD_V_EQ_0 | OUTER_QUAD_U_EQ_1 | OUTER_QUAD_V_EQ_1 |
292292
//----------------------------------------------------------------------------------
@@ -316,7 +316,7 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
316316
}
317317
}
318318

319-
// offset into URB is 1 for outerScalarTessFactors and
319+
// offset into URB is 1 for outerScalarTessFactors and
320320
// 1 if its triangle domain and inner scalar tessellation factor
321321
// 0 if its the quad domain inner tessellation factor
322322
int offset = (IID == GenISAIntrinsic::GenISA_OuterScalarTessFactors) ? 1 :
@@ -339,8 +339,19 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
339339
{
340340
unsigned int tessFactor = int_cast<unsigned int>(llvm::cast<ConstantInt>(inst->getOperand(0))->getZExtValue());
341341

342-
tessFactor = ((IID == GenISAIntrinsic::GenISA_InnerScalarTessFactors)
343-
&& (tessShaderDomain == USC::TESSELLATOR_DOMAIN_TRI)) ? 3 : tessFactor;
342+
if (tessShaderDomain == USC::TESSELLATOR_DOMAIN_ISOLINE)
343+
{
344+
// For isolines first tessellation factor(0) is line-density. The second one(1)
345+
// is line-detail tessellation factor. To store them properly in patch header
346+
// we need to set correct bits in URB write mask i.e. 0x4 for line-density
347+
// and 0x8 for line-detail. Swap the indexes.
348+
tessFactor ^= 1;
349+
}
350+
else
351+
{
352+
tessFactor = ((IID == GenISAIntrinsic::GenISA_InnerScalarTessFactors) &&
353+
(tessShaderDomain == USC::TESSELLATOR_DOMAIN_TRI)) ? 3 : tessFactor;
354+
}
344355

345356
AddURBWrite(pOffsetVal,
346357
builder.getInt32(1 << (3 - tessFactor)),
@@ -351,16 +362,26 @@ void HullShaderLowering::LowerIntrinsicInputOutput(Function& F)
351362
{
352363
builder.SetInsertPoint(inst);
353364
Value* pSubRes = nullptr;
365+
Value* pSubResRHS = nullptr;
354366
if ((IID == GenISAIntrinsic::GenISA_InnerScalarTessFactors)
355367
&& (tessShaderDomain == USC::TESSELLATOR_DOMAIN_TRI))
356368
{
357369
pSubRes = inst->getOperand(0);
358370
}
359371
else
360372
{
373+
if (tessShaderDomain == USC::TESSELLATOR_DOMAIN_ISOLINE)
374+
{
375+
pSubResRHS = builder.CreateXor(inst->getOperand(0), builder.getInt32(1));
376+
}
377+
else
378+
{
379+
pSubResRHS = inst->getOperand(0);
380+
}
381+
361382
pSubRes = builder.CreateSub(
362383
builder.getInt32(3),
363-
inst->getOperand(0));
384+
pSubResRHS);
364385
}
365386

366387
Value* pShiftVal = builder.CreateShl(

0 commit comments

Comments
 (0)