diff --git a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp index 1ad3fe8b2..024f6f319 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp @@ -743,6 +743,20 @@ void DXBCContainer::ReplaceChunk(bytebuf &ByteCode, uint32_t fourcc, const byte return; } } + + uint32_t newOffs = uint32_t(ByteCode.size() + sizeof(uint32_t)); + ByteCode.insert(sizeof(FileHeader) + header->numChunks * sizeof(uint32_t), (byte *)&newOffs, + sizeof(newOffs)); + + for(uint32_t chunkIdx = 0; chunkIdx < header->numChunks; chunkIdx++) + chunkOffsets[chunkIdx] += sizeof(uint32_t); + + ByteCode.append(replacement, size); + + header->numChunks++; + header->fileLength = (uint32_t)ByteCode.size(); + + HashContainer(ByteCode.data(), ByteCode.size()); } const byte *DXBCContainer::FindChunk(const bytebuf &ByteCode, uint32_t fourcc, size_t &size)