Exemple #1
0
        public static DebugAnnotation Parse(DebugBytecodeReader reader, DebugBytecodeReader annotationReader)
        {
            var result = new DebugAnnotation();

            result.ParameterOffset = annotationReader.ReadUInt32("ParameterOffset");
            result.ValueOffset     = annotationReader.ReadUInt32("ValueOffset");

            var parameterReader = reader.CopyAtOffset("AnnotationType", annotationReader, (int)result.ParameterOffset);

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

            var valueReader = reader.CopyAtOffset("ValueReader", annotationReader, (int)result.ValueOffset);

            result.Values = result.Parameter.ReadParameterValue(valueReader);

            return(result);
        }
Exemple #2
0
        public static DebugAssignment Parse(DebugBytecodeReader reader, DebugBytecodeReader assignmentReader)
        {
            var result = new DebugAssignment();

            result.Type        = assignmentReader.ReadEnum32 <StateType>("Type");
            result.ArrayIndex  = assignmentReader.ReadUInt32("ArrayIndex");
            result.TypeOffset  = assignmentReader.ReadUInt32("TypeOffset");
            result.ValueOffset = assignmentReader.ReadUInt32("ValueOffset");

            var variableReader = reader.CopyAtOffset("AssignmentTypeReader", assignmentReader, (int)result.TypeOffset);

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

            var valueReader = reader.CopyAtOffset("ValueReader", assignmentReader, (int)result.ValueOffset);

            result.Value = result.Parameter.ReadParameterValue(valueReader);
            return(result);
        }
Exemple #3
0
        public static DebugParameter Parse(DebugBytecodeReader reader, DebugBytecodeReader variableReader)
        {
            var result = new DebugParameter();

            result.ParameterType  = variableReader.ReadEnum32 <ParameterType>("ParameterType");
            result.ParameterClass = variableReader.ReadEnum32 <ParameterClass>("ParameterClass");
            result.NameOffset     = variableReader.ReadUInt32("NameOffset");

            var nameReader = reader.CopyAtOffset("NameReader", variableReader, (int)result.NameOffset);

            result.Name = nameReader.TryReadString("Name");

            result.SemanticOffset = variableReader.ReadUInt32("SemanticOffset");

            var semanticReader = reader.CopyAtOffset("SemanticReader", variableReader, (int)result.SemanticOffset);

            result.Semantic = semanticReader.TryReadString("Semantic");

            if (result.ParameterClass == ParameterClass.Scalar ||
                result.ParameterClass == ParameterClass.Vector ||
                result.ParameterClass == ParameterClass.MatrixRows ||
                result.ParameterClass == ParameterClass.MatrixColumns)
            {
                result.Elements = variableReader.ReadUInt32("ElementCount");
                result.Rows     = variableReader.ReadUInt32("Rows");
                result.Columns  = variableReader.ReadUInt32("Columns");
            }
            if (result.ParameterClass == ParameterClass.Struct)
            {
                result.Elements          = variableReader.ReadUInt32("ElementCount");
                result.StructMemberCount = variableReader.ReadUInt32("StructMemberCount");
                for (int i = 0; i < result.StructMemberCount; i++)
                {
                    result.StructMembers.Add(DebugParameter.Parse(reader, variableReader));
                }
            }
            if (result.ParameterClass == ParameterClass.Object)
            {
                result.Elements = variableReader.ReadUInt32("Elements");
            }
            return(result);
        }
        public static List <Number> ReadParameterValue(this DebugParameter parameter, DebugBytecodeReader valueReader)
        {
            var result = new List <Number>();

            if (parameter.ParameterClass == ParameterClass.Object)
            {
                var defaultValueCount = parameter.GetSize() / 4;
                var data = valueReader.ReadBytes("ParameterValue", (int)defaultValueCount * 4);
                result.Add(new Number(data));
            }
            else
            {
                var defaultValueCount = parameter.GetSize() / 4;
                var data = valueReader.ReadBytes("ParameterValue", (int)defaultValueCount * 4);
                for (int i = 0; i < defaultValueCount; i++)
                {
                    result.Add(Number.FromByteArray(data, i * 4));
                }
            }
            return(result);
        }
Exemple #5
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);
        }