@@ -3926,25 +3926,7 @@ void EmitPass::emitLdInstruction(llvm::Instruction* inst)
39263926 {
39273927 if (feedbackEnable)
39283928 {
3929- CVariable* flag = m_currShader->GetNewVariable(numLanes(m_currShader->m_dispatchSize), ISA_TYPE_BOOL, EALIGN_BYTE);
3930- uint subvar = numLanes(simdSize) / (getGRFSize() >> 2) * 4;
3931-
3932- if (needPacking)
3933- {
3934- subvar /= 2;
3935- }
3936-
3937- m_encoder->SetSrcSubVar(0, subvar);
3938- m_encoder->SetSrcRegion(0, 0, 1, 0);
3939- CVariable* newdestination = m_currShader->BitCast(dst, ISA_TYPE_UD);
3940- m_encoder->SetP(flag, newdestination);
3941- m_encoder->Push();
3942-
3943- CVariable* pred = m_currShader->ImmToVariable(0xFFFFFFFF, dst->GetType());
3944- CVariable* zero = m_currShader->ImmToVariable(0x0, dst->GetType());
3945- m_encoder->SetDstSubVar(subvar);
3946- m_encoder->Select(flag, dst, pred, zero);
3947- m_encoder->Push();
3929+ emitFeedbackEnable(false);
39483930 }
39493931
39503932 if (m_destination->IsUniform())
@@ -6757,6 +6739,31 @@ void EmitPass::emitSurfaceInfo(GenIntrinsicInst* inst)
67576739 ResetVMask(false);
67586740}
67596741
6742+ void EmitPass::emitFeedbackEnable(bool isHFPacked)
6743+ {
6744+ // if feedback is enabled we always return all 4 channels
6745+ CVariable* flag = m_currShader->GetNewVariable(numLanes(m_currShader->m_dispatchSize), ISA_TYPE_BOOL, EALIGN_BYTE);
6746+ uint typeSize = CEncoder::GetCISADataTypeSize(m_destination->GetType());
6747+ uint subvar = (numLanes(m_currShader->m_SIMDSize) * typeSize * 4) / getGRFSize();
6748+ if (!isHFPacked)
6749+ {
6750+ // if HF destination is not packed yet, each channel takes at least 1 GRF.
6751+ subvar = std::max(4u, subvar);
6752+ }
6753+
6754+ m_encoder->SetSrcSubVar(0, subvar);
6755+ m_encoder->SetSrcRegion(0, 0, 1, 0);
6756+ CVariable* newdestination = m_currShader->BitCast(m_destination, ISA_TYPE_UD);
6757+ m_encoder->SetP(flag, newdestination);
6758+ m_encoder->Push();
6759+
6760+ CVariable* pred = m_currShader->ImmToVariable(0xFFFFFFFF, m_destination->GetType());
6761+ CVariable* zero = m_currShader->ImmToVariable(0x0, m_destination->GetType());
6762+ m_encoder->SetDstSubVar(subvar);
6763+ m_encoder->Select(flag, m_destination, pred, zero);
6764+ m_encoder->Push();
6765+ }
6766+
67606767void EmitPass::emitGather4Instruction(SamplerGatherIntrinsic* inst)
67616768{
67626769 EOPCODE opCode = GetOpCode(inst);
@@ -6844,28 +6851,9 @@ void EmitPass::emitGather4Instruction(SamplerGatherIntrinsic* inst)
68446851 PackSIMD8HFRet(dst);
68456852 }
68466853
6847-
68486854 if (feedbackEnable)
68496855 {
6850- CVariable* flag = m_currShader->GetNewVariable(numLanes(m_currShader->m_dispatchSize), ISA_TYPE_BOOL, EALIGN_BYTE);
6851- uint subvar = numLanes(m_currShader->m_SIMDSize) / (getGRFSize() >> 2) * 4;
6852-
6853- if (simd8HFRet)
6854- {
6855- subvar /= 2;
6856- }
6857-
6858- m_encoder->SetSrcSubVar(0, subvar);
6859- m_encoder->SetSrcRegion(0, 0, 1, 0);
6860- CVariable* newdestination = m_currShader->BitCast(m_destination, ISA_TYPE_UD);
6861- m_encoder->SetP(flag, newdestination);
6862- m_encoder->Push();
6863-
6864- CVariable* pred = m_currShader->ImmToVariable(0xFFFFFFFF, m_destination->GetType());
6865- CVariable* zero = m_currShader->ImmToVariable(0x0, m_destination->GetType());
6866- m_encoder->SetDstSubVar(subvar);
6867- m_encoder->Select(flag, m_destination, pred, zero);
6868- m_encoder->Push();
6856+ emitFeedbackEnable(true);
68696857 }
68706858 }
68716859}
@@ -6942,25 +6930,7 @@ void EmitPass::emitLdmsInstruction(llvm::Instruction* inst)
69426930
69436931 if (feedbackEnable)
69446932 {
6945- CVariable* flag = m_currShader->GetNewVariable(numLanes(m_currShader->m_dispatchSize), ISA_TYPE_BOOL, EALIGN_BYTE);
6946- uint subvar = numLanes(m_currShader->m_SIMDSize) / (getGRFSize() >> 2) * 4;
6947-
6948- if (simd8HFRet)
6949- {
6950- subvar /= 2;
6951- }
6952-
6953- m_encoder->SetSrcSubVar(0, subvar);
6954- m_encoder->SetSrcRegion(0, 0, 1, 0);
6955- CVariable* newdestination = m_currShader->BitCast(m_destination, ISA_TYPE_UD);
6956- m_encoder->SetP(flag, newdestination);
6957- m_encoder->Push();
6958-
6959- CVariable* pred = m_currShader->ImmToVariable(0xFFFFFFFF, m_destination->GetType());
6960- CVariable* zero = m_currShader->ImmToVariable(0x0, m_destination->GetType());
6961- m_encoder->SetDstSubVar(subvar);
6962- m_encoder->Select(flag, m_destination, pred, zero);
6963- m_encoder->Push();
6933+ emitFeedbackEnable(true);
69646934 }
69656935}
69666936
0 commit comments