From 71da697812264bc5645d2ff4450bc18beb5a89d4 Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Tue, 23 Oct 2018 04:15:34 -0700 Subject: [PATCH] Fix ExecutionMode's crashing drivers with compute based mesh output. The OpExecutionMode entries were being left in place, but pointing to functions which are no longer entry points. This caused the GPU driver to crash (probably trying to look it up). --- renderdoc/driver/vulkan/vk_postvs.cpp | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 5e7dcddb4..ee5c3e4f2 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -659,6 +659,40 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV for(SPIRVIterator end = editor.EndEntries(); it < end; ++it) editor.Remove(it); + // Strip away any execution modes from the original shaders + for(it = editor.BeginEntries(); it < editor.BeginDebug(); ++it) + { + if(it.opcode() == spv::OpExecutionMode) + { + SPIRVId modeEntryID = SPIRVId(it.word(1)); + + // We only need to be cautious about what we are stripping for the entry + // that we are actually translating, the rest aren't used anyways. + if(modeEntryID == entryID) + { + // Lets check to make sure we don't blindly strip away execution modes that + // might actually have an impact on the behaviour of the shader. + spv::ExecutionMode execMode = spv::ExecutionMode(it.word(2)); + switch(execMode) + { + case spv::ExecutionModeXfb: break; + default: RDCERR("Unexpected execution mode"); + } + } + + editor.PreModify(it); + + SPIRVOperation op(it); + + // invalid to have a nop here, but it will be stripped out later + op.nopRemove(1); + op[0] = SPV_NOP; + + editor.PostModify(it); + } + } + + // Add our compute shader execution mode editor.AddOperation( it, SPIRVOperation(spv::OpExecutionMode, {wrapperEntry, spv::ExecutionModeLocalSize, MeshOutputDispatchWidth, 1, 1}));