Skip to content

Commit 3a2caa7

Browse files
bcheng0127gfxbot
authored andcommitted
RA bug happened in augumentation for sampler instruction.
When SIMD8 sampler is used in SIMD16 kernel, the Q1 and Q2 will be applied to all return registers Change-Id: I5ff54c5f82bfaf36cc127dd4d8c45208e560195d
1 parent 8a39a67 commit 3a2caa7

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

visa/GraphColor.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,38 @@ bool Augmentation::updateDstMaskForScatter(G4_INST* inst, unsigned char* mask)
26022602
default: return false;
26032603
}
26042604
break;
2605+
2606+
case SFID::SAMPLER:
2607+
{
2608+
unsigned int respLength = msgDesc->ResponseLength();
2609+
unsigned char curEMBit = (unsigned char)inst->getMaskOffset();
2610+
unsigned int warpNum = respLength * G4_GRF_REG_NBYTES / (execSize * elemSize);
2611+
2612+
if (inst->isWriteEnableInst())
2613+
{
2614+
curEMBit = NOMASK_BYTE;
2615+
}
2616+
2617+
for (unsigned int i = 0; i < warpNum; i++)
2618+
{
2619+
for (unsigned int j = 0; j < execSize; j++)
2620+
{
2621+
for (unsigned int k = 0; k < elemSize; k++)
2622+
{
2623+
mask[(i * execSize + j)*elemSize + k] = curEMBit;
2624+
}
2625+
if (curEMBit != NOMASK_BYTE)
2626+
{
2627+
curEMBit++;
2628+
ASSERT_USER(curEMBit <= 32, "Illegal mask channel");
2629+
}
2630+
}
2631+
curEMBit = (unsigned char)inst->getMaskOffset();
2632+
}
2633+
return true;
2634+
}
2635+
break;
2636+
26052637
default: return false;
26062638
}
26072639

@@ -3938,7 +3970,7 @@ void Augmentation::buildLiveIntervals()
39383970

39393971
#ifdef DEBUG_VERBOSE_ON
39403972
// Print calculated live-ranges
3941-
printLiveIntervals();
3973+
gra.printLiveIntervals();
39423974
#endif
39433975
}
39443976

visa/TranslationInterface.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8583,6 +8583,22 @@ static void setUniformSampler(G4_InstSend* sendInst, bool uniformSampler)
85838583
Need to split sample_d and sample_dc in to two simd8 sends since HW doesn't support it.
85848584
Also need to split any sample instruciton that has more then 5 parameters. Since there is a limit on msg length.
85858585
*/
8586+
static unsigned TmpSmplDstID = 0;
8587+
const char* getNameString(Mem_Manager& mem, size_t size, const char* format, ...)
8588+
{
8589+
#ifdef _DEBUG
8590+
char* name = (char*) mem.alloc(size);
8591+
va_list args;
8592+
va_start(args, format);
8593+
std::vsnprintf(name, size, format, args);
8594+
va_end(args);
8595+
return name;
8596+
#else
8597+
const char* name = "";
8598+
return const_cast<char*>(name);
8599+
#endif
8600+
}
8601+
85868602
static int splitSampleInst(VISASampler3DSubOpCode actualop,
85878603
bool pixelNullMask,
85888604
bool cpsEnable,
@@ -8599,6 +8615,7 @@ static int splitSampleInst(VISASampler3DSubOpCode actualop,
85998615
IR_Builder *builder,
86008616
unsigned int numParms,
86018617
G4_SrcRegRegion ** params,
8618+
Mem_Manager& mem,
86028619
bool uniformSampler = true)
86038620
{
86048621
int status = CM_SUCCESS;
@@ -8640,7 +8657,9 @@ static int splitSampleInst(VISASampler3DSubOpCode actualop,
86408657
++tmpDstRows;
86418658
}
86428659

8643-
tempDstDcl = builder->createDeclareNoLookup("TmpSmplDst",
8660+
const char *name = getNameString(mem, 20, "%s%d", "TmpSmplDst_", TmpSmplDstID++);
8661+
8662+
tempDstDcl = builder->createDeclareNoLookup(name,
86448663
originalDstDcl->getRegFile(),
86458664
originalDstDcl->getNumElems(),
86468665
(uint16_t)tmpDstRows,
@@ -8734,7 +8753,9 @@ static int splitSampleInst(VISASampler3DSubOpCode actualop,
87348753
G4_Declare* tempDstDcl2 = nullptr;
87358754
if(!dst->isNullReg())
87368755
{
8737-
tempDstDcl2 = builder->createDeclareNoLookup("TmpSmplDst2",
8756+
const char *name = getNameString(mem, 20, "%s%d", "TmpSmplDst2_", TmpSmplDstID++);
8757+
8758+
tempDstDcl2 = builder->createDeclareNoLookup(name,
87388759
originalDstDcl->getRegFile(),
87398760
originalDstDcl->getNumElems(),
87408761
(uint16_t)tmpDstRows,
@@ -9097,7 +9118,7 @@ int IR_Builder::translateVISASampler3DInst(
90979118

90989119
return splitSampleInst(actualop, pixelNullMask, cpsEnable, pred, chMask,
90999120
numChannels, aoffimmi, sampler, surface, dst,
9100-
emask, useHeader, numRows, this, numParms, params, uniformSampler);
9121+
emask, useHeader, numRows, this, numParms, params, mem, uniformSampler);
91019122
}
91029123

91039124
bool useSplitSend = useSends();
@@ -9230,7 +9251,7 @@ int IR_Builder::translateVISALoad3DInst(
92309251
return splitSampleInst(actualop, pixelNullMask, /*cpsEnable*/false,
92319252
pred_opnd, channelMask, numChannels, aoffimmi,
92329253
NULL, surface, dst, em, useHeader, numRows,
9233-
this, numParms, opndArray);
9254+
this, numParms, opndArray, mem);
92349255
}
92359256

92369257
bool useSplitSend = useSends();
@@ -9348,7 +9369,7 @@ int IR_Builder::translateVISAGather3dInst(
93489369
return splitSampleInst(actualop, pixelNullMask, /*cpsEnable*/false,
93499370
pred, channelMask, 4, aoffimmi, sampler,
93509371
surface, dst, em, useHeader, numRows, this,
9351-
numOpnds, opndArray);
9372+
numOpnds, opndArray, mem);
93529373
}
93539374

93549375
bool useSplitSend = useSends();

0 commit comments

Comments
 (0)