From: Pavel Asyutchenko Date: Thu, 2 Sep 2021 18:11:04 +0000 (+0300) Subject: llvmpipe: fix crash when doing FB fetch + gl_FragDepth write in one shader X-Git-Tag: upstream/22.3.5~17006 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ffb1522767d4f502141273a89bba125f5a451ea;p=platform%2Fupstream%2Fmesa.git llvmpipe: fix crash when doing FB fetch + gl_FragDepth write in one shader Reproducible by piglit test from this MR: https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/576 Signed-off-by: Pavel Asyutchenko Reviewed-by: Dave Airlie Cc: mesa-stable Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 9b72a9e..b771b7c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -473,7 +473,7 @@ static void emit_load_var(struct lp_build_nir_context *bld_base, break; case nir_var_shader_out: if (bld->fs_iface && bld->fs_iface->fb_fetch) { - bld->fs_iface->fb_fetch(bld->fs_iface, &bld_base->base, var->data.driver_location, result); + bld->fs_iface->fb_fetch(bld->fs_iface, &bld_base->base, var->data.location, result); return; } for (unsigned i = 0; i < num_components; i++) { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index d2053c3..b3b7baa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -258,7 +258,7 @@ struct lp_build_fs_iface { void (*fb_fetch)(const struct lp_build_fs_iface *iface, struct lp_build_context *bld, - unsigned cbuf, + int location, LLVMValueRef result[4]); }; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 197c60f..c77f0f3 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -452,10 +452,13 @@ static LLVMValueRef fs_interp(const struct lp_build_fs_iface *iface, } static void fs_fb_fetch(const struct lp_build_fs_iface *iface, - struct lp_build_context *bld, - unsigned cbuf, - LLVMValueRef result[4]) + struct lp_build_context *bld, + int location, + LLVMValueRef result[4]) { + assert(location >= FRAG_RESULT_DATA0 && location <= FRAG_RESULT_DATA7); + const int cbuf = location - FRAG_RESULT_DATA0; + struct lp_build_fs_llvm_iface *fs_iface = (struct lp_build_fs_llvm_iface *)iface; struct gallivm_state *gallivm = bld->gallivm; LLVMBuilderRef builder = gallivm->builder;