internal Shader(GraphicsDevice device, BinaryReader reader)
{
GraphicsDevice = device;
var isVertexShader = reader.ReadBoolean();
Stage = isVertexShader ? ShaderStage.Vertex : ShaderStage.Pixel;
var shaderLength = reader.ReadInt32();
var shaderBytecode = reader.ReadBytes(shaderLength);
var samplerCount = (int)reader.ReadByte();
Samplers = new SamplerInfo[samplerCount];
for (var s = 0; s < samplerCount; s++)
{
Samplers[s].type = (SamplerType)reader.ReadByte();
Samplers[s].textureSlot = reader.ReadByte();
Samplers[s].samplerSlot = reader.ReadByte();
if (reader.ReadBoolean())
{
Samplers[s].state = new SamplerState();
Samplers[s].state.AddressU = (TextureAddressMode)reader.ReadByte();
Samplers[s].state.AddressV = (TextureAddressMode)reader.ReadByte();
Samplers[s].state.AddressW = (TextureAddressMode)reader.ReadByte();
Samplers[s].state.BorderColor = new Color(
reader.ReadByte(),
reader.ReadByte(),
reader.ReadByte(),
reader.ReadByte());
Samplers[s].state.Filter = (TextureFilter)reader.ReadByte();
Samplers[s].state.MaxAnisotropy = reader.ReadInt32();
Samplers[s].state.MaxMipLevel = reader.ReadInt32();
Samplers[s].state.MipMapLevelOfDetailBias = reader.ReadSingle();
}
#if OPENGL
Samplers[s].name = reader.ReadString();
#else
Samplers[s].name = null;
#endif
Samplers[s].parameter = reader.ReadByte();
}
var cbufferCount = (int)reader.ReadByte();
CBuffers = new int[cbufferCount];
for (var c = 0; c < cbufferCount; c++)
CBuffers[c] = reader.ReadByte();
PlatformConstruct(reader, isVertexShader, shaderBytecode);
}