/// <summary> /// Compile the shader file using the given compilation function /// </summary> public void CompileShaders(List <ShaderFile> shaderFiles, CompileFunc compileFunc) { string title = name; string msg; // @todo //if (GlslangCompiler.Locate(package as SPIRVExtensionPackage) == null) //{ // msg = "Could not locate the glslang reference compiler (glslangvalidator.exe) in system path!"; // VsShellUtilities.ShowMessageBox(ServiceProvider, msg, title, OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); // OutputWindow.Add(msg); // return; //} ErrorList.Clear(); bool success = true; msg = ""; foreach (var shaderFile in shaderFiles) { string targetEnv = (package as SPIRVExtensionPackage).OptionTargetEnv; List <string> validatorOutput; bool compiled = compileFunc(shaderFile.fileName, out validatorOutput, package as SPIRVExtensionPackage); if (compiled) { OutputWindow.Add(string.Join("\n", validatorOutput)); } else { msg += string.Format(CultureInfo.CurrentCulture, "Shader \"{0}\" could not be compiled to SPIR-V!", shaderFile.fileName) + "\n"; Debug.Write(msg); ParseErrors(validatorOutput, shaderFile); OutputWindow.Add(shaderFile.fileName + "\n" + string.Join("\n", validatorOutput)); success = false; } } if (success) { if (shaderFiles.Count == 1) { msg = string.Format(CultureInfo.CurrentCulture, "Shader successfully compiled to \"{0}\"", shaderFiles[0].fileName + ".spv"); } else { msg = "All shaders successfully compiled to SPIR-V"; } VsShellUtilities.ShowMessageBox(ServiceProvider, msg, title, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } else { VsShellUtilities.ShowMessageBox(ServiceProvider, msg, title, OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } if (ErrorList.ErrorCount() > 0) { ErrorList.Show(); } }