예제 #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);
        }
예제 #2
0
        public new static EffectVariableIndexAssignment Parse(BytecodeReader reader, BytecodeReader assignmentReader)
        {
            var result          = new EffectVariableIndexAssignment();
            var arrayNameOffset = assignmentReader.ReadUInt32();
            var arrayNameReader = reader.CopyAtOffset((int)arrayNameOffset);

            result.ArrayName = arrayNameReader.ReadString();
            var variableNameOffset = assignmentReader.ReadUInt32();
            var variableNameReader = reader.CopyAtOffset((int)variableNameOffset);

            result.VariableName = variableNameReader.ReadString();
            return(result);
        }