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);
        }
Beispiel #2
0
        public static DebugVariable Parse(DebugBytecodeReader reader, DebugBytecodeReader variableReader)
        {
            var result = new DebugVariable();

            result.ParameterOffset    = variableReader.ReadUInt32("ParameterOffset");
            result.DefaultValueOffset = variableReader.ReadUInt32("DefaultValueOffset");
            result.IsShared           = variableReader.ReadUInt32("IsShared");
            result.AnnotationCount    = variableReader.ReadUInt32("AnnotationCount");
            for (int i = 0; i < result.AnnotationCount; i++)
            {
                variableReader.AddIndent($"Annotation {i}");
                result.Annotations.Add(DebugAnnotation.Parse(reader, variableReader));
                variableReader.RemoveIndent();
            }
            var paramterReader = reader.CopyAtOffset("ParameterReader", variableReader, (int)result.ParameterOffset);

            result.Parameter = DebugParameter.Parse(reader, paramterReader);

            if (result.Parameter.ParameterType.IsSampler())
            {
                var elementCount       = result.Parameter.Elements > 0 ? result.Parameter.Elements : 1;
                var samplerStateReader = reader.CopyAtOffset("SamplerStateReader", variableReader, (int)result.DefaultValueOffset);
                for (int i = 0; i < elementCount; i++)
                {
                    samplerStateReader.AddIndent($"SamplerState {i}");
                    result.SamplerStates.Add(DebugSamplerState.Parse(reader, samplerStateReader));
                    samplerStateReader.RemoveIndent();
                }
            }
            else
            {
                var valueReader = reader.CopyAtOffset("ValueReader", variableReader, (int)result.DefaultValueOffset);
                result.Value = result.Parameter.ReadParameterValue(valueReader);
            }
            return(result);
        }