Beispiel #1
0
        public static DebugEffectHeader Parse(DebugBytecodeReader chunkReader)
        {
            var result = new DebugEffectHeader();

            result.Version                = DebugShaderVersion.ParseFX(chunkReader);
            result.ConstantBuffers        = chunkReader.ReadUInt32("ConstantBuffers");
            result.GlobalVariables        = chunkReader.ReadUInt32("GlobalVariables");
            result.ObjectCount            = chunkReader.ReadUInt32("ObjectCount");
            result.SharedConstantBuffers  = chunkReader.ReadUInt32("SharedConstantBuffers");
            result.SharedGlobalVariables  = chunkReader.ReadUInt32("SharedGlobalVariables");
            result.SharedObjectCount      = chunkReader.ReadUInt32("SharedObjectCount");
            result.Techniques             = chunkReader.ReadUInt32("Techniques");
            result.FooterOffset           = chunkReader.ReadUInt32("FooterOffset");
            result.StringCount            = chunkReader.ReadUInt32("StringCount");
            result.LocalTextureCount      = chunkReader.ReadUInt32("LocalTextureCount");
            result.DepthStencilStateCount = chunkReader.ReadUInt32("DepthStencilStateCount");
            result.BlendStateCount        = chunkReader.ReadUInt32("BlendStateCount");
            result.RasterizerStateCount   = chunkReader.ReadUInt32("RasterizerStateCount");
            result.LocalSamplerCount      = chunkReader.ReadUInt32("LocalSamplerCount");
            result.RenderTargetViewCount  = chunkReader.ReadUInt32("RenderTargetViewCount");
            result.DepthStencilViewCount  = chunkReader.ReadUInt32("DepthStencilViewCount");
            result.ShaderCount            = chunkReader.ReadUInt32("ShaderCount");
            result.InlineShaderCount      = chunkReader.ReadUInt32("InlineShaderCount");
            if (result.Version.MajorVersion >= 5)
            {
                result.GroupCount                    = chunkReader.ReadUInt32("GroupCount");
                result.UAVCount                      = chunkReader.ReadUInt32("UAVCount");
                result.InterfaceVariableCount        = chunkReader.ReadUInt32("InterfaceVariableCount");
                result.InterfaceVariableElementCount = chunkReader.ReadUInt32("InterfaceVariableElementCount");
                result.ClassInstanceElementCount     = chunkReader.ReadUInt32("ClassInstanceElementCount");
            }
            return(result);
        }
Beispiel #2
0
        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);
        }