public static DebugEffectObjectVariable Parse(DebugBytecodeReader reader, DebugBytecodeReader variableReader, DebugShaderVersion version, bool isShared = false) { var result = new DebugEffectObjectVariable(); var nameOffset = result.NameOffset = variableReader.ReadUInt32("NameOffset"); var nameReader = reader.CopyAtOffset("NameReader", variableReader, (int)nameOffset); result.Name = nameReader.ReadString("Name"); result.TypeOffset = variableReader.ReadUInt32("TypeOffset"); var typeReader = reader.CopyAtOffset("TypeReader", variableReader, (int)result.TypeOffset); result.Type = DebugEffectType.Parse(reader, typeReader, version); var semanticOffset = result.SemanticOffset = variableReader.ReadUInt32("SemanticOffset"); if (semanticOffset != 0) { var semanticReader = reader.CopyAtOffset("SemanticReader", variableReader, (int)semanticOffset); result.Semantic = semanticReader.ReadString("Semantic"); } else { result.Semantic = ""; } result.BufferOffset = variableReader.ReadUInt32("BufferOffset"); if (isShared) { return(result); } // Initializer data if (result.Type.ObjectType == EffectObjectType.String) { for (int i = 0; i < result.ElementCount; i++) { var stringValueOffset = variableReader.ReadUInt32($"StringValueOffset{i}"); var stringValueReader = reader.CopyAtOffset($"StringValueReader{i}", variableReader, (int)stringValueOffset); result.Strings.Add(stringValueReader.ReadString($"StringValue{i}")); } } if (IfHasAssignments(result.Type)) { for (int i = 0; i < result.ElementCount; i++) { var assignmentCount = variableReader.ReadUInt32($"AssignmentCount{i}"); var assignments = new List <DebugEffectAssignment>(); result.Assignments.Add(assignments); for (int j = 0; j < assignmentCount; j++) { variableReader.AddIndent($"Assignment {i}"); assignments.Add(DebugEffectAssignment.Parse(reader, variableReader)); variableReader.RemoveIndent(); } } } if (result.Type.ObjectType == EffectObjectType.GeometryShaderWithStream) { for (int i = 0; i < result.ElementCount; i++) { variableReader.AddIndent($"GSSOInitializer {i}"); result.GSSOInitializers.Add(DebugEffectGSSOInitializer.Parse(reader, variableReader)); variableReader.RemoveIndent(); } } else if (IsShader5(result.Type)) { for (int i = 0; i < result.ElementCount; i++) { variableReader.AddIndent($"ShaderData5 {i}"); result.ShaderData5.Add(DebugEffectShaderData5.Parse(reader, variableReader)); variableReader.RemoveIndent(); } } else if (IsShader(result.Type)) { for (int i = 0; i < result.ElementCount; i++) { variableReader.AddIndent($"ShaderData {i}"); result.ShaderData.Add(DebugEffectShaderData.Parse(reader, variableReader)); variableReader.RemoveIndent(); } } result.AnnotationCount = variableReader.ReadUInt32("AnnotationCount"); for (int i = 0; i < result.AnnotationCount; i++) { variableReader.AddIndent($"Annotation {i}"); result.Annotations.Add(DebugEffectAnnotation.Parse(reader, variableReader, version)); variableReader.RemoveIndent(); } return(result); }
public static DebugEffectChunk Parse(DebugBytecodeReader reader, uint size) { var headerReader = reader.CopyAtCurrentPosition("Header", reader); var result = new DebugEffectChunk(); result.Size = size; var header = result.Header = DebugEffectHeader.Parse(headerReader); var bodyOffset = header.Version.MajorVersion < 5 ? 0x4C : 0x60; var footerOffset = (int)(result.Header.FooterOffset + bodyOffset); var bodyReader = reader.CopyAtOffset("Body", reader, (int)bodyOffset); var dummyReader = bodyReader.CopyAtCurrentPosition("DummyReader", bodyReader); dummyReader.ReadUInt32("Zero"); var footerReader = reader.CopyAtOffset("Footer", reader, footerOffset); var version = header.Version; for (int i = 0; i < header.ConstantBuffers; i++) { footerReader.AddIndent($"ConstantBuffer {i}"); result.LocalBuffers.Add(DebugEffectBuffer.Parse(bodyReader, footerReader, version, false)); footerReader.RemoveIndent(); } for (int i = 0; i < header.ObjectCount; i++) { footerReader.AddIndent($"Variable {i}"); result.LocalVariables.Add(DebugEffectObjectVariable.Parse(bodyReader, footerReader, version, false)); footerReader.RemoveIndent(); } for (int i = 0; i < header.SharedConstantBuffers; i++) { footerReader.AddIndent($"SharedConstantBuffer {i}"); result.SharedBuffers.Add(DebugEffectBuffer.Parse(bodyReader, footerReader, version, true)); footerReader.RemoveIndent(); } for (int i = 0; i < header.SharedObjectCount; i++) { footerReader.AddIndent($"SharedVariable {i}"); result.SharedVariables.Add(DebugEffectObjectVariable.Parse(bodyReader, footerReader, version, true)); footerReader.RemoveIndent(); } if (header.Version.MajorVersion >= 5) { for (int i = 0; i < header.InterfaceVariableCount; i++) { footerReader.AddIndent($"Interface {i}"); result.InterfaceVariables.Add(DebugEffectInterfaceVariable.Parse(bodyReader, footerReader, version)); footerReader.RemoveIndent(); } for (int i = 0; i < header.GroupCount; i++) { footerReader.AddIndent($"Group {i}"); result.Groups.Add(DebugEffectGroup.Parse(bodyReader, footerReader, header.Version)); footerReader.RemoveIndent(); } } else { for (int i = 0; i < header.Techniques; i++) { footerReader.AddIndent($"Technique {i}"); result.Techniques.Add(DebugEffectTechnique.Parse(bodyReader, footerReader, header.Version)); footerReader.RemoveIndent(); } } return(result); }