Expression GetProgram(Draw draw) { _obfuscator.Minify(draw.State); var src = draw.Source; var vsSource = GlslWriter.BuildString(_backend, draw.State.VertexShader, !Environment.Debug); var fsSource = GlslWriter.BuildString(_backend, draw.State.PixelShader, !Environment.Debug); var key = vsSource + ":" + fsSource; foreach (var e in _programs.GetList(key)) { if (e.Source.Package.IsAccessibleFrom(draw.Source.Package)) { return(e); } } int constCount = draw.State.RuntimeConstants.Count; int attribCount = draw.State.VertexAttributes.Count; int uniformCount = draw.State.Uniforms.Count; int samplerCount = draw.State.PixelSamplers.Count; var array = new Expression[constCount + attribCount + uniformCount + samplerCount]; var index = 0; foreach (var v in draw.State.RuntimeConstants) { array[index++] = new Constant(src, Essentials.String, v.Name); } foreach (var v in draw.State.VertexAttributes) { array[index++] = new Constant(src, Essentials.String, v.Name); } foreach (var v in draw.State.Uniforms) { array[index++] = new Constant(src, Essentials.String, v.Name); } foreach (var v in draw.State.PixelSamplers) { array[index++] = new Constant(src, Essentials.String, v.Name); } var prog = ILFactory.CallMethod(src, "Uno.Graphics.OpenGL.GLProgram", "Create", new Constant(src, Essentials.String, vsSource), new Constant(src, Essentials.String, fsSource), new Constant(src, Essentials.Int, constCount), new Constant(src, Essentials.Int, attribCount), new NewArray(src, _stringArray, array)); var result = _bundle.AddProgram(draw.State.Path.DrawBlock, prog); _programs.Add(key, result); if (_dumpShaders) { var prefix = Environment.Combine("shaders", Type.QualifiedName + "." + key.GetHashCode().ToString("x8")); Disk.WriteAllText(prefix + ".vert", vsSource); Disk.WriteAllText(prefix + ".frag", fsSource); } return(result); }