void ExportSerializedProgram(SerializedProgram serializedProgram, ShaderWriter writer, ShaderType type) { if (serializedProgram.SubPrograms.Count > 0) { writer.WriteIndent(3); writer.Write("Program \"{0}\" {{\n", type.ToProgramTypeString()); HashSet <ShaderGpuProgramType> isTierLookup = GetIsTierLookup(serializedProgram.SubPrograms); var subprograms = serializedProgram.SubPrograms; var best = serializedProgram.SubPrograms .OrderByDescending(subProgram => { GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(writer.Platform); int index = writer.Shader.Platforms.IndexOf(platform); ShaderSubProgramBlob blob = writer.Shader.SubProgramBlobs[index]; var sp = blob.SubPrograms[(int)subProgram.BlobIndex]; return(sp.ProgramData.Count); //return sp.GlobalKeywords.Sum(keyword => keyword.Contains("ON") ? 2 : 1); }).FirstOrDefault(); if (FilterSubPrograms) { subprograms = new SerializedSubProgram[] { best }; } foreach (SerializedSubProgram subProgram in subprograms) { Platform uplatform = writer.Platform; GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(uplatform); int index = writer.Shader.Platforms.IndexOf(platform); ShaderSubProgramBlob blob = writer.Shader.SubProgramBlobs[index]; bool isTier = isTierLookup.Contains(subProgram.GpuProgramType); ExportSerializedSubProgram(subProgram, writer, blob, type, isTier, best.BlobIndex == subProgram.BlobIndex); } writer.WriteIndent(3); writer.Write("}\n"); } }
public void Export(ShaderWriter writer, ShaderType type) { writer.WriteIndent(3); writer.Write("Program \"{0}\" {{\n", type.ToProgramTypeString()); int tierCount = GetTierCount(SubPrograms); for (int i = 0; i < SubPrograms.Length; i++) { SerializedSubProgram subProgram = SubPrograms[i]; Platform uplatform = writer.Platform; GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(uplatform); int index = writer.Shader.Platforms.IndexOf(platform); ref ShaderSubProgramBlob blob = ref writer.Shader.SubProgramBlobs[index]; subProgram.Export(writer, ref blob, type, tierCount > 1); }
public void Export(ShaderWriter writer, ShaderType type) { if (SubPrograms.Length == 0) { return; } writer.WriteIndent(3); writer.Write("Program \"{0}\" {{\n", type.ToProgramTypeString()); int tierCount = GetTierCount(); for (int i = 0; i < SubPrograms.Length; i++) { SubPrograms[i].Export(writer, type, tierCount > 1); } writer.WriteIndent(3); writer.Write("}\n"); }
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); }
public void Export(ShaderWriter writer, ShaderType type) { if (SubPrograms.Count > 0) { writer.WriteIntent(3); writer.Write("Program \"{0}\" {{\n", type.ToProgramTypeString()); HashSet <ShaderGpuProgramType> isTierLookup = GetIsTierLookup(SubPrograms); foreach (SerializedSubProgram subProgram in SubPrograms) { Platform uplatform = writer.Platform; GPUPlatform platform = subProgram.GpuProgramType.ToGPUPlatform(uplatform); int index = writer.Shader.Platforms.IndexOf(platform); ShaderSubProgramBlob blob = writer.Shader.SubProgramBlobs[index]; bool isTier = isTierLookup.Contains(subProgram.GpuProgramType); subProgram.Export(writer, blob, isTier); } writer.WriteIntent(3); writer.Write("}\n"); } }