Exemplo n.º 1
0
        public static VariableBlob Parse(BytecodeReader reader, BytecodeReader dataReader)
        {
            var result = new VariableBlob();

            result.Index = dataReader.ReadUInt32();
            var blobSize     = dataReader.ReadUInt32();
            var paddedSize   = blobSize + (blobSize % 4 == 0 ? 0 : 4 - blobSize % 4);
            var shaderReader = dataReader.CopyAtCurrentPosition();
            var data         = dataReader.ReadBytes((int)paddedSize);

            if (!_IsShader(data))
            {
                if (blobSize == 0)
                {
                    result.Value = "";
                }
                else
                {
                    result.Value = Encoding.UTF8.GetString(data, 0, (int)(blobSize - 1));
                }
            }
            else
            {
                result.Shader = ShaderModel.Parse(shaderReader);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static EffectContainer Parse(BytecodeReader reader, uint length)
        {
            var result         = new EffectContainer();
            var chunkReader    = reader.CopyAtCurrentPosition();
            var footerOffset   = chunkReader.ReadUInt32() + 4;
            var bodyReader     = chunkReader.CopyAtCurrentPosition();
            var footerReader   = reader.CopyAtOffset((int)footerOffset);
            var variableCount  = footerReader.ReadUInt32();
            var techniqueCount = footerReader.ReadUInt32();
            var passCount      = footerReader.ReadUInt32();
            var shaderCount    = footerReader.ReadUInt32();

            for (int i = 0; i < variableCount; i++)
            {
                result.Variables.Add(Variable.Parse(bodyReader, footerReader));
            }
            for (int i = 0; i < techniqueCount; i++)
            {
                result.Techniques.Add(Technique.Parse(bodyReader, footerReader));
            }
            var variableBlobCount = footerReader.ReadUInt32();
            var stateBlobCount    = footerReader.ReadUInt32();

            for (int i = 0; i < variableBlobCount; i++)
            {
                var data = VariableBlob.Parse(bodyReader, footerReader);
                result.VariableBlobs.Add(data);
            }
            for (int i = 0; i < stateBlobCount; i++)
            {
                var data = StateBlob.Parse(bodyReader, footerReader);
                result.StateBlobs.Add(data);
            }
            result.BuildBlobLookup();
            return(result);
        }