Skip to content

Commit b349751

Browse files
jsantillan2017Zuul
authored andcommitted
Added new GenISAIntrinsics
Change-Id: Ifa13bf6a766ee00fac1779ee1539256ec7507bb3
1 parent d1ae9fd commit b349751

File tree

5 files changed

+73
-16
lines changed

5 files changed

+73
-16
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,17 +3493,15 @@ void EmitPass::emitPSInput(llvm::Instruction* inst)
34933493
}
34943494
}
34953495

3496-
void EmitPass::emitPlnInterpolation(CVariable* baryVar, unsigned int delatIndex)
3496+
void EmitPass::emitPlnInterpolation(CVariable* baryVar, CVariable* inputvar)
34973497
{
3498-
CPixelShader* psProgram = static_cast<CPixelShader*>(m_currShader);
34993498
unsigned int numPln = 1;
3500-
// temp variable should be the same type as the destination
3501-
CVariable* inputVar = psProgram->GetInputDelta(delatIndex);
3499+
35023500
for (unsigned int i = 0; i < numPln; i++)
35033501
{
35043502
// plane will access 4 operands
35053503
m_encoder->SetSrcRegion(0, 0, 4, 1);
3506-
m_encoder->Pln(m_destination, inputVar, baryVar);
3504+
m_encoder->Pln(m_destination, inputvar, baryVar);
35073505
m_encoder->Push();
35083506
}
35093507
}
@@ -3513,10 +3511,12 @@ void EmitPass::emitPSInputPln(llvm::Instruction* inst)
35133511
//create the payload and do interpolationd
35143512
CPixelShader* psProgram = static_cast<CPixelShader*>(m_currShader);
35153513
uint setupIndex = (uint)llvm::cast<llvm::ConstantInt>(inst->getOperand(0))->getZExtValue();
3514+
// temp variable should be the same type as the destination
3515+
CVariable* inputVar = psProgram->GetInputDelta(setupIndex);
35163516
e_interpolation mode = (e_interpolation)llvm::cast<llvm::ConstantInt>(inst->getOperand(1))->getZExtValue();
35173517
// need to do interpolation unless we do constant interpolation
35183518
CVariable* baryVar = psProgram->GetBaryReg(mode);
3519-
emitPlnInterpolation(baryVar, setupIndex);
3519+
emitPlnInterpolation(baryVar, inputVar);
35203520
}
35213521

35223522
void EmitPass::emitEvalAttribute(llvm::GenIntrinsicInst* inst)
@@ -3591,24 +3591,45 @@ void EmitPass::emitEvalAttribute(llvm::GenIntrinsicInst* inst)
35913591
break;
35923592

35933593
case GenISAIntrinsic::GenISA_PullSnappedBarys:
3594-
{
3595-
ConstantInt* xCstOffset = llvm::dyn_cast<llvm::ConstantInt>(inst->getOperand(0));
3596-
ConstantInt* yCstOffset = llvm::dyn_cast<llvm::ConstantInt>(inst->getOperand(1));
3597-
if (xCstOffset && yCstOffset && psProgram->GetPhase() != PSPHASE_COARSE)
3594+
case GenISAIntrinsic::GenISA_PullCentroidBarys:
3595+
{
3596+
uint offsetX = 0;
3597+
uint offsetY = 0;
3598+
bool offsetIsConst = true;
3599+
auto messageType = EU_PI_MESSAGE_EVAL_CENTROID_POSITION;
3600+
if (inst->getIntrinsicID() == GenISAIntrinsic::GenISA_PullSnappedBarys)
3601+
{
3602+
offsetIsConst = false;
3603+
auto xCstOffset = llvm::dyn_cast<llvm::ConstantInt>(inst->getOperand(0));
3604+
auto yCstOffset = llvm::dyn_cast<llvm::ConstantInt>(inst->getOperand(1));
3605+
if (xCstOffset && yCstOffset)
3606+
{
3607+
offsetIsConst = true;
3608+
offsetX = (uint) xCstOffset->getZExtValue();
3609+
offsetY = (uint) yCstOffset->getZExtValue();
3610+
}
3611+
3612+
messageType = offsetIsConst && psProgram->GetPhase() != PSPHASE_COARSE ?
3613+
EU_PI_MESSAGE_EVAL_PER_MESSAGE_OFFSET :
3614+
EU_PI_MESSAGE_EVAL_PER_SLOT_OFFSET;
3615+
}
3616+
if (offsetIsConst && psProgram->GetPhase() != PSPHASE_COARSE)
35983617
{
35993618
payload = m_currShader->GetNewVariable(messageLength * (getGRFSize() >> 2), ISA_TYPE_D, EALIGN_GRF);
36003619
desc = PixelInterpolator(
36013620
messageLength,
36023621
responseLength,
36033622
m_encoder->IsSecondHalf() ? 1 : 0,
36043623
executionMode,
3605-
EU_PI_MESSAGE_EVAL_PER_MESSAGE_OFFSET,
3624+
messageType,
36063625
interpolationMode,
3607-
(uint)xCstOffset->getZExtValue(),
3608-
(uint)yCstOffset->getZExtValue());
3626+
offsetX,
3627+
offsetY);
36093628
}
36103629
else
36113630
{
3631+
assert(messageType != EU_PI_MESSAGE_EVAL_CENTROID_POSITION);
3632+
36123633
messageLength = 2 * numLanes(m_currShader->m_SIMDSize) / 8;
36133634
payload = m_currShader->GetNewVariable(messageLength * (getGRFSize() >> 2), ISA_TYPE_D, EALIGN_GRF);
36143635
desc = PixelInterpolator(
@@ -3617,7 +3638,7 @@ void EmitPass::emitEvalAttribute(llvm::GenIntrinsicInst* inst)
36173638
m_encoder->IsSecondHalf() ? 1 : 0,
36183639
psProgram->GetPhase() == PSPHASE_COARSE,
36193640
executionMode,
3620-
EU_PI_MESSAGE_EVAL_PER_SLOT_OFFSET,
3641+
messageType,
36213642
interpolationMode);
36223643
CVariable* XOffset = GetSymbol(inst->getOperand(0));
36233644
CVariable* YOffset = GetSymbol(inst->getOperand(1));
@@ -3643,9 +3664,31 @@ void EmitPass::emitEvalAttribute(llvm::GenIntrinsicInst* inst)
36433664

36443665
void EmitPass::emitInterpolate(llvm::GenIntrinsicInst* inst)
36453666
{
3667+
CPixelShader* psProgram = static_cast<CPixelShader*>(m_currShader);
36463668
CVariable* barys = GetSymbol(inst->getOperand(1));
36473669
uint setupIndex = (uint)llvm::cast<llvm::ConstantInt>(inst->getOperand(0))->getZExtValue();
3648-
emitPlnInterpolation(barys, setupIndex);
3670+
// temp variable should be the same type as the destination
3671+
CVariable* inputVar = psProgram->GetInputDelta(setupIndex);
3672+
emitPlnInterpolation(barys, inputVar);
3673+
}
3674+
3675+
void EmitPass::emitInterpolate2(llvm::GenIntrinsicInst* inst)
3676+
{
3677+
CVariable* inputVar = GetSymbol(inst->getOperand(0));
3678+
CVariable* barys = GetSymbol(inst->getOperand(1));
3679+
emitPlnInterpolation(barys, inputVar);
3680+
}
3681+
3682+
void EmitPass::emitInterpolant(llvm::GenIntrinsicInst* inst)
3683+
{
3684+
uint setupIndex = (uint)llvm::cast<llvm::ConstantInt>(inst->getOperand(0))->getZExtValue();
3685+
auto psProgram = static_cast<CPixelShader*>(m_currShader);
3686+
CVariable* inputVar = psProgram->GetInputDelta(setupIndex);
3687+
m_encoder->SetSrcRegion(0, 4, 4, 1);
3688+
m_encoder->SetSimdSize(SIMDMode::SIMD4);
3689+
m_encoder->SetNoMask();
3690+
m_encoder->Copy(m_destination, inputVar);
3691+
m_encoder->Push();
36493692
}
36503693

36513694
void EmitPass::emitDSInput(llvm::Instruction* pInst)
@@ -7635,11 +7678,18 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst* inst)
76357678
break;
76367679
case GenISAIntrinsic::GenISA_PullSampleIndexBarys:
76377680
case GenISAIntrinsic::GenISA_PullSnappedBarys:
7681+
case GenISAIntrinsic::GenISA_PullCentroidBarys:
76387682
emitEvalAttribute(inst);
76397683
break;
76407684
case GenISAIntrinsic::GenISA_Interpolate:
76417685
emitInterpolate(inst);
76427686
break;
7687+
case GenISAIntrinsic::GenISA_Interpolate2:
7688+
emitInterpolate2(inst);
7689+
break;
7690+
case GenISAIntrinsic::GenISA_Interpolant:
7691+
emitInterpolant(inst);
7692+
break;
76437693
case GenISAIntrinsic::GenISA_DCL_DSCntrlPtInputVec:
76447694
emitInput(inst);
76457695
break;

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ namespace IGC
338338
void emitPSInputCst(llvm::Instruction* inst);
339339
void emitEvalAttribute(llvm::GenIntrinsicInst* inst);
340340
void emitInterpolate(llvm::GenIntrinsicInst* inst);
341+
void emitInterpolate2(llvm::GenIntrinsicInst* inst);
342+
void emitInterpolant(llvm::GenIntrinsicInst* inst);
341343

342344
void emitGradientX(const SSource& source, const DstModifier& modifier);
343345
void emitGradientY(const SSource& source, const DstModifier& modifier);
@@ -459,7 +461,7 @@ namespace IGC
459461
ResourceDescriptor GetResourceVariable(llvm::Value* resourcePtr);
460462
SamplerDescriptor GetSamplerVariable(llvm::Value* samplerPtr);
461463
CVariable* ComputeSampleIntOffset(llvm::Instruction* sample, uint sourceIndex);
462-
void emitPlnInterpolation(CVariable* bary, unsigned int delatIndex);
464+
void emitPlnInterpolation(CVariable* bary, CVariable* inputvar);
463465

464466
CVariable* GetExecutionMask();
465467
CVariable* GetExecutionMask(CVariable* &vecMaskVar);

IGC/Compiler/CISACodeGen/PixelShaderCodeGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ namespace IGC
875875
}
876876
case GenISAIntrinsic::GenISA_PullSampleIndexBarys:
877877
case GenISAIntrinsic::GenISA_PullSnappedBarys:
878+
case GenISAIntrinsic::GenISA_PullCentroidBarys:
878879
m_HasPullBary = true;
879880
break;
880881
default:

IGC/Compiler/CISACodeGen/opCode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ DECLARE_OPCODE(GenISA_resinfoptr, GenISAIntrinsic, llvm_resinfoptr, false, false
5858
DECLARE_OPCODE(GenISA_sampleinfoptr, GenISAIntrinsic, llvm_sampleinfoptr, false, false, false, false, false, false, false)
5959
DECLARE_OPCODE(GenISA_PullSampleIndexBarys, GenISAIntrinsic, llvm_pullSampleIndexBarys, false, false, false, false, false, false, false)
6060
DECLARE_OPCODE(GenISA_PullSnappedBarys, GenISAIntrinsic, llvm_pullSnappedBarys, false, false, false, false, false, false, false)
61+
DECLARE_OPCODE(GenISA_PullCentroidBarys, GenISAIntrinsic, llvm_pullCentroidBarys, false, false, false, false, false, false, false )
6162
DECLARE_OPCODE(sqrt, Intrinsic, llvm_sqrt, true, true, true, false, true, false, false)
6263
DECLARE_OPCODE(GenISA_rsq, GenISAIntrinsic, llvm_rsq, true, true, true, false, true, false, false)
6364
DECLARE_OPCODE(FMul, Instruction, llvm_fmul, true, true, true, true, false, false, false)

IGC/GenISAIntrinsics/Intrinsic_definitions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@
158158
"GenISA_cycleCounter": ["int2",[],"None"],
159159
"GenISA_PullSampleIndexBarys": ["float2",["int","bool"],"NoMem"],
160160
"GenISA_PullSnappedBarys": ["float2",["int","int","bool"],"NoMem"],
161+
"GenISA_PullCentroidBarys": ["float2",["bool"],"NoMem"],
162+
"GenISA_Interpolant": ["float4",["int"],"NoMem"],
161163
"GenISA_Interpolate": ["float",["int","float2"],"NoMem"],
164+
"GenISA_Interpolate2": ["float",["float4","float2"],"NoMem"],
162165
"GenISA_GradientX": ["anyfloat",[0],"NoMem"],
163166
"GenISA_GradientXfine": ["float",["float"],"NoMem"],
164167
"GenISA_GradientY": ["anyfloat",[0],"NoMem"],

0 commit comments

Comments
 (0)