int C_DECL Hlsl2Glsl_Translate( const ShHandle handle, const char* entry, ETargetVersion targetVersion, unsigned options) { if (handle == 0) return 0; HlslCrossCompiler* compiler = handle; compiler->infoSink.info.erase(); // \todo [2013-05-14 pyry] Maintain different support library per target version. initializeHLSLSupportLibrary(targetVersion); if (!compiler->IsASTTransformed() || !compiler->IsGlslProduced()) { compiler->infoSink.info.message(EPrefixError, "Shader does not have valid object code."); return 0; } bool ret = compiler->GetLinker()->link(compiler, entry, targetVersion, options); finalizeHLSLSupportLibrary(); return ret ? 1 : 0; }
int C_DECL Hlsl2Glsl_Initialize(GlobalAllocateFunction alloc, GlobalFreeFunction free, void* user) { TInfoSink infoSink; bool ret = true; SetGlobalAllocationAllocator(alloc, free, user); if (!InitProcess()) return 0; // This method should be called once per process. If its called by multiple threads, then // we need to have thread synchronization code around the initialization of per process // global pool allocator if (!PerProcessGPA) { TPoolAllocator *builtInPoolAllocator = new TPoolAllocator(true); builtInPoolAllocator->push(); TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator; SetGlobalPoolAllocatorPtr(builtInPoolAllocator); TSymbolTable symTables[EShLangCount]; GenerateBuiltInSymbolTable(infoSink, symTables, EShLangCount); PerProcessGPA = new TPoolAllocator(true); PerProcessGPA->push(); SetGlobalPoolAllocatorPtr(PerProcessGPA); SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]); SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]); SetGlobalPoolAllocatorPtr(gPoolAllocator); symTables[EShLangVertex].pop(); symTables[EShLangFragment].pop(); initializeHLSLSupportLibrary(); builtInPoolAllocator->popAll(); delete builtInPoolAllocator; } return ret ? 1 : 0; }