Mesa (main): llvmpipe: fix crash when doing FB fetch + gl_FragDepth write in one shader
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Oct 5 21:12:08 UTC 2021
Module: Mesa
Branch: main
Commit: 7ffb1522767d4f502141273a89bba125f5a451ea
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ffb1522767d4f502141273a89bba125f5a451ea
Author: Pavel Asyutchenko <sventeam at yandex.ru>
Date: Thu Sep 2 21:11:04 2021 +0300
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 <sventeam at yandex.ru>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12705>
---
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 2 +-
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 +-
src/gallium/drivers/llvmpipe/lp_state_fs.c | 9 ++++++---
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index 9b72a9e1c01..b771b7cc748 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 d2053c32b12..b3b7baa2290 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 197c60f7e04..c77f0f38df8 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;
More information about the mesa-commit
mailing list