|
@@ -215,6 +215,54 @@ static CallInst *FindCallToCreateHandle(Value *handleType) {
|
|
return CI;
|
|
return CI;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+DxilResourceProperties GetResourcePropertyFromHandleCall(const hlsl::DxilModule *M, CallInst *handleCall) {
|
|
|
|
+
|
|
|
|
+ DxilResourceProperties RP = {};
|
|
|
|
+ RP.Class = DXIL::ResourceClass::Invalid;
|
|
|
|
+ RP.Kind = DXIL::ResourceKind::Invalid;
|
|
|
|
+
|
|
|
|
+ ConstantInt *HandleOpCodeConst = cast<ConstantInt>(
|
|
|
|
+ handleCall->getArgOperand(DXIL::OperandIndex::kOpcodeIdx));
|
|
|
|
+ DXIL::OpCode handleOp = static_cast<DXIL::OpCode>(HandleOpCodeConst->getLimitedValue());
|
|
|
|
+ if (handleOp == DXIL::OpCode::CreateHandle) {
|
|
|
|
+ if (ConstantInt *resClassArg =
|
|
|
|
+ dyn_cast<ConstantInt>(handleCall->getArgOperand(
|
|
|
|
+ DXIL::OperandIndex::kCreateHandleResClassOpIdx))) {
|
|
|
|
+ DXIL::ResourceClass resClass = static_cast<DXIL::ResourceClass>(
|
|
|
|
+ resClassArg->getLimitedValue());
|
|
|
|
+ ConstantInt *rangeID = GetArbitraryConstantRangeID(handleCall);
|
|
|
|
+ if (rangeID) {
|
|
|
|
+ DxilResource resource;
|
|
|
|
+ if (resClass == DXIL::ResourceClass::UAV)
|
|
|
|
+ resource = M->GetUAV(rangeID->getLimitedValue());
|
|
|
|
+ else if (resClass == DXIL::ResourceClass::SRV)
|
|
|
|
+ resource = M->GetSRV(rangeID->getLimitedValue());
|
|
|
|
+ RP = resource_helper::loadFromResourceBase(&resource);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (handleOp == DXIL::OpCode::CreateHandleForLib) {
|
|
|
|
+ // If library handle, find DxilResource by checking the name
|
|
|
|
+ if (LoadInst *LI = dyn_cast<LoadInst>(handleCall->getArgOperand(
|
|
|
|
+ DXIL::OperandIndex::kCreateHandleForLibResOpIdx))) {
|
|
|
|
+ Value *resType = LI->getOperand(0);
|
|
|
|
+ for (auto &&res : M->GetUAVs()) {
|
|
|
|
+ if (res->GetGlobalSymbol() == resType) {
|
|
|
|
+ RP = resource_helper::loadFromResourceBase(res.get());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (handleOp == DXIL::OpCode::AnnotateHandle) {
|
|
|
|
+ DxilInst_AnnotateHandle annotateHandle(cast<Instruction>(handleCall));
|
|
|
|
+ Type *ResPropTy = M->GetOP()->GetResourcePropertiesType();
|
|
|
|
+
|
|
|
|
+ RP = resource_helper::loadFromAnnotateHandle(annotateHandle, ResPropTy, *M->GetShaderModel());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return RP;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
|
|
ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
|
|
const hlsl::DxilModule *M) {
|
|
const hlsl::DxilModule *M) {
|
|
ShaderFlags flag;
|
|
ShaderFlags flag;
|
|
@@ -315,71 +363,15 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
|
|
CallInst *handleCall = FindCallToCreateHandle(resHandle);
|
|
CallInst *handleCall = FindCallToCreateHandle(resHandle);
|
|
// Check if this is a library handle or general create handle
|
|
// Check if this is a library handle or general create handle
|
|
if (handleCall) {
|
|
if (handleCall) {
|
|
- ConstantInt *HandleOpCodeConst = cast<ConstantInt>(
|
|
|
|
- handleCall->getArgOperand(DXIL::OperandIndex::kOpcodeIdx));
|
|
|
|
- DXIL::OpCode handleOp = static_cast<DXIL::OpCode>(HandleOpCodeConst->getLimitedValue());
|
|
|
|
- if (handleOp == DXIL::OpCode::CreateHandle) {
|
|
|
|
- if (ConstantInt *resClassArg =
|
|
|
|
- dyn_cast<ConstantInt>(handleCall->getArgOperand(
|
|
|
|
- DXIL::OperandIndex::kCreateHandleResClassOpIdx))) {
|
|
|
|
- DXIL::ResourceClass resClass = static_cast<DXIL::ResourceClass>(
|
|
|
|
- resClassArg->getLimitedValue());
|
|
|
|
- if (resClass == DXIL::ResourceClass::UAV) {
|
|
|
|
- // Validator 1.0 assumes that all uav load is multi component load.
|
|
|
|
- if (hasMulticomponentUAVLoadsBackCompat) {
|
|
|
|
- hasMulticomponentUAVLoads = true;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- ConstantInt *rangeID = GetArbitraryConstantRangeID(handleCall);
|
|
|
|
- if (rangeID) {
|
|
|
|
- DxilResource resource = M->GetUAV(rangeID->getLimitedValue());
|
|
|
|
- if ((resource.IsTypedBuffer() ||
|
|
|
|
- resource.IsAnyTexture()) &&
|
|
|
|
- !dxilutil::IsResourceSingleComponent(resource.GetRetType())) {
|
|
|
|
- hasMulticomponentUAVLoads = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- DXASSERT(false, "Resource class must be constant.");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (handleOp == DXIL::OpCode::CreateHandleForLib) {
|
|
|
|
- // If library handle, find DxilResource by checking the name
|
|
|
|
- if (LoadInst *LI = dyn_cast<LoadInst>(handleCall->getArgOperand(
|
|
|
|
- DXIL::OperandIndex::
|
|
|
|
- kCreateHandleForLibResOpIdx))) {
|
|
|
|
- Value *resType = LI->getOperand(0);
|
|
|
|
- for (auto &&res : M->GetUAVs()) {
|
|
|
|
- if (res->GetGlobalSymbol() == resType) {
|
|
|
|
- if ((res->IsTypedBuffer() || res->IsAnyTexture()) &&
|
|
|
|
- !dxilutil::IsResourceSingleComponent(res->GetRetType())) {
|
|
|
|
- hasMulticomponentUAVLoads = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (handleOp == DXIL::OpCode::AnnotateHandle) {
|
|
|
|
- DxilInst_AnnotateHandle annotateHandle(handleCall);
|
|
|
|
- Type *ResPropTy = M->GetOP()->GetResourcePropertiesType();
|
|
|
|
-
|
|
|
|
- DxilResourceProperties RP =
|
|
|
|
- resource_helper::loadFromAnnotateHandle(
|
|
|
|
- annotateHandle, ResPropTy, *M->GetShaderModel());
|
|
|
|
- if (RP.Class == DXIL::ResourceClass::UAV) {
|
|
|
|
- // Validator 1.0 assumes that all uav load is multi component
|
|
|
|
- // load.
|
|
|
|
- if (hasMulticomponentUAVLoadsBackCompat) {
|
|
|
|
|
|
+ DxilResourceProperties RP = GetResourcePropertyFromHandleCall(M, handleCall);
|
|
|
|
+ if (RP.Class == DXIL::ResourceClass::UAV) {
|
|
|
|
+ // Validator 1.0 assumes that all uav load is multi component load.
|
|
|
|
+ if (hasMulticomponentUAVLoadsBackCompat) {
|
|
|
|
+ hasMulticomponentUAVLoads = true;
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+ if (DXIL::IsTyped(RP.Kind) && !RP.Typed.SingleComponent)
|
|
hasMulticomponentUAVLoads = true;
|
|
hasMulticomponentUAVLoads = true;
|
|
- continue;
|
|
|
|
- } else {
|
|
|
|
- if (DXIL::IsTyped(RP.Kind) &&
|
|
|
|
- !RP.Typed.SingleComponent)
|
|
|
|
- hasMulticomponentUAVLoads = true;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|