@@ -432,13 +432,23 @@ spv_result_t DisassembleSPIRV(
432432#endif // defined(IGC_SPIRV_TOOLS_ENABLED)
433433
434434#if defined(IGC_SPIRV_ENABLED)
435+ bool CheckForImageUsage (const std::string & SPIRVBinary) {
436+ std::istringstream repIS (SPIRVBinary);
437+ llvm::Optional<SPIRV::SPIRVModuleReport> report = SPIRV::getSpirvReport (repIS);
438+ SPIRV::SPIRVModuleTextReport textReport = SPIRV::formatSpirvReport (*report);
439+
440+ auto it = std::find (textReport.Capabilities .begin (), textReport.Capabilities .end (), " ImageBasic" );
441+ return it != textReport.Capabilities .end ();
442+ }
443+
435444// Translate SPIR-V binary to LLVM Module
436445bool TranslateSPIRVToLLVM (
437446 const STB_TranslateInputArgs& InputArgs,
438447 llvm::LLVMContext& Context,
439448 llvm::StringRef SPIRVBinary,
440449 llvm::Module*& LLVMModule,
441- std::string& stringErrMsg)
450+ std::string& stringErrMsg,
451+ const PLATFORM& platform)
442452{
443453 bool success = true ;
444454 std::istringstream IS (SPIRVBinary.str ());
@@ -468,6 +478,14 @@ bool TranslateSPIRVToLLVM(
468478 Opts.setSpecConst (SC.first , SC.second );
469479 }
470480
481+ if (platform.eProductFamily == IGFX_PVC) {
482+ if (CheckForImageUsage (SPIRVBinary.str ())) {
483+ stringErrMsg = " For PVC platform images should not be used" ;
484+ return false ;
485+ }
486+ }
487+
488+
471489 // Actual translation from SPIR-V to LLVM
472490 success = llvm::readSpirv (Context, Opts, IS, LLVMModule, stringErrMsg);
473491#else // IGC Legacy SPIRV Translator
@@ -693,7 +711,7 @@ bool ProcessElfInput(
693711 Context.setAsSPIRV ();
694712 std::string stringErrMsg;
695713 llvm::StringRef buf (SpvPair.second .pInput , SpvPair.second .InputSize );
696- success = TranslateSPIRVToLLVM (SpvPair.second , *Context.getLLVMContext (), buf, pKernelModule, stringErrMsg);
714+ success = TranslateSPIRVToLLVM (SpvPair.second , *Context.getLLVMContext (), buf, pKernelModule, stringErrMsg, platform );
697715 if (!success)
698716 {
699717 SetErrorMessage (stringErrMsg, OutputArgs);
@@ -891,7 +909,8 @@ bool ParseInput(
891909 const STB_TranslateInputArgs* pInputArgs,
892910 STB_TranslateOutputArgs* pOutputArgs,
893911 llvm::LLVMContext& oclContext,
894- TB_DATA_FORMAT inputDataFormatTemp)
912+ TB_DATA_FORMAT inputDataFormatTemp,
913+ const IGC::CPlatform& IGCPlatform)
895914{
896915 pKernelModule = nullptr ;
897916
@@ -955,7 +974,7 @@ bool ParseInput(
955974#if defined(IGC_SPIRV_ENABLED)
956975 // convert SPIR-V binary to LLVM module
957976 std::string stringErrMsg;
958- bool success = TranslateSPIRVToLLVM (*pInputArgs, oclContext, strInput, pKernelModule, stringErrMsg);
977+ bool success = TranslateSPIRVToLLVM (*pInputArgs, oclContext, strInput, pKernelModule, stringErrMsg, (PLATFORM&)IGCPlatform );
959978#else
960979 std::string stringErrMsg{" SPIRV consumption not enabled for the TARGET." };
961980 bool success = false ;
@@ -1339,7 +1358,7 @@ bool TranslateBuildSPMD(
13391358 DumpShaderFile (pOutputFolder, outputstr.str ().c_str (), outputstr.str ().size (), hash, " _cmd.txt" );
13401359 }
13411360
1342- if (!ParseInput (pKernelModule, pInputArgs, pOutputArgs, *llvmContext, inputDataFormatTemp))
1361+ if (!ParseInput (pKernelModule, pInputArgs, pOutputArgs, *llvmContext, inputDataFormatTemp, IGCPlatform ))
13431362 {
13441363 return false ;
13451364 }
@@ -1521,7 +1540,7 @@ bool TranslateBuildSPMD(
15211540
15221541 IGC::Debug::RegisterComputeErrHandlers (*oclContext.getLLVMContext ());
15231542
1524- if (!ParseInput (pKernelModule, pInputArgs, pOutputArgs, *oclContext.getLLVMContext (), inputDataFormatTemp))
1543+ if (!ParseInput (pKernelModule, pInputArgs, pOutputArgs, *oclContext.getLLVMContext (), inputDataFormatTemp, IGCPlatform ))
15251544 {
15261545 return false ;
15271546 }
0 commit comments