From 5c49a7c6b532bc15630c2ef4ce97fc4bfb1536d7 Mon Sep 17 00:00:00 2001 From: Pascal Lecocq Date: Sat, 20 May 2023 11:25:03 -0700 Subject: [PATCH] fix(optix): fix userdata derivatives for interpolated params on GPU (#1685) Following #1657, it turns out we forgot to zero initialize the userdata derivatives for the optix path. This leads to some rendering glitches caused by the memory garbage left in those derivatives. Signed-off-by: Pascal Lecocq Co-authored-by: Pascal Lecocq --- src/liboslexec/llvm_instance.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/liboslexec/llvm_instance.cpp b/src/liboslexec/llvm_instance.cpp index 468338a8f..1b31494ae 100644 --- a/src/liboslexec/llvm_instance.cpp +++ b/src/liboslexec/llvm_instance.cpp @@ -563,6 +563,8 @@ BackendLLVM::llvm_assign_initial_value(const Symbol& sym, bool force) llvm::Value* dst = llvm_void_ptr(sym); TypeDesc t = sym.typespec().simpletype(); ll.op_memcpy(dst, src, t.size(), t.basesize()); + if (sym.has_derivs()) + llvm_zero_derivs(sym); #endif } else if (!sym.lockgeom() && !sym.typespec().is_closure()) { // geometrically-varying param; memcpy its default value