Example #1
0
        public static DebugStateBlob Parse(DebugBytecodeReader reader, DebugBytecodeReader blobReader)
        {
            var result = new DebugStateBlob();

            result.TechniqueIndex    = blobReader.ReadUInt32("TechniqueIndex");
            result.PassIndex         = blobReader.ReadUInt32("PassIndex");
            result.SamplerStateIndex = blobReader.ReadUInt32("SamplerStateIndex");
            result.AssignmentIndex   = blobReader.ReadUInt32("AssignmentIndex");
            result.BlobType          = blobReader.ReadEnum32 <StateBlobType>("BlobType");
            if (result.BlobType == StateBlobType.Shader)
            {
                result.ShaderSize = blobReader.ReadUInt32("BlobSize");
                var startPosition = blobReader._reader.BaseStream.Position;
                var shaderReader  = blobReader.CopyAtCurrentPosition("ShaderReader", blobReader);
                result.Shader = DebugShaderModel.Parse(shaderReader);
                blobReader._reader.BaseStream.Position = startPosition + result.ShaderSize;
            }
            if (result.BlobType == StateBlobType.Variable)
            {
                result.VariableName = blobReader.TryReadString("VariableName");
            }
            else if (result.BlobType == StateBlobType.IndexShader)
            {
                result.ShaderSize = blobReader.ReadUInt32("BlobSize");
                var startPosition = blobReader._reader.BaseStream.Position;
                var variableSize  = blobReader.ReadUInt32("VariableNameSize");
                var variableData  = blobReader.ReadBytes("VariableData", (int)variableSize);
                result.VariableName = Encoding.UTF8.GetString(variableData, 0, variableData.Length - 1);
                var shaderReader = blobReader.CopyAtCurrentPosition("ShaderReader", blobReader);
                result.Shader = DebugShaderModel.Parse(shaderReader);
                blobReader._reader.BaseStream.Position = startPosition + result.ShaderSize;
            }
            return(result);
        }