@@ -345,7 +345,8 @@ void DumpShaderFile(
345345 const char * pBuffer,
346346 const UINT bufferSize,
347347 const QWORD hash,
348- const std::string& ext)
348+ const std::string& ext,
349+ std::string* fileName = nullptr )
349350{
350351 if (pBuffer && bufferSize > 0 )
351352 {
@@ -366,6 +367,11 @@ void DumpShaderFile(
366367 fwrite (pBuffer, 1 , bufferSize, pFile);
367368 fclose (pFile);
368369 }
370+
371+ if (fileName != nullptr )
372+ {
373+ *fileName = fullPath.str ();
374+ }
369375 }
370376}
371377
@@ -879,16 +885,18 @@ bool TranslateBuild(
879885
880886 if (IGC_IS_FLAG_ENABLED (ShaderDumpEnable))
881887 {
888+ std::string iof, of, inputf; // filenames for internal_options.txt, options.txt, and .spv/.bc
889+
882890 const char *pOutputFolder = IGC::Debug::GetShaderOutputFolder ();
883891 QWORD hash = inputShHash.getAsmHash ();
884892
885893 if (inputDataFormatTemp == TB_DATA_FORMAT_LLVM_BINARY)
886894 {
887- DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInput , pInputArgs->InputSize , hash, " .bc" );
895+ DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInput , pInputArgs->InputSize , hash, " .bc" , &inputf );
888896 }
889897 else if (inputDataFormatTemp == TB_DATA_FORMAT_SPIR_V)
890898 {
891- DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInput , pInputArgs->InputSize , hash, " .spv" );
899+ DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInput , pInputArgs->InputSize , hash, " .spv" , &inputf );
892900#if defined(IGC_SPIRV_TOOLS_ENABLED)
893901 spv_text spirvAsm = nullptr ;
894902 if (DisassembleSPIRV (pInputArgs->pInput , pInputArgs->InputSize , &spirvAsm) == SPV_SUCCESS)
@@ -899,8 +907,24 @@ bool TranslateBuild(
899907#endif // defined(IGC_SPIRV_TOOLS_ENABLED)
900908 }
901909
902- DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInternalOptions , pInputArgs->InternalOptionsSize , hash, " _internal_options.txt" );
903- DumpShaderFile (pOutputFolder, (char *)pInputArgs->pOptions , pInputArgs->OptionsSize , hash, " _options.txt" );
910+ DumpShaderFile (pOutputFolder, (char *)pInputArgs->pInternalOptions , pInputArgs->InternalOptionsSize , hash, " _internal_options.txt" , &iof);
911+ DumpShaderFile (pOutputFolder, (char *)pInputArgs->pOptions , pInputArgs->OptionsSize , hash, " _options.txt" , &of);
912+
913+ // dump cmd file that has igcstandalone command to compile this kernel.
914+ std::ostringstream cmdfile;
915+ cmdfile << " igcstandalone -api ocl"
916+ << " -prod " << IGCPlatform.GetProductFamily ()
917+ << " -step " << IGCPlatform.GetRevId ()
918+ << " -inputcs " << inputf;
919+ if (of.size () > 0 )
920+ {
921+ cmdfile << " -foptions " << of;
922+ }
923+ if (iof.size () > 0 )
924+ {
925+ cmdfile << " -finternal_options " << iof;
926+ }
927+ DumpShaderFile (pOutputFolder, cmdfile.str ().c_str (), cmdfile.str ().size (), hash, " _cmd.txt" );
904928 }
905929
906930 if (!ParseInput (pKernelModule, pInputArgs, pOutputArgs, *llvmContext, inputDataFormatTemp))
0 commit comments