From 3522f0f24c98a3f9bd04ee74c7dfb9efc4675d51 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Wed, 13 May 2026 17:41:08 +0800 Subject: [PATCH] llvmpipe: stub other functions inside compute shaders for ORCJIT ORCJIT expects every functions prototypes to be present even when using object caches. Code for adding stubs for entry point functions was added previously when implementing shader cache for ORCJIT, but when using OpenCL, extra functions could be present in compute shaders which need stubs too. Reuse the code for constructing references for extra functions to generate function stubs for them. This fixes function calls with Rusticl on llvmpipe with ORCJIT. Fixes: bb0efdd4d896 ("llvmpipe: add shader cache support for ORCJIT implementation") Signed-off-by: Icenowy Zheng Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/llvmpipe/lp_state_cs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index f901b05a4ce..39dc2f73507 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -401,10 +401,16 @@ generate_compute(struct llvmpipe_context *lp, } if (variant->gallivm->cache->data_size) { +#if GALLIVM_USE_ORCJIT gallivm_stub_func(gallivm, function); if (use_coro) gallivm_stub_func(gallivm, coro); + /* Otherwise continue to stub all other functions */ + if (exec_list_length(&nir->functions) <= 1) + return; +#else return; +#endif } context_ptr = LLVMGetParam(function, CS_ARG_CONTEXT); @@ -474,12 +480,28 @@ generate_compute(struct llvmpipe_context *lp, LLVMValueRef lfunc = LLVMAddFunction(gallivm->module, func_name, func_type); LLVMSetFunctionCallConv(lfunc, LLVMCCallConv); +#if GALLIVM_USE_ORCJIT + if (gallivm->cache->data_size) { + gallivm_stub_func(gallivm, lfunc); + continue; + } +#endif + struct lp_build_fn *new_fn = ralloc(fns, struct lp_build_fn); new_fn->fn_type = func_type; new_fn->fn = lfunc; _mesa_hash_table_insert(fns, func, new_fn); } +#if GALLIVM_USE_ORCJIT + if (gallivm->cache->data_size) { + lp_bld_llvm_sampler_soa_destroy(sampler); + lp_bld_llvm_image_soa_destroy(image); + _mesa_hash_table_destroy(fns, NULL); + return; + } +#endif + nir_foreach_function(func, nir) { if (func->is_entrypoint) continue;