Esempio n. 1
0
        public static DebugEffectAssignment Parse(DebugBytecodeReader reader, DebugBytecodeReader annotationReader)
        {
            //MemberType type, such as AddressV or Filter
            var memberType = (EffectAssignmentType)annotationReader.ReadUInt32("MemberType");
            //	$"EffectStateAnnotationType is {memberType}");
            //MemberIndex is 1 for BlendEnable[1] = TRUE;
            var memberIndex        = annotationReader.ReadUInt32("MemberIndex");
            var assignmentType     = (EffectCompilerAssignmentType)annotationReader.ReadUInt32("AssignmentType");
            var valueOffset        = annotationReader.ReadUInt32("ValueOffset");
            var typeSpecificReader = reader.CopyAtOffset("TypeSpecificReader", annotationReader, (int)valueOffset);
            DebugEffectAssignment result;

            switch (assignmentType)
            {
            case EffectCompilerAssignmentType.Constant:
                result = DebugEffectConstantAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.Variable:
                result = DebugEffectVariableAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.ConstantIndex:
                result = DebugEffectConstantIndexAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.VariableIndex:
                result = DebugEffectVariableIndexAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.ExpressionIndex:
                result = DebugEffectExpressionIndexAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.Expression:
                result = DebugEffectExpressionAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.InlineShader:
                result = DebugEffectInlineShaderAssignment.Parse(reader, typeSpecificReader);
                break;

            case EffectCompilerAssignmentType.InlineShader5:
                result = DebugEffectInlineShader5Assignment.Parse(reader, typeSpecificReader);
                break;

            default:
                throw new ParseException($"Unsupported EffectCompilerAssignmentType {assignmentType}");
            }
            result.MemberType     = memberType;
            result.MemberIndex    = memberIndex;
            result.AssignmentType = assignmentType;
            result.ValueOffset    = valueOffset;
            return(result);
        }
        public new static DebugEffectInlineShader5Assignment Parse(DebugBytecodeReader reader, DebugBytecodeReader variableReader)
        {
            var result       = new DebugEffectInlineShader5Assignment();
            var shaderOffset = result.ShaderOffset = variableReader.ReadUInt32("ShaderOffset");

            result.SODeclsOffset[0] = variableReader.ReadUInt32("SODeclsOffset0");
            result.SODeclsOffset[1] = variableReader.ReadUInt32("SODeclsOffset1");
            result.SODeclsOffset[2] = variableReader.ReadUInt32("SODeclsOffset2");
            result.SODeclsOffset[3] = variableReader.ReadUInt32("SODeclsOffset3");
            var SoDeclsCount = result.SODeclsCount = variableReader.ReadUInt32("SODeclsCount");

            result.RasterizedStream = variableReader.ReadUInt32("RasterizedStream");
            var interfaceBindingCount  = result.InterfaceBindingCount = variableReader.ReadUInt32("InterfaceBindingCount");
            var interfaceBindingOffset = result.InterfaceBindingOffset = variableReader.ReadUInt32("InterfaceBindinfOffset");
            var shaderReader           = reader.CopyAtOffset("ShaderReader", variableReader, (int)shaderOffset);
            var shaderSize             = shaderReader.ReadUInt32("ShaderSize");

            if (shaderSize != 0)
            {
                result.Shader = BytecodeContainer.Parse(shaderReader.ReadBytes("Shader", (int)shaderSize));
            }
            for (int i = 0; i < 4; i++)
            {
                var offset = result.SODeclsOffset[i];
                if (offset != 0)
                {
                    var soDeclReader = reader.CopyAtOffset("SODeclReader", variableReader, (int)offset);
                    result.SODecls.Add(soDeclReader.ReadString($"SODecl{i}"));
                }
            }
            var interfaceReader = reader.CopyAtOffset("InterfaceReader", variableReader, (int)interfaceBindingOffset);

            for (int i = 0; i < interfaceBindingCount; i++)
            {
                result.InterfaceBindings.Add(DebugEffectInterfaceInitializer.Parse(reader, interfaceReader));
            }
            return(result);
        }