public void Export(TextWriter writer, Shader shader, ShaderType type, Func <ShaderGpuProgramType, ShaderTextExporter> exporterInstantiator) { if (SubPrograms.Count > 0) { writer.WriteIntent(3); writer.Write("Program \"{0}\" {{\n", type.ToProgramTypeString()); foreach (SerializedSubProgram subProgram in SubPrograms) { Platform uplatform = shader.File.Platform; GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(uplatform); int index = shader.Platforms.IndexOf(platform); ShaderSubProgramBlob blob = shader.SubProgramBlobs[index]; int count = SubPrograms.Where(t => t.GpuProgramType == subProgram.GpuProgramType).Select(t => t.ShaderHardwareTier).Distinct().Count(); subProgram.Export(writer, blob, uplatform, count > 1, exporterInstantiator); } writer.WriteIntent(3); writer.Write("}\n"); } }
public StringBuilder ToString(StringBuilder sb, SShader shader, ShaderType type) { if (SubPrograms.Count > 0) { sb.AppendIntent(3).Append("Program").Append(' '); sb.Append('"').Append(type.ToProgramTypeString()).Append('"'); sb.Append(' ').Append('{').Append('\n'); foreach (SerializedSubProgram subProgram in SubPrograms) { GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(m_assetsFile.Platform); int index = shader.Platforms.IndexOf(platform); ShaderSubProgramBlob blob = shader.SubProgramBlobs[index]; int count = SubPrograms.Where(t => t.GpuProgramType == subProgram.GpuProgramType).Select(t => t.ShaderHardwareTier).Distinct().Count(); subProgram.ToString(sb, blob, count > 1); } sb.AppendIntent(3).Append('}').Append('\n'); } return(sb); }