Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ShaderBytecode.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Text;
4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Serialization;
6 using SiliconStudio.Core.Storage;
7 
8 namespace SiliconStudio.Paradox.Shaders
9 {
10  /// <summary>
11  /// The bytecode of an effect.
12  /// </summary>
13  [DataContract]
14  public partial class ShaderBytecode
15  {
16  /// <summary>
17  /// The stage of this Bytecode.
18  /// </summary>
20 
21  /// <summary>
22  /// Hash of the Data.
23  /// </summary>
24  public ObjectId Id { get; set; }
25 
26  /// <summary>
27  /// Gets the shader data that should be used to create the <see cref="Shader"/>.
28  /// </summary>
29  /// <value>
30  /// The shader data.
31  /// </value>
32  public byte[] Data { get; set; }
33 
34  /// <summary>
35  /// Initializes a new instance of the <see cref="ShaderBytecode"/> class.
36  /// </summary>
37  public ShaderBytecode()
38  {
39  }
40 
41  /// <summary>
42  /// Initializes a new instance of the <see cref="ShaderBytecode"/> class.
43  /// </summary>
44  /// <param name="data">The data.</param>
45  public ShaderBytecode(ObjectId id, byte[] data)
46  {
47  Id = id;
48  Data = data;
49  }
50 
51  /// <summary>
52  /// Performs an implicit conversion from <see cref="ShaderBytecode"/> to <see cref="System.Byte[][]"/>.
53  /// </summary>
54  /// <param name="shaderBytecode">The shader bytecode.</param>
55  /// <returns>The result of the conversion.</returns>
56  public static implicit operator byte[](ShaderBytecode shaderBytecode)
57  {
58  return shaderBytecode.Data;
59  }
60 
61  /// <summary>
62  /// Gets the data as a string.
63  /// </summary>
64  /// <returns>System.String.</returns>
65  public string GetDataAsString()
66  {
67  return Encoding.UTF8.GetString(Data, 0, Data.Length);
68  }
69  }
70 }
ShaderStage Stage
The stage of this Bytecode.
ShaderBytecode()
Initializes a new instance of the ShaderBytecode class.
string GetDataAsString()
Gets the data as a string.
ShaderBytecode(ObjectId id, byte[] data)
Initializes a new instance of the ShaderBytecode class.
A hash to uniquely identify data.
Definition: ObjectId.cs:13
ShaderStage
Enum to specify shader stage.
Definition: ShaderStage.cs:12