From 38d87b9b3be3cf017d5bc543cd97f483da348107 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 15 Feb 2018 16:03:14 +0000 Subject: [PATCH] Don't be surprised by multiple functions in SPIR-V editing * Once we've reached the function bodies we can ignore any more function opcodes. --- renderdoc/driver/shaders/spirv/spirv_editor.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_editor.cpp b/renderdoc/driver/shaders/spirv/spirv_editor.cpp index 344fae1d3..4e5e4c0fd 100644 --- a/renderdoc/driver/shaders/spirv/spirv_editor.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_editor.cpp @@ -230,16 +230,19 @@ SPIRVEditor::SPIRVEditor(std::vector &spirvWords) : spirv(spirvWords) } else if(opcode == spv::OpFunction) { - if(section != SectionState::TypeVar) - RDCERR("Unexpected current section when encountering OpFunction: %d", section); + if(section != SectionState::FunctionBodies) + { + if(section != SectionState::TypeVar) + RDCERR("Unexpected current section when encountering OpFunction: %d", section); - // we've now met the function bodies - section = SectionState::FunctionBodies; + // we've now met the function bodies + section = SectionState::FunctionBodies; - typeVarSection.endOffset = it.offset; + typeVarSection.endOffset = it.offset; - if(typeVarSection.startOffset == typeVarSection.endOffset || typeVarSection.startOffset == 0) - RDCERR("No types found in this shader! There should be at least one for the entry point"); + if(typeVarSection.startOffset == typeVarSection.endOffset || typeVarSection.startOffset == 0) + RDCERR("No types found in this shader! There should be at least one for the entry point"); + } } else {