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 EffectInlineShaderAssignment Parse(BytecodeReader reader, BytecodeReader assignmentReader) { var result = new EffectInlineShaderAssignment(); var shaderOffset = assignmentReader.ReadUInt32(); var SODeclOffset = assignmentReader.ReadUInt32(); var shaderReader = reader.CopyAtOffset((int)shaderOffset); var shaderSize = shaderReader.ReadUInt32(); if (shaderSize != 0) { result.Shader = BytecodeContainer.Parse(shaderReader.ReadBytes((int)shaderSize)); } var SODeclReader = reader.CopyAtOffset((int)SODeclOffset); result.SODecl = SODeclReader.ReadString(); return(result); }