Commit 019cef93 authored by Sohil Bammi's avatar Sohil Bammi Committed by gbsbuild

Transitioning Resource Alloc metadata info (including InlineSampler change) to...

Transitioning Resource Alloc metadata info (including InlineSampler change) to the new framework. Deleting all structures and classes relating to it from the old framework

Change-Id: Ib2d0ed81832270250cbbaa8e1d011bea8243e813
parent ed44eb83
......@@ -246,9 +246,9 @@ SOpenCLKernelInfo::SResourceInfo COpenCLKernel::getResourceInfo(int argNo)
CodeGenContext *pCtx = GetContext();
ModuleMetaData* modMD = pCtx->getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[entry];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[argNo];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[argNo];
SOpenCLKernelInfo::SResourceInfo resInfo;
ResourceTypeEnum type = (ResourceTypeEnum) argAlloc->type;
......@@ -275,55 +275,48 @@ ResourceExtensionTypeEnum COpenCLKernel::getExtensionInfo(int argNo)
CodeGenContext *pCtx = GetContext();
ModuleMetaData* modMD = pCtx->getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[entry];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[argNo];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[argNo];
return (ResourceExtensionTypeEnum) argAlloc->extensionType;
}
void COpenCLKernel::CreateInlineSamplerAnnotations()
{
FunctionInfoMetaDataHandle funcInfoMD = m_pMdUtils->getFunctionsInfoItem(entry);
ResourceAllocMetaDataHandle resAllocMD = funcInfoMD->getResourceAlloc();
if (!resAllocMD->hasValue())
if (m_Context->getModuleMetaData()->FuncMD.find(entry) != m_Context->getModuleMetaData()->FuncMD.end())
{
return;
}
FunctionMetaData funcMD = m_Context->getModuleMetaData()->FuncMD.find(entry)->second;
for (auto i = resAllocMD->begin_InlineSamplers(), e = resAllocMD->end_InlineSamplers(); i != e; ++i)
{
InlineSamplerMetaDataHandle inlineSamplerMD = *i;
iOpenCL::SamplerInputAnnotation* samplerInput = new iOpenCL::SamplerInputAnnotation();
samplerInput->AnnotationSize = sizeof(samplerInput);
samplerInput->SamplerType = iOpenCL::SAMPLER_OBJECT_TEXTURE;
samplerInput->SamplerTableIndex = inlineSamplerMD->getIndex();
samplerInput->TCXAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD->getTCXAddressMode());
samplerInput->TCYAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD->getTCYAddressMode());
samplerInput->TCZAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD->getTCZAddressMode());
samplerInput->NormalizedCoords = inlineSamplerMD->getNormalizedCoords() != 0 ? true : false;
samplerInput->MagFilterType = iOpenCL::SAMPLER_MAPFILTER_TYPE(inlineSamplerMD->getMagFilterType());
samplerInput->MinFilterType = iOpenCL::SAMPLER_MAPFILTER_TYPE(inlineSamplerMD->getMinFilterType());
samplerInput->MipFilterType = iOpenCL::SAMPLER_MIPFILTER_TYPE(inlineSamplerMD->getMipFilterType());
ResourceAllocMD resAllocMD = funcMD.resAllocMD;
samplerInput->CompareFunc = iOpenCL::SAMPLER_COMPARE_FUNC_TYPE(inlineSamplerMD->getCompareFunc());
for (auto i = resAllocMD.inlineSamplersMD.begin(), e = resAllocMD.inlineSamplersMD.end(); i != e; ++i)
{
InlineSamplersMD inlineSamplerMD = *i;
iOpenCL::SamplerInputAnnotation* samplerInput = new iOpenCL::SamplerInputAnnotation();
samplerInput->BorderColorR = inlineSamplerMD->getBorderColorR();
samplerInput->BorderColorG = inlineSamplerMD->getBorderColorG();
samplerInput->BorderColorB = inlineSamplerMD->getBorderColorB();
samplerInput->BorderColorA = inlineSamplerMD->getBorderColorA();
samplerInput->AnnotationSize = sizeof(samplerInput);
samplerInput->SamplerType = iOpenCL::SAMPLER_OBJECT_TEXTURE;
samplerInput->SamplerTableIndex = inlineSamplerMD.index;
m_kernelInfo.m_samplerInput.push_back(samplerInput);
}
samplerInput->TCXAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD.TCXAddressMode);
samplerInput->TCYAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD.TCYAddressMode);
samplerInput->TCZAddressMode = iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE(inlineSamplerMD.TCZAddressMode);
samplerInput->NormalizedCoords = inlineSamplerMD.NormalizedCoords != 0 ? true : false;
samplerInput->MagFilterType = iOpenCL::SAMPLER_MAPFILTER_TYPE(inlineSamplerMD.MagFilterType);
samplerInput->MinFilterType = iOpenCL::SAMPLER_MAPFILTER_TYPE(inlineSamplerMD.MinFilterType);
samplerInput->MipFilterType = iOpenCL::SAMPLER_MIPFILTER_TYPE(inlineSamplerMD.MipFilterType);
samplerInput->CompareFunc = iOpenCL::SAMPLER_COMPARE_FUNC_TYPE(inlineSamplerMD.CompareFunc);
{
auto *MD = m_Context->getModuleMetaData();
auto I = MD->FuncMD.find(entry);
if (I != MD->FuncMD.end())
{
m_kernelInfo.m_HasInlineVmeSamplers = I->second.hasInlineVmeSamplers;
samplerInput->BorderColorR = inlineSamplerMD.BorderColorR;
samplerInput->BorderColorG = inlineSamplerMD.BorderColorG;
samplerInput->BorderColorB = inlineSamplerMD.BorderColorB;
samplerInput->BorderColorA = inlineSamplerMD.BorderColorA;
m_kernelInfo.m_samplerInput.push_back(samplerInput);
}
m_kernelInfo.m_HasInlineVmeSamplers = funcMD.hasInlineVmeSamplers;
}
}
......@@ -719,9 +712,9 @@ void COpenCLKernel::CreateAnnotations(KernelArg* kernelArg, uint payloadPosition
CodeGenContext *pCtx = GetContext();
ModuleMetaData* modMD = pCtx->getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[entry];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[argNo];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[argNo];
iOpenCL::PointerArgumentAnnotation *ptrAnnotation = new iOpenCL::PointerArgumentAnnotation();
......@@ -1676,11 +1669,13 @@ void COpenCLKernel::FillKernel()
void COpenCLKernel::RecomputeBTLayout()
{
ResourceAllocMetaDataHandle resourceAlloc = m_pMdUtils->getFunctionsInfoItem(entry)->getResourceAlloc();
assert(resourceAlloc->hasValue() && "Resource Allocation information not present");
CodeGenContext *pCtx = GetContext();
ModuleMetaData* modMD = pCtx->getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[entry];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
// Get the number of UAVs and Resources from MD.
int numUAVs = resourceAlloc->getUAVsNum();
int numResources = resourceAlloc->getSRVsNum();
int numUAVs = resAllocMD->uavsNumType;
int numResources = resAllocMD->srvsNumType;
// Now, update the layout information
USC::SShaderStageBTLayout* layout = ((COCLBTILayout *)m_pBtiLayout)->getModifiableLayout();
......
......@@ -467,9 +467,9 @@ VISAVariableLocation VISAModule::GetVariableLocation(const llvm::Instruction* pI
const std::string typeStr = modMD->FuncMD[const_cast<Function*>(m_pEntryFunc)].m_OpenCLArgBaseTypes[pArgument->getArgNo()];
KernelArg::ArgType argType = KernelArg::calcArgType(pArgument, typeStr);
FunctionMetaData *funcMD = &modMD->FuncMD[const_cast<Function*>(m_pEntryFunc)];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() == IGCLLVM::GetFuncArgSize(m_pEntryFunc) && "Invalid ArgAllocMDList");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[pArgument->getArgNo()];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() == IGCLLVM::GetFuncArgSize(m_pEntryFunc) && "Invalid ArgAllocMDList");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[pArgument->getArgNo()];
unsigned int index = argAlloc->indexType;
switch (argType)
......
This diff is collapsed.
This diff is collapsed.
......@@ -56,17 +56,14 @@ BuiltinsConverter::BuiltinsConverter(void) : FunctionPass(ID)
bool BuiltinsConverter::fillIndexMap(Function &F)
{
MetaDataUtils *pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
ResourceAllocMetaDataHandle resourceAllocInfo = pMdUtils->getFunctionsInfoItem(&F)->getResourceAlloc();
assert(resourceAllocInfo->hasValue() && "Resource Allocation Information not present");
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[&F];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
for (Function::arg_iterator arg = F.arg_begin(), e = F.arg_end(); arg != e; ++arg)
{
int argNo = (*arg).getArgNo();
FunctionMetaData *funcMD = &modMD->FuncMD[&F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[argNo];
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[argNo];
if (argAlloc->type == OtherResourceType)
{
// Other resource type has no valid index and is not needed in the map.
......@@ -81,7 +78,7 @@ bool BuiltinsConverter::fillIndexMap(Function &F)
// The sampler arguments have already been allocated indices by the ResourceAllocator.
// So, the first sampler we can allocate here may not be 0, but is the number of
// already allocated indices.
m_nextSampler = resourceAllocInfo->getSamplersNum();
m_nextSampler = resAllocMD->samplersNumType;
return true;
}
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ IGC_INITIALIZE_PASS_END(Image3dToImage2darray, PASS_FLAG, PASS_DESCRIPTION, PASS
char Image3dToImage2darray::ID = 0;
Image3dToImage2darray::Image3dToImage2darray() :
FunctionPass(ID), m_Changed(false), m_MetadataUtils(nullptr)
FunctionPass(ID), m_Changed(false), m_MetadataUtils(nullptr), m_modMD(nullptr)
{
initializeImage3dToImage2darrayPass(*PassRegistry::getPassRegistry());
}
......
......@@ -70,7 +70,7 @@ namespace IGC
llvm::GenIntrinsicInst *pCall,
unsigned imageIdx,
const IGCMD::MetaDataUtils* pMdUtils,
const IGC::ModuleMetaData* modMD,
const IGC::ModuleMetaData* m_modMD,
const llvm::Value* pCoord);
};
......
......@@ -185,7 +185,9 @@ Value* ImageFuncResolution::getImageNumSamples(CallInst &CI)
Value* ImageFuncResolution::getSamplerAddressMode(CallInst &CI)
{
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils);
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils, modMD);
assert(sampler != nullptr && "Sampler untraceable for ImplicitArg::SAMPLER_ADDRESS");
if (isa<Argument>(sampler))
{
......@@ -195,22 +197,25 @@ Value* ImageFuncResolution::getSamplerAddressMode(CallInst &CI)
else
{
llvm::Function* pFunc = CI.getParent()->getParent();
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(pFunc);
ResourceAllocMetaDataHandle resAllocMD = funcInfoMD->getResourceAlloc();
assert(isa<ConstantInt>(sampler) && "Sampler must be a constant integer");
InlineSamplerState samplerStateAddressMode{ cast<ConstantInt>(sampler)->getZExtValue() };
uint64_t samplerVal = 0;
uint samplerValue = int_cast<unsigned int>(cast<ConstantInt>(sampler)->getZExtValue());
for (auto i = resAllocMD->begin_InlineSamplers(), e = resAllocMD->end_InlineSamplers(); i != e; ++i){
InlineSamplerMetaDataHandle inlineSamplerMD = *i;
if (samplerValue == inlineSamplerMD->getValue())
if (modMD->FuncMD.find(pFunc) != modMD->FuncMD.end())
{
FunctionMetaData funcMD = modMD->FuncMD[pFunc];
ResourceAllocMD resAllocMD = funcMD.resAllocMD;
for (auto i = resAllocMD.inlineSamplersMD.begin(), e = resAllocMD.inlineSamplersMD.end(); i != e; i++)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerValue) };
samplerVal = inlineSamplerMD->getAddressMode();
IGC::InlineSamplersMD inlineSamplerMD = *i;
if (samplerValue == inlineSamplerMD.m_Value)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerValue) };
samplerVal = inlineSamplerMD.addressMode;
}
}
}
return ConstantInt::get(CI.getType(), samplerVal);
}
}
......@@ -218,7 +223,8 @@ Value* ImageFuncResolution::getSamplerAddressMode(CallInst &CI)
Value* ImageFuncResolution::getSamplerNormalizedCoords(CallInst &CI)
{
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils);
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils, modMD);
if (sampler == nullptr)
{
// TODO: For now disable WA if unable to trace sampler argument.
......@@ -233,22 +239,25 @@ Value* ImageFuncResolution::getSamplerNormalizedCoords(CallInst &CI)
else
{
llvm::Function* pFunc = CI.getParent()->getParent();
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(pFunc);
ResourceAllocMetaDataHandle resAllocMD = funcInfoMD->getResourceAlloc();
assert(isa<ConstantInt>(sampler) && "Sampler must be a constant integer");
uint64_t samplerVal = 0;
uint samplerValue = int_cast<unsigned int>(cast<ConstantInt>(sampler)->getZExtValue());
for (auto i = resAllocMD->begin_InlineSamplers(), e = resAllocMD->end_InlineSamplers(); i != e; ++i){
InlineSamplerMetaDataHandle inlineSamplerMD = *i;
if (samplerValue == inlineSamplerMD->getValue())
if (modMD->FuncMD.find(pFunc) != modMD->FuncMD.end())
{
FunctionMetaData funcMD = modMD->FuncMD[pFunc];
ResourceAllocMD resAllocMD = funcMD.resAllocMD;
for (auto i = resAllocMD.inlineSamplersMD.begin(), e = resAllocMD.inlineSamplersMD.end(); i != e; ++i)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerValue) };
samplerVal = inlineSamplerMD->getNormalizedCoords();
IGC::InlineSamplersMD inlineSamplerMD = *i;
if (samplerValue == inlineSamplerMD.m_Value)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerValue) };
samplerVal = inlineSamplerMD.NormalizedCoords;
}
}
}
return ConstantInt::get(CI.getType(), samplerVal);
}
}
......@@ -256,7 +265,8 @@ Value* ImageFuncResolution::getSamplerNormalizedCoords(CallInst &CI)
Value* ImageFuncResolution::getSamplerSnapWARequired(CallInst &CI)
{
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils);
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
Value* sampler = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, pMdUtils, modMD);
if (sampler == nullptr)
{
// TODO: For now disable WA if unable to trace sampler argument.
......@@ -273,28 +283,33 @@ Value* ImageFuncResolution::getSamplerSnapWARequired(CallInst &CI)
assert(isa<ConstantInt>(sampler) && "Sampler must be a constant integer");
llvm::Function* pFunc = CI.getParent()->getParent();
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(pFunc);
ResourceAllocMetaDataHandle resAllocMD = funcInfoMD->getResourceAlloc();
bool snapWARequired = false;
uint samplerVal = int_cast<unsigned int>(cast<ConstantInt>(sampler)->getZExtValue());
for (auto i = resAllocMD->begin_InlineSamplers(), e = resAllocMD->end_InlineSamplers(); i != e; ++i){
InlineSamplerMetaDataHandle inlineSamplerMD = *i;
if (samplerVal == inlineSamplerMD->getValue())
if (modMD->FuncMD.find(pFunc) != modMD->FuncMD.end())
{
FunctionMetaData funcMD = modMD->FuncMD[pFunc];
ResourceAllocMD resAllocMD = funcMD.resAllocMD;
for (auto i = resAllocMD.inlineSamplersMD.begin(), e = resAllocMD.inlineSamplersMD.end(); i != e; ++i)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerVal) };
bool anyAddressModeClamp =
inlineSamplerMD->getTCXAddressMode() == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER ||
inlineSamplerMD->getTCYAddressMode() == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER ||
inlineSamplerMD->getTCZAddressMode() == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER;
bool anyMapFilterModeNearest =
inlineSamplerMD->getMagFilterType() == iOpenCL::SAMPLER_MAPFILTER_POINT ||
inlineSamplerMD->getMinFilterType() == iOpenCL::SAMPLER_MAPFILTER_POINT;
snapWARequired = anyAddressModeClamp &&
anyMapFilterModeNearest &&
!inlineSamplerMD->getNormalizedCoords();
InlineSamplersMD inlineSamplerMD = *i;
if (samplerVal == inlineSamplerMD.m_Value)
{
InlineSamplerState samplerState{ static_cast<uint64_t>(samplerVal) };
bool anyAddressModeClamp =
inlineSamplerMD.TCXAddressMode == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER ||
inlineSamplerMD.TCYAddressMode == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER ||
inlineSamplerMD.TCZAddressMode == iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_BORDER;
bool anyMapFilterModeNearest =
inlineSamplerMD.MagFilterType == iOpenCL::SAMPLER_MAPFILTER_POINT ||
inlineSamplerMD.MinFilterType == iOpenCL::SAMPLER_MAPFILTER_POINT;
snapWARequired = anyAddressModeClamp &&
anyMapFilterModeNearest &&
!inlineSamplerMD.NormalizedCoords;
}
}
}
return ConstantInt::get(CI.getType(), snapWARequired ? -1 : 0);
}
}
......
......@@ -162,7 +162,7 @@ void ImageFuncsAnalysis::visitCallInst(CallInst &CI)
// We only care about image and sampler arguments here, inline samplers
// don't require extra kernel parameters.
Value* callArg = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils());
Value* callArg = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(&CI, 0, getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils(), getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData());
// TODO: For now assume that we may not trace a sampler/texture for indirect access.
// In this case we provide no WA support for indirect case and all WAs will return 0.
......
......@@ -1019,10 +1019,10 @@ KernelArgs::KernelArgs(const Function& F, const DataLayout* DL, MetaDataUtils* p
{
// Check for bindless images which require allocation
FunctionMetaData *funcMD = &moduleMD->FuncMD[const_cast<llvm::Function*>(&F)];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
if (resourceAlloc->argAllocMDList.size() > funcArg->getArgNo())
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
if (resAllocMD->argAllocMDList.size() > funcArg->getArgNo())
{
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[funcArg->getArgNo()];
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[funcArg->getArgNo()];
if (argAlloc->type == ResourceTypeEnum::BindlessUAVResourceType ||
argAlloc->type == ResourceTypeEnum::BindlessSamplerResourceType)
{
......
......@@ -100,7 +100,7 @@ bool ResourceAllocator::runOnFunction(llvm::Function &F)
if (modMD->FuncMD.find(&F) == modMD->FuncMD.end())
assert("Function was not found.");
FunctionMetaData *funcMD = &modMD->FuncMD[&F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
// Go over all of the kernel args.
// For each kernel arg, if it represents an explicit image or buffer argument,
......@@ -304,15 +304,14 @@ bool ResourceAllocator::runOnFunction(llvm::Function &F)
// Param allocations must be inserted to the Metadata Utils in order.
MetaDataUtils *pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
auto funcResourceAllocInfo = pMdUtils->getFunctionsInfoItem(&F)->getResourceAlloc();
for( auto i : paramAllocations )
{
resourceAlloc->argAllocMDList.push_back(i);
resAllocMD->argAllocMDList.push_back(i);
}
funcResourceAllocInfo->setUAVsNum(numUAVs);
funcResourceAllocInfo->setSRVsNum(numResources);
funcResourceAllocInfo->setSamplersNum(numSamplers);
resAllocMD->uavsNumType = numUAVs;
resAllocMD->srvsNumType = numResources;
resAllocMD->samplersNumType = numSamplers;
pMdUtils->save(F.getContext());
......
......@@ -426,9 +426,9 @@ void StatelessToStatefull::visitCallInst(CallInst &I)
{
ModuleMetaData *modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[baseArgNumber];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[baseArgNumber];
Constant* resourceNumber = ConstantInt::get(int32Ty, argAlloc->indexType);
unsigned addrSpace = EncodeAS4GFXResource(*resourceNumber, BufferType::UAV, 0);
......@@ -485,9 +485,9 @@ void StatelessToStatefull::visitLoadInst(LoadInst &I)
{
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[baseArgNumber];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[baseArgNumber];
Constant* resourceNumber = ConstantInt::get(int32Ty, argAlloc->indexType);
......@@ -536,9 +536,9 @@ void StatelessToStatefull::visitStoreInst(StoreInst &I)
{
ModuleMetaData *modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert(resourceAlloc->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[baseArgNumber];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert(resAllocMD->argAllocMDList.size() > 0 && "ArgAllocMDList is empty.");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[baseArgNumber];
Constant* resourceNumber = ConstantInt::get(int32Ty, argAlloc->indexType);
unsigned addrSpace = EncodeAS4GFXResource(*resourceNumber, BufferType::UAV, 0);
......
......@@ -208,9 +208,9 @@ void SubGroupFuncsResolution::BTIHelper( llvm::CallInst &CI )
{
int argNo = ( *arg ).getArgNo();
FunctionMetaData *funcMD = &modMD->FuncMD[F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
assert((size_t) argNo < resourceAlloc->argAllocMDList.size() && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resourceAlloc->argAllocMDList[argNo];
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
assert((size_t) argNo < resAllocMD->argAllocMDList.size() && "ArgAllocMD List Out of Bounds");
ArgAllocMD *argAlloc = &resAllocMD->argAllocMDList[argNo];
m_argIndexMap[ &(*arg) ] = CImagesBI::ParamInfo(
argAlloc->indexType,
(ResourceTypeEnum) argAlloc->type,
......
......@@ -311,9 +311,9 @@ void PromoteResourceToDirectAS::PromoteSamplerTextureToDirectAS(GenIntrinsicInst
if (modMD->FuncMD.find(function) != modMD->FuncMD.end())
{
FunctionMetaData *funcMD = &modMD->FuncMD[function];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
ArgAllocMD *argInfo = &resourceAlloc->argAllocMDList[argPtr->getArgNo()];
assert((size_t) argPtr->getArgNo() < resourceAlloc->argAllocMDList.size() && "ArgAllocMD List Out of Bounds Error");
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
ArgAllocMD *argInfo = &resAllocMD->argAllocMDList[argPtr->getArgNo()];
assert((size_t) argPtr->getArgNo() < resAllocMD->argAllocMDList.size() && "ArgAllocMD List Out of Bounds Error");
if (argInfo->type == IGCMD::ResourceTypeEnum::BindlessUAVResourceType)
{
......@@ -791,9 +791,9 @@ void PromoteResourceToDirectAS::PromoteStatelessToBindlessBuffers(Function& F)
if (modMD->FuncMD.find(&F) != modMD->FuncMD.end())
{
FunctionMetaData *funcMD = &modMD->FuncMD[&F];
ResourceAllocMD *resourceAlloc = &funcMD->resourceAlloc;
ArgAllocMD *argInfo = &resourceAlloc->argAllocMDList[srcPtr->getArgNo()];
assert((size_t) srcPtr->getArgNo() < resourceAlloc->argAllocMDList.size() && "ArgAllocMD List Out of Bounds");
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
ArgAllocMD *argInfo = &resAllocMD->argAllocMDList[srcPtr->getArgNo()];
assert((size_t) srcPtr->getArgNo() < resAllocMD->argAllocMDList.size() && "ArgAllocMD List Out of Bounds");
if (argInfo->type == IGCMD::ResourceTypeEnum::UAVResourceType)
{
// Update metadata to show bindless resource type
......
......@@ -43,12 +43,32 @@ namespace IGC
int indexType = -1;
};
struct InlineSamplersMD
{
int m_Value = 0;
int addressMode = 0;
int index = 0;
int TCXAddressMode = 0;
int TCYAddressMode = 0;
int TCZAddressMode = 0;
int MagFilterType = 0;
int MinFilterType = 0;
int MipFilterType = 0;
int CompareFunc = 0;
int NormalizedCoords = 0;
float BorderColorR = 0.0f;
float BorderColorG = 0.0f;
float BorderColorB = 0.0f;
float BorderColorA = 0.0f;
};
struct ResourceAllocMD
{
int uavsNumType = 0; //unused
int srvsNumType = 0; //unused
int samplersNumType = 0; //unused
int uavsNumType = 0;
int srvsNumType = 0;
int samplersNumType = 0;
std::vector<ArgAllocMD> argAllocMDList;
std::vector<InlineSamplersMD> inlineSamplersMD;
};
struct ComputeShaderSecondCompileInputInfoMD
......@@ -82,7 +102,7 @@ namespace IGC
WorkGroupWalkOrderMD workGroupWalkOrder;
std::vector<FuncArgMD> funcArgs;
FunctionTypeMD functionType = UnknownFunction;
ResourceAllocMD resourceAlloc;
ResourceAllocMD resAllocMD;
std::vector<unsigned> maxByteOffsets;
bool IsInitializer = false;
bool IsFinalizer = false;
......
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