| 218 | } |
| 219 | |
| 220 | ref<const ProgramKernels> ProgramManager::createProgramKernels( |
| 221 | const Program& program, |
| 222 | const ProgramVersion& programVersion, |
| 223 | const ProgramVars& programVars, |
| 224 | std::string& log |
| 225 | ) const |
| 226 | { |
| 227 | CpuTimer timer; |
| 228 | timer.update(); |
| 229 | |
| 230 | auto pSlangGlobalScope = programVersion.getSlangGlobalScope(); |
| 231 | auto pSlangSession = pSlangGlobalScope->getSession(); |
| 232 | |
| 233 | slang::IComponentType* pSpecializedSlangGlobalScope = pSlangGlobalScope; |
| 234 | |
| 235 | // Create a composite component type that represents all type conformances |
| 236 | // linked into the `ProgramVersion`. |
| 237 | auto createTypeConformanceComponentList = [&](const TypeConformanceList& typeConformances |
| 238 | ) -> std::optional<Slang::ComPtr<slang::IComponentType>> |
| 239 | { |
| 240 | Slang::ComPtr<slang::IComponentType> pTypeConformancesCompositeComponent; |
| 241 | std::vector<Slang::ComPtr<slang::ITypeConformance>> typeConformanceComponentList; |
| 242 | std::vector<slang::IComponentType*> typeConformanceComponentRawPtrList; |
| 243 | |
| 244 | for (auto& typeConformance : typeConformances) |
| 245 | { |
| 246 | Slang::ComPtr<slang::IBlob> pSlangDiagnostics; |
| 247 | Slang::ComPtr<slang::ITypeConformance> pTypeConformanceComponent; |
| 248 | |
| 249 | // Look for the type and interface type specified by the type conformance. |
| 250 | // If not found we'll log an error and return. |
| 251 | auto slangType = pSlangGlobalScope->getLayout()->findTypeByName(typeConformance.first.typeName.c_str()); |
| 252 | auto slangInterfaceType = pSlangGlobalScope->getLayout()->findTypeByName(typeConformance.first.interfaceName.c_str()); |
| 253 | if (!slangType) |
| 254 | { |
| 255 | log += fmt::format("Type '{}' in type conformance was not found.\n", typeConformance.first.typeName.c_str()); |
| 256 | return {}; |
| 257 | } |
| 258 | if (!slangInterfaceType) |
| 259 | { |
| 260 | log += fmt::format("Interface type '{}' in type conformance was not found.\n", typeConformance.first.interfaceName.c_str()); |
| 261 | return {}; |
| 262 | } |
| 263 | |
| 264 | auto res = pSlangSession->createTypeConformanceComponentType( |
| 265 | slangType, |
| 266 | slangInterfaceType, |
| 267 | pTypeConformanceComponent.writeRef(), |
| 268 | (SlangInt)typeConformance.second, |
| 269 | pSlangDiagnostics.writeRef() |
| 270 | ); |
| 271 | if (SLANG_FAILED(res)) |
| 272 | { |
| 273 | log += "Slang call createTypeConformanceComponentType() failed.\n"; |
| 274 | return {}; |
| 275 | } |
| 276 | if (pSlangDiagnostics && pSlangDiagnostics->getBufferSize() > 0) |
| 277 | { |
no test coverage detected