Beispiel #1
0
        public virtual void Load(ChunkMeta meta, BinaryReader br)
        {
            chunkMeta = meta;
            var ms = br.BaseStream;

            ms.Position = meta.offset + meta.headerLength;
        }
Beispiel #2
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            parentId = br.ReadUInt64();           // pResource
            name     = Utils.ReadChunkString(br); // Name
        }
Beispiel #3
0
        public void ProcessChunks()
        {
            // 当前仅处理 Font Texture chunk
            if (props.type != SectionType.FrameCapture)
            {
                return;
            }

            chunkMetas = new List <ChunkMeta>();

            using (MemoryStream ms = new MemoryStream(uncompressedData))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    int index           = 1; // RenderDoc的chunk从1开始计数
                    int eventBeginIndex = 0;
                    while (ms.Position < uncompressedData.Length)
                    {
                        int eventId = 0;
                        if (eventBeginIndex != 0)
                        {
                            eventId = index - eventBeginIndex;
                        }

                        var chunkMeta = new ChunkMeta(index, eventId);
                        chunkMeta.LoadFromStream(br);
                        index++;

                        if (chunkMeta.chunkID == (int)SystemChunk.CaptureBegin)
                        {
                            eventBeginIndex        = chunkMeta.index;
                            CaptureBeginChunkIndex = index - 1;
                        }

                        chunkMetas.Add(chunkMeta);
                    }
                }

            chunkManager = new ChunkManager();
            chunkManager.LoadChunksFromSection(this);

            //// 通过关键字查找chunk offset
            //int fontNameOffset = uncompressedData.IndexOf(fontTextureMagicData);
            //if (fontNameOffset == -1)
            //{
            //    Console.WriteLine("can not find [Font Texture] chunk");
            //    return;
            //}

            //using (MemoryStream ms = new MemoryStream(uncompressedData))
            //using (BinaryReader br = new BinaryReader(ms))
            //{
            //    int SetResourceNameOffset = fontNameOffset + fontTextureMagicData.Length;
            //    SetResourceNameOffset = (SetResourceNameOffset + 63) & (~63);

            //    ms.Position = SetResourceNameOffset;

            //    fontTextureChunk = new ChunkMeta();
            //    fontTextureChunk.LoadFromStream(br);
            //}
        }
Beispiel #4
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            parentId = br.ReadUInt64(); // pIndexBuffer
            Format   = (DXGI_FORMAT)br.ReadInt32();
            Offset   = br.ReadUInt32();
        }
Beispiel #5
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            parentId   = br.ReadUInt64(); // pResource
            pDesc      = D3D11Reader.Read_D3D11_Nullable <D3D11_DEPTH_STENCIL_VIEW_DESC>(br);
            resourceId = br.ReadUInt64(); // pView
        }
Beispiel #6
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            uint Buffer = br.ReadUInt32();

            resourceId           = br.ReadUInt64(); // SwapbufferID
            BackbufferDescriptor = D3D11Reader.Read_D3D11_TEXTURE2D_DESC(br) as D3D11_TEXTURE2D_DESC;

            name = "Serialised Swap Chain Buffer"; // fakeBB
        }
Beispiel #7
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            StartSlot       = br.ReadUInt32();
            NumBuffers      = br.ReadUInt32();
            ppVertexBuffers = D3D11Reader.Read_Primitive_Array <ulong>(br);
            pStrides        = D3D11Reader.Read_Primitive_Array <uint>(br);
            pOffsets        = D3D11Reader.Read_Primitive_Array <uint>(br);

            if (NumBuffers > 0)
            {
                parentId = ppVertexBuffers[0]; // 没办法,只显示第一个吧
            }
        }
Beispiel #8
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);
            Descriptor = D3D11Reader.Read_D3D11_TEXTURE2D_DESC(br) as D3D11_TEXTURE2D_DESC;

            // unused, just for the sake of the user
            {
                uint numSubresources = Descriptor.MipLevels != 0
                                           ? Descriptor.MipLevels
                                           : Common.CalcNumMips(Descriptor.Width, Descriptor.Height, 1);
                numSubresources *= Descriptor.ArraySize;

                pInitialDatas = D3D11Reader.Read_D3D11_Array <D3D11_SUBRESOURCE_DATA>(br); // 初始化第一步
                resourceId    = br.ReadUInt64();

                if (pInitialDatas != null)
                {
                    D3D11Reader.Read_CreateTextureData(br, pInitialDatas, Descriptor.Width, Descriptor.Height, 1, Descriptor.Format,
                                                       Descriptor.MipLevels, Descriptor.ArraySize, pInitialDatas != null); // 初始化第二步
                }
            }
        }
Beispiel #9
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            Descriptor   = D3D11Reader.Read_D3D11_BUFFER_DESC(br) as D3D11_BUFFER_DESC;  // Descriptor
            pInitialData = D3D11Reader.Read_D3D11_Nullable <D3D11_SUBRESOURCE_DATA>(br); // pInitialData
            resourceId   = br.ReadUInt64();                                              // pBuffer

            int dataOffset;
            int count;

            D3D11Reader.Read_BytesArray(br, out dataOffset, out count, true);
            ulong InitialDataLength = br.ReadUInt64();

            Debug.Assert((int)InitialDataLength == count);

            data                  = new D3D11_SUBRESOURCE_DATA();
            data.pSysMem          = null;
            data.SysMemPitch      = Descriptor.ByteWidth;
            data.SysMemSlicePitch = Descriptor.ByteWidth;
            data.sysMemDataOffset = dataOffset;
            data.sysMemLength     = count;
        }
Beispiel #10
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            type     = (D3D11ResourceType)br.ReadUInt32();
            parentId = br.ReadUInt64(); // id

            // RenderDoc 可以保证对应的资源已创建
            D3D11_TEXTURE2D_DESC desc;

            var createChunk = chunkManager.GetResourceChunk(parentId);

            if (createChunk == null)
            {
                Console.WriteLine($"unsupported resouce on [Chunk_InitialContents] with id {parentId}");
                return; // 尚未支持的资源类型
            }
            else
            {
                if (createChunk is Chunk_CreateTexture2D)
                {
                    desc = (createChunk as Chunk_CreateTexture2D).Descriptor;
                }
                else if (createChunk is Chunk_CreateSwapBuffer)
                {
                    desc = (createChunk as Chunk_CreateSwapBuffer).BackbufferDescriptor;
                }
                else
                {
                    throw new Exception($"unknown resource type {createChunk.GetType().Name}");
                }
            }

            if (type == D3D11ResourceType.Resource_UnorderedAccessView)
            {
                // TODO
            }
            else if (type == D3D11ResourceType.Resource_Buffer)
            {
                // TODO
            }
            else if (type == D3D11ResourceType.Resource_Texture1D)
            {
                // TODO
            }
            else if (type == D3D11ResourceType.Resource_Texture2D)
            {
                uint NumSubresources = desc.MipLevels * desc.ArraySize;
                bool multisampled    = desc.SampleDesc.Count > 1 || desc.SampleDesc.Quality > 0;

                if (multisampled)
                {
                    NumSubresources *= desc.SampleDesc.Count;
                }

                uint numReaded = br.ReadUInt32();
                Debug.Assert(NumSubresources == numReaded);
                NumSubresources = numReaded;

                bool OmittedContents = br.ReadBoolean(); // for compatibility

                if (OmittedContents)
                {
                    return;
                }

                subDatas = new D3D11_SUBRESOURCE_DATA[NumSubresources];

                for (int i = 0; i < NumSubresources; i++)
                {
                    // 数据格式与 CreteTexture2D 时的SubResource不同,原因不明, 可能是历史遗留问题?
                    uint numRows = Math.Max(1, desc.Height >> i);
                    if (Common.IsBlockFormat(desc.Format))
                    {
                        numRows = Common.AlignUp4(numRows) / 4;
                    }
                    else if (Common.IsYUVPlanarFormat(desc.Format))
                    {
                        numRows = Common.GetYUVNumRows(desc.Format, desc.Height);
                    }

                    subDatas[i]                  = new D3D11_SUBRESOURCE_DATA();
                    subDatas[i].SysMemPitch      = br.ReadUInt32();
                    subDatas[i].SysMemSlicePitch = subDatas[i].SysMemPitch * numRows;
                    subDatas[i].pSysMem          = D3D11Reader.Read_BytesArray(br, out subDatas[i].sysMemDataOffset, out subDatas[i].sysMemLength, true);
                }
            }
        }
Beispiel #11
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            initParams = D3D11Reader.Read_D3D11InitParams(br) as D3D11InitParams;
        }
Beispiel #12
0
        public override void Load(ChunkMeta meta, BinaryReader br)
        {
            base.Load(meta, br);

            m_CurContextId = br.ReadUInt64();
        }
Beispiel #13
0
        private IChunk CreateChunkByMeta(ChunkMeta chunkMeta)
        {
            SystemChunk systemChunk = (SystemChunk)chunkMeta.chunkID;
            D3D11Chunk  d3D11Chunk  = (D3D11Chunk)chunkMeta.chunkID;

            if (chunkMeta.chunkID < (uint)SystemChunk.FirstDriverChunk)
            {
                switch (systemChunk)
                {
                case SystemChunk.DriverInit:
                    return(new Chunk_DriverInit(this));

                case SystemChunk.InitialContents:
                    return(new Chunk_InitialContents(this));

                default:
                    return(new ChunkBase(this));
                }
            }
            else
            {
                switch (d3D11Chunk)
                {
                case D3D11Chunk.CreateTexture2D:
                    return(new Chunk_CreateTexture2D(this));

                case D3D11Chunk.CreateTexture2D1:
                    return(new Chunk_CreateTexture2D1(this));

                case D3D11Chunk.SetResourceName:
                    return(new Chunk_SetResourceName(this));

                case D3D11Chunk.CreateSwapBuffer:
                    return(new Chunk_CreateSwapBuffer(this));

                case D3D11Chunk.CreateRenderTargetView:
                    return(new Chunk_CreateRenderTargetView(this));

                case D3D11Chunk.CreateShaderResourceView:
                    return(new Chunk_CreateShaderResourceView(this));

                case D3D11Chunk.CreateDepthStencilView:
                    return(new Chunk_CreateDepthStencilView(this));

                case D3D11Chunk.UpdateSubresource:
                    return(new Chunk_UpdateSubresource(this));

                case D3D11Chunk.UpdateSubresource1:
                    return(new Chunk_UpdateSubresource1(this));

                case D3D11Chunk.CreateBuffer:
                    return(new Chunk_CreateBuffer(this));

                case D3D11Chunk.IASetVertexBuffers:
                    return(new Chunk_IASetVertexBuffers(this));

                case D3D11Chunk.IASetIndexBuffer:
                    return(new Chunk_IASetIndexBuffer(this));

                default:
                    return(new ChunkBase(this));
                }
            }
        }