Commit bcd6d684 authored by JuanRod2's avatar JuanRod2 Committed by gbsbuild

Fixed an issue where PiixelLoweringPass is dropping debug info when

generating RTWrite Intrinsic

Change-Id: I565ed476d3dafd4a135c5cf0d2c5991623e7f0cc
parent c08060c6
......@@ -243,6 +243,7 @@ bool PixelShaderLowering::runOnFunction(llvm::Function &F)
m_module = F.getParent();
ColorOutputArray colors;
DebugLocArray debugLocs;
Value* depth = nullptr;
Value* mask = nullptr;
Value* src0Alpha = nullptr;
......@@ -268,7 +269,7 @@ bool PixelShaderLowering::runOnFunction(llvm::Function &F)
m_hasDiscard = (m_module->getNamedMetadata("KillPixel") != nullptr);
// In case we are using intrinsic retrieve the output
FindIntrinsicOutput(colors, depth, stencil, mask, src0Alpha);
FindIntrinsicOutput(colors, depth, stencil, mask, src0Alpha, debugLocs);
if (uavPixelSync)
{
......@@ -278,7 +279,7 @@ bool PixelShaderLowering::runOnFunction(llvm::Function &F)
}
// EmitRender target write intrinsic
EmitRTWrite(colors, depth, stencil, mask, src0Alpha);
EmitRTWrite(colors, depth, stencil, mask, src0Alpha, debugLocs);
Function* samplePhase = nullptr;
Function* pixelPhase = nullptr;
......@@ -312,7 +313,8 @@ void PixelShaderLowering::FindIntrinsicOutput(
Value*& depth,
Value*& stencil,
Value*& mask,
Value*& src0Alpha)
Value*& src0Alpha,
DebugLocArray& debugLocs)
{
bool inputUsed[MAX_INPUTS] = {0};
llvm::Instruction* primId = nullptr;
......@@ -401,6 +403,9 @@ void PixelShaderLowering::FindIntrinsicOutput(
{
mask = inst->getOperand(0);
}
//Need to save debug location
debugLocs.push_back(((Instruction*)inst)->getDebugLoc());
// delete the output
instructionToRemove.push_back(inst);
}
......@@ -456,7 +461,7 @@ void PixelShaderLowering::FindIntrinsicOutput(
ConstantInt::get(Type::getInt32Ty(m_module->getContext()), location),
ConstantInt::get(Type::getInt32Ty(m_module->getContext()), EINTERPOLATION_CONSTANT),
};
Value* in = GenIntrinsicInst::Create(
CallInst* in = GenIntrinsicInst::Create(
GenISAIntrinsic::getDeclaration(
m_module,
GenISAIntrinsic::GenISA_DCL_inputVec,
......@@ -464,6 +469,7 @@ void PixelShaderLowering::FindIntrinsicOutput(
arguments,
"",
primId);
in->setDebugLoc(primId->getDebugLoc());
primId->replaceAllUsesWith(in);
NamedMDNode* primIdMD = m_module->getOrInsertNamedMetadata("PrimIdLocation");
......@@ -638,6 +644,7 @@ CallInst* PixelShaderLowering::addRTWrite(
GenISAIntrinsic::GenISA_RTWrite,
Type::getFloatTy(this->m_module->getContext()));
}
return GenIntrinsicInst::Create(frtw, arguments, "",
bbToAdd->getTerminator());
}
......@@ -681,7 +688,7 @@ static void dbgPrintBlendOptMode(uint64_t hash,
void PixelShaderLowering::EmitRTWrite(
ColorOutputArray& colors, Value* depth, Value* stencil,
Value* oMask, Value* src0Alpha)
Value* oMask, Value* src0Alpha, DebugLocArray& debugLocs)
{
if (!m_hasDiscard)
{
......@@ -759,6 +766,7 @@ void PixelShaderLowering::EmitRTWrite(
colors[RTindexVal],
colors[1 - RTindexVal],
depth, stencil, 0);
colors[RTindexVal].inst->setDebugLoc(debugLocs[RTindexVal]);
//Single source RTWrite
colors[1 - RTindexVal].inst = addRTWrite(
......@@ -767,6 +775,7 @@ void PixelShaderLowering::EmitRTWrite(
oMask, colors[1 - RTindexVal],
depth,
stencil);
colors[1 - RTindexVal].inst->setDebugLoc(debugLocs[1 - RTindexVal]);
}
else
{
......@@ -778,6 +787,8 @@ void PixelShaderLowering::EmitRTWrite(
oMask, colors[i],
depth,
stencil);
colors[i].inst->setDebugLoc(debugLocs[i]);
}
}
......
......@@ -31,6 +31,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/PassManager.h>
#include <llvm/IR/DebugLoc.h>
#include "common/LLVMWarningsPop.hpp"
namespace IGC
......@@ -101,6 +102,7 @@ private:
};
typedef smallvector<ColorOutput, 4> ColorOutputArray;
typedef smallvector<llvm::DebugLoc, 4> DebugLocArray;
// For multirate PS, output & discard will be lowered to RTWrite during
// unification. Some optimization (GVN) may convert the pixel mask in
......@@ -110,12 +112,13 @@ private:
void FindIntrinsicOutput(ColorOutputArray& color,
llvm::Value*& depth, llvm::Value*& stencil,
llvm::Value*& mask, llvm::Value*& src0Alpha);
llvm::Value*& mask, llvm::Value*& src0Alpha,
DebugLocArray& debugLocs);
void EmitMemoryFence(llvm::IRBuilder<> builder);
void EmitRTWrite(ColorOutputArray& color, llvm::Value* depth,
llvm::Value* stencil, llvm::Value* mask,
llvm::Value* src0Alpha);
llvm::Value* src0Alpha, DebugLocArray& debugLocs);
void EmitCoarseMask(llvm::Value* mask);
llvm::Value* fcmpUNEConst(llvm::IGCIRBuilder<>& irb,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment