Skip to content

Commit 5bb66f6

Browse files
committed
Don't rely on ReplaceChunk silently doing nothing for missing chunks
1 parent e9430a0 commit 5bb66f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

renderdoc/driver/shaders/dxbc/dxbc_bytecode_editor.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ ProgramEditor::ProgramEditor(const DXBC::DXBCContainer *container, bytebuf &outB
5656
ProgramEditor::~ProgramEditor()
5757
{
5858
rdcarray<uint32_t> encoded = EncodeProgram();
59-
// only one of these fourcc's will be present, so we just try to replace both
60-
DXBC::DXBCContainer::ReplaceChunk(m_OutBlob, MAKE_FOURCC('S', 'H', 'E', 'X'), encoded);
61-
DXBC::DXBCContainer::ReplaceChunk(m_OutBlob, MAKE_FOURCC('S', 'H', 'D', 'R'), encoded);
59+
// only one of these fourcc's will be present
60+
size_t dummy = 0;
61+
if(DXBC::DXBCContainer::FindChunk(m_OutBlob, DXBC::FOURCC_SHEX, dummy))
62+
DXBC::DXBCContainer::ReplaceChunk(m_OutBlob, MAKE_FOURCC('S', 'H', 'E', 'X'), encoded);
63+
if(DXBC::DXBCContainer::FindChunk(m_OutBlob, DXBC::FOURCC_SHDR, dummy))
64+
DXBC::DXBCContainer::ReplaceChunk(m_OutBlob, MAKE_FOURCC('S', 'H', 'D', 'R'), encoded);
6265
}
6366

6467
/*

0 commit comments

Comments
 (0)