Esempio n. 1
0
 //See Shader.ExportBinary
 public void ExportShader(Shader shader, IExportContainer container, Stream stream,
                          Func <Version, GPUPlatform, ShaderTextExporter> exporterInstantiator)
 {
     if (IsSerialized(container.Version))
     {
         using (ShaderWriter writer = new ShaderWriter(stream, shader, exporterInstantiator))
         {
             ExportParsedForm(shader.ParsedForm, writer);
         }
     }
     else if (IsEncoded(container.Version))
     {
         using (ShaderWriter writer = new ShaderWriter(stream, shader, exporterInstantiator))
         {
             string header = Encoding.UTF8.GetString(shader.Script);
             shader.SubProgramBlob.Export(writer, header);
         }
     }
     else
     {
         var bytes = Encoding.ASCII.GetBytes("/*Default*/\n");
         stream.Write(bytes, 0, bytes.Length);
         shader.ExportBinary(container, stream);
     }
 }