예제 #1
0
        public static EffectAssignment Parse(BytecodeReader reader, BytecodeReader annotationReader)
        {
            //MemberType type, such as AddressV or Filter
            var memberType = (EffectAssignmentType)annotationReader.ReadUInt32();
            //	$"EffectStateAnnotationType is {memberType}");
            //MemberIndex is 1 for BlendEnable[1] = TRUE;
            var memberIndex        = annotationReader.ReadUInt32();
            var assignmentType     = (EffectCompilerAssignmentType)annotationReader.ReadUInt32();
            var valueOffset        = annotationReader.ReadUInt32();
            var typeSpecificReader = reader.CopyAtOffset((int)valueOffset);
            EffectAssignment result;

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

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

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

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

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

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

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

            case EffectCompilerAssignmentType.InlineShader5:
                result = EffectInlineShader5Assignment.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 EffectConstantAssignment Parse(BytecodeReader reader, BytecodeReader assignmentReader)
        {
            var result          = new EffectConstantAssignment();
            var assignmentCount = assignmentReader.ReadUInt32();

            for (int i = 0; i < assignmentCount; i++)
            {
                result.Types.Add((EffectScalarType)assignmentReader.ReadUInt32());
                result.Values.Add(Number.Parse(assignmentReader));
            }
            return(result);
        }