private void WriteProgress(string operation, int percentComplete) { if (operation == null) { throw new ArgumentNullException("operation"); } if (percentComplete < 0) { percentComplete = 0; } if (percentComplete > 100) { percentComplete = 100; } if (percentComplete == 100) { HideProgress(); } else { VsStatusBar.Progress( ref _pdwCookieForStatusBar, 1 /* in progress */, operation, (uint)percentComplete, (uint)100); } }
private static string Compile(string shaderCode, ShaderType shaderType) { var options = OptionsPagePackage.Options; if (!string.IsNullOrWhiteSpace(options.ExternalCompilerExeFilePath)) { //create temp shader file for external compiler var shaderFileName = GetShaderFileName(shaderType); try { File.WriteAllText(shaderFileName, shaderCode); using (var process = new Process()) { process.StartInfo.FileName = options.ExternalCompilerExeFilePath; process.StartInfo.Arguments = $"{options.ExternalCompilerArguments} {shaderFileName}"; //arguments process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.CreateNoWindow = true; //do not display a windows VsStatusBar.SetText($"Using external compiler '{Path.GetFileNameWithoutExtension(options.ExternalCompilerExeFilePath)}' with arguments '{options.ExternalCompilerArguments}'"); process.Start(); process.WaitForExit(10000); var output = process.StandardOutput.ReadToEnd(); //The output result return(output.Replace(shaderFileName, "0")); //HACK: glslLangValidator produces inconsistent error message format when using vulkan vs cg compilation } } catch (Exception e) { var message = "Error executing external compiler with message\n" + e.ToString(); VsStatusBar.SetText(message); } } VsStatusBar.SetText("Using driver compiler"); return(CompileOnGPU(shaderCode, shaderType)); }
private static string CompileOnGPU(string shaderCode, string sShaderType) { if (!mappingContentTypeToShaderType.TryGetValue(sShaderType, out ShaderType shaderType)) { var time = DateTime.Now.ToString("HH.mm.ss.fff"); if (ShaderContentTypes.AutoDetect == sShaderType) { shaderType = AutoDetectShaderType(shaderCode); VsStatusBar.SetText($"{time} Auto detecting shader type to '{shaderType}'"); } else { VsStatusBar.SetText($"{time} Unsupported shader type '{sShaderType}' by OpenTK shader compiler. Use an external compiler"); } } try { using (var shader = new ShaderGL(shaderType)) { shader.Compile(shaderCode); return(shader.Log); } } catch (AccessViolationException) { return($"(1 1):ERROR: OpenGL shader compiler has crashed"); } }
private void HideProgress() { VsStatusBar.Progress( ref _pdwCookieForStatusBar, 0 /* completed */, String.Empty, (uint)100, (uint)100); }
private void HideProgress() { ThreadHelper.ThrowIfNotOnUIThread(); VsStatusBar.Progress( ref _pdwCookieForStatusBar, 0 /* completed */, string.Empty, (uint)100, (uint)100); }
private static void RegisterFileExtensions(IFileExtensionRegistryService fileExtensionRegistry, string sExtensions, IContentType contentType) { var extensions = sExtensions.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var ext in extensions) { try { fileExtensionRegistry.AddFileExtension(ext, contentType); } catch (InvalidOperationException) { var titel = "GLSL language integration"; var message = $"{titel}:Extension {ext} is ignored because it is already registered " + $"with a different Visual Studio component. " + $"Please remove it from the {titel} options page!"; VsStatusBar.SetText(message); } } }