Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static DebugEffectChunk Parse(DebugBytecodeReader reader, uint length)
        {
            var result       = new DebugEffectChunk();
            var footerOffset = reader.ReadUInt32("footerOffset");
            var bodyReader   = reader.CopyAtCurrentPosition("BodyReader", reader);
            var dummyReader  = bodyReader.CopyAtCurrentPosition("Dummy", bodyReader);

            dummyReader.ReadUInt32("Zero");
            var footerReader   = bodyReader.CopyAtOffset("FooterReader", reader, (int)footerOffset);
            var variableCount  = result.VariableCount = footerReader.ReadUInt32("VariableCount");
            var techniqueCount = result.TechniqueCount = footerReader.ReadUInt32("TechniqueCount");

            result.PassCount   = footerReader.ReadUInt32("PassCount");
            result.ShaderCount = footerReader.ReadUInt32("ShaderCount");

            for (int i = 0; i < variableCount; i++)
            {
                footerReader.AddIndent($"Variable {i}");
                result.Variables.Add(DebugVariable.Parse(bodyReader, footerReader));
                footerReader.RemoveIndent();
            }
            for (int i = 0; i < techniqueCount; i++)
            {
                footerReader.AddIndent($"Technique {i}");
                result.Techniques.Add(DebugTechnique.Parse(bodyReader, footerReader));
                footerReader.RemoveIndent();
            }

            result.VariableBlobCount = footerReader.ReadUInt32("VariableBlobCount");
            result.StateBlobCount    = footerReader.ReadUInt32("StateBlobCount");
            for (int i = 0; i < result.VariableBlobCount; i++)
            {
                footerReader.AddIndent($"VariableBlob {i}");
                result.VariableBlobs.Add(DebugBinaryData.Parse(bodyReader, footerReader));
                footerReader.RemoveIndent();
            }
            for (int i = 0; i < result.StateBlobCount; i++)
            {
                footerReader.AddIndent($"StateBlob {i}");
                result.StateBlobs.Add(DebugStateBlob.Parse(bodyReader, footerReader));
                footerReader.RemoveIndent();
            }
            return(result);
        }