Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static DebugBinaryData Parse(DebugBytecodeReader reader, DebugBytecodeReader blobReader)
        {
            var result = new DebugBinaryData();

            result.Index = blobReader.ReadUInt32("Index");
            result.Size  = blobReader.ReadUInt32("Size");
            var startPosition = blobReader._reader.BaseStream.Position;
            var header        = blobReader.PeakUint32();
            var shaderType    = (ShaderType)(header >> 16);
            var paddedSize    = result.Size + (result.Size % 4 == 0 ? 0 : 4 - result.Size % 4);

            if (shaderType == ShaderType.Pixel || shaderType == ShaderType.Vertex || shaderType == ShaderType.Expression)
            {
                var shaderReader = blobReader.CopyAtCurrentPosition("ShaderReader", blobReader);
                result.Shader = DebugShaderModel.Parse(shaderReader);
            }
            else if (result.Size > 0)
            {
                blobReader.ReadBytes("Value", (int)paddedSize);
            }
            blobReader._reader.BaseStream.Position = startPosition + paddedSize;
            return(result);
        }