| 117 | } |
| 118 | |
| 119 | ref<const ProgramVersion> ProgramManager::createProgramVersion(const Program& program, std::string& log) const |
| 120 | { |
| 121 | CpuTimer timer; |
| 122 | timer.update(); |
| 123 | |
| 124 | auto pSlangRequest = createSlangCompileRequest(program); |
| 125 | if (pSlangRequest == nullptr) |
| 126 | return nullptr; |
| 127 | |
| 128 | SlangResult slangResult = spCompile(pSlangRequest); |
| 129 | log += spGetDiagnosticOutput(pSlangRequest); |
| 130 | if (SLANG_FAILED(slangResult)) |
| 131 | { |
| 132 | spDestroyCompileRequest(pSlangRequest); |
| 133 | return nullptr; |
| 134 | } |
| 135 | |
| 136 | Slang::ComPtr<slang::IComponentType> pSlangGlobalScope; |
| 137 | spCompileRequest_getProgram(pSlangRequest, pSlangGlobalScope.writeRef()); |
| 138 | |
| 139 | Slang::ComPtr<slang::ISession> pSlangSession(pSlangGlobalScope->getSession()); |
| 140 | |
| 141 | // Prepare entry points. |
| 142 | std::vector<Slang::ComPtr<slang::IComponentType>> pSlangEntryPoints; |
| 143 | for (const auto& entryPointGroup : program.mDesc.entryPointGroups) |
| 144 | { |
| 145 | for (const auto& entryPoint : entryPointGroup.entryPoints) |
| 146 | { |
| 147 | Slang::ComPtr<slang::IComponentType> pSlangEntryPoint; |
| 148 | spCompileRequest_getEntryPoint(pSlangRequest, entryPoint.globalIndex, pSlangEntryPoint.writeRef()); |
| 149 | |
| 150 | // Rename entry point in the generated code if the exported name differs from the source name. |
| 151 | // This makes it possible to generate different specializations of the same source entry point, |
| 152 | // for example by setting different type conformances. |
| 153 | if (entryPoint.exportName != entryPoint.name) |
| 154 | { |
| 155 | Slang::ComPtr<slang::IComponentType> pRenamedEntryPoint; |
| 156 | pSlangEntryPoint->renameEntryPoint(entryPoint.exportName.c_str(), pRenamedEntryPoint.writeRef()); |
| 157 | pSlangEntryPoints.push_back(pRenamedEntryPoint); |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | pSlangEntryPoints.push_back(pSlangEntryPoint); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // Extract list of files referenced, for dependency-tracking purposes. |
| 167 | int depFileCount = spGetDependencyFileCount(pSlangRequest); |
| 168 | for (int ii = 0; ii < depFileCount; ++ii) |
| 169 | { |
| 170 | std::string depFilePath = spGetDependencyFilePath(pSlangRequest, ii); |
| 171 | if (std::filesystem::exists(depFilePath)) |
| 172 | program.mFileTimeMap[depFilePath] = getFileModifiedTime(depFilePath); |
| 173 | } |
| 174 | |
| 175 | // Note: the `ProgramReflection` needs to be able to refer back to the |
| 176 | // `ProgramVersion`, but the `ProgramVersion` can't be initialized |
no test coverage detected