PDA

View Full Version : GLSlang not catching compile errors, always failing to link



JoshKlint
06-04-2016, 02:08 PM
I've implemented GLSlang into my toolset by including the source directly into my engine. When a forward-compatible OpenGL 400 context is simulated with GLSlang, the reference compiler lets "texture2D" pass, while the Intel and AMD compilers will produce an error. It also seems that only ShLinkExt is implemented; using ShLink results in a missing function when the program is compiled. When I run this code, ShLinkExt always returns 0, no matter what, although the compiling step works:
int numHandles = 0; ShHandle linkhandles[5] = {0}; for (int i = 0; i < 5; ++i) { if (shhandle[i] != 0) { linkhandles[numHandles] = shhandle[i]; numHandles++; } } if (numHandles == 0) return false; ShHandle linker = ShConstructLinker(EShExVertexFragment, 0); ShHandle uniformmap = ShConstructUniformMap(); short* uniformsAccessed[1024]; int numUniformsAccessed[1024]; bool success = ShLinkExt(linker, linkhandles, numHandles);// , uniformmap, uniformsAccessed, numUniformsAccessed) != 0; errortext = ShGetInfoLog(linker); ShDestruct(linker); ShDestruct(uniformmap); return success; Here is my validation / compile function for each stage:
if (source[sourceid] == "") return false; if (!GLSLInitialized) GLSLInitialized = ShInitialize(); int lengths[1]; const char* sources[1]; EShLanguage lang; if (sourceid == Vertex) lang = EShLangVertex; if (sourceid == Geometry) lang = EShLangGeometry; if (sourceid == Evaluation) lang = EShLangTessEvaluation; if (sourceid == Control) lang = EShLangTessControl; if (sourceid == Pixel) lang = EShLangFragment; if (shhandle[sourceid]==0) shhandle[sourceid] = ShConstructCompiler(lang, 0); sources[0] = source[sourceid].c_str(); lengths[0] = source[sourceid].length(); TBuiltInResource res = glslang::DefaultTBuiltInResource; bool success = ShCompile(shhandle[sourceid], sources, 1, lengths, EShOptNone, &res, 0, 400, true, EShMsgDefault) != 0; errortext = ShGetInfoLog(shhandle[sourceid]); return success;