From 9795d8fbb026440b377d5d02b2ce677c7c08f0c2 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 30 Sep 2024 11:08:30 +0100 Subject: [PATCH] Handle encoding DXIL bytecode with multiple functions * After each function we need to reset the IDs of any function-local constants since they may be referenced in other functions and need to be given new function-local IDs for reference. --- renderdoc/driver/shaders/dxil/dxil_bytecode.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp index 75c8694bb..b07665053 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp @@ -2687,6 +2687,16 @@ void LLVMOrderAccumulator::processFunction(const Function *f) void LLVMOrderAccumulator::exitFunction() { + // reset IDs for function constants, so that if they're used in a different function they get a new id + for(size_t i = firstFuncConst; i < firstFuncConst + numFuncConsts; i++) + { + if(cast(values[i])) + { + Value *value = (Value *)values[i]; + value->id = Value::UnvisitedID; + } + } + values.resize(functionWaterMark); }