| 57 | } |
| 58 | |
| 59 | bool DXCompile(const char *pSrcCode, |
| 60 | const DefineList* pDefines, |
| 61 | const char *pEntryPoint, |
| 62 | const char *pParams, |
| 63 | D3D12_SHADER_BYTECODE* pOutBytecode) |
| 64 | { |
| 65 | //compute hash |
| 66 | // |
| 67 | size_t hash; |
| 68 | hash = HashShaderString((GetShaderCompilerLibDir() + "\\").c_str() , pSrcCode); |
| 69 | hash = Hash(pEntryPoint, strlen(pEntryPoint), hash); |
| 70 | hash = Hash(pParams, strlen(pParams), hash); |
| 71 | if (pDefines != NULL) |
| 72 | { |
| 73 | hash = pDefines->Hash(hash); |
| 74 | } |
| 75 | |
| 76 | #ifdef USE_MULTITHREADED_CACHE |
| 77 | // Compile if not in cache |
| 78 | // |
| 79 | if (s_shaderCache.CacheMiss(hash, pOutBytecode)) |
| 80 | #endif |
| 81 | { |
| 82 | char *SpvData = NULL; |
| 83 | size_t SpvSize = 0; |
| 84 | |
| 85 | DXCompileToDXO(hash, pSrcCode, pDefines, pEntryPoint, pParams, &SpvData, &SpvSize); |
| 86 | |
| 87 | assert(SpvSize != 0); |
| 88 | pOutBytecode->BytecodeLength = SpvSize; |
| 89 | pOutBytecode->pShaderBytecode = SpvData; |
| 90 | |
| 91 | #ifdef USE_MULTITHREADED_CACHE |
| 92 | s_shaderCache.UpdateCache(hash, pOutBytecode); |
| 93 | #endif |
| 94 | } |
| 95 | |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | bool CompileShaderFromString( |
| 100 | const char *pShaderCode, |
no test coverage detected