コード例 #1
0
        public static DebugEffectShaderData5 Parse(DebugBytecodeReader reader,
                                                   DebugBytecodeReader variableReader)
        {
            var result       = new DebugEffectShaderData5();
            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("InterfaceBindingOffset");
            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("SODecls"));
                }
            }
            var interfaceReader = reader.CopyAtOffset("InterfaceReader", variableReader, (int)interfaceBindingOffset);

            for (int i = 0; i < interfaceBindingCount; i++)
            {
                result.InterfaceBindings.Add(DebugEffectInterfaceInitializer.Parse(reader, interfaceReader));
            }
            return(result);
        }
コード例 #2
0
        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);
        }