forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShaderData.writer.cs
58 lines (50 loc) · 1.81 KB
/
ShaderData.writer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.IO;
namespace TwoMGFX
{
internal partial class ShaderData
{
public void Write(BinaryWriter writer, Options options)
{
writer.Write(IsVertexShader);
writer.Write(ShaderCode.Length);
writer.Write(ShaderCode);
writer.Write((byte)_samplers.Length);
foreach (var sampler in _samplers)
{
writer.Write((byte)sampler.type);
writer.Write((byte)sampler.textureSlot);
writer.Write((byte)sampler.samplerSlot);
if (sampler.state != null)
{
writer.Write(true);
writer.Write((byte)sampler.state.AddressU);
writer.Write((byte)sampler.state.AddressV);
writer.Write((byte)sampler.state.AddressW);
writer.Write(sampler.state.BorderColor.R);
writer.Write(sampler.state.BorderColor.G);
writer.Write(sampler.state.BorderColor.B);
writer.Write(sampler.state.BorderColor.A);
writer.Write((byte)sampler.state.Filter);
writer.Write(sampler.state.MaxAnisotropy);
writer.Write(sampler.state.MaxMipLevel);
writer.Write(sampler.state.MipMapLevelOfDetailBias);
}
else
writer.Write(false);
writer.Write(sampler.samplerName);
writer.Write((byte)sampler.parameter);
}
writer.Write((byte)_cbuffers.Length);
foreach (var cb in _cbuffers)
writer.Write((byte)cb);
writer.Write((byte)_attributes.Length);
foreach (var attrib in _attributes)
{
writer.Write(attrib.name);
writer.Write((byte)attrib.usage);
writer.Write((byte)attrib.index);
writer.Write((short)attrib.location);
}
}
}
}