Mesa (master): gallivm/nir: fixup compact TCS variable storage.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 19 01:23:15 UTC 2020
Module: Mesa
Branch: master
Commit: e616223024d05c86df104368b558ffa612fdec7c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e616223024d05c86df104368b558ffa612fdec7c
Author: Dave Airlie <airlied at redhat.com>
Date: Tue Apr 7 11:11:51 2020 +1000
gallivm/nir: fixup compact TCS variable storage.
This fixes a lot of tessellation shaders, since tess factors
get emitted with spir-v now.
Fixes a bunch of:
dEQP-VK.tessellation*
along with 7000 others.
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6339>
---
src/gallium/auxiliary/draw/draw_llvm.c | 11 +++++++--
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 31 ++++++++++++++++++-------
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 1 +
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 1 +
src/gallium/drivers/swr/swr_shader.cpp | 1 +
5 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 22644aa5eab..aabece0ce13 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -3189,6 +3189,7 @@ draw_tcs_llvm_emit_store_output(const struct lp_build_tcs_iface *tes_iface,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index,
LLVMValueRef value,
LLVMValueRef mask_vec)
@@ -3200,13 +3201,14 @@ draw_tcs_llvm_emit_store_output(const struct lp_build_tcs_iface *tes_iface,
LLVMValueRef res;
struct lp_type type = bld->type;
- if (is_vindex_indirect || is_aindex_indirect) {
+ if (is_vindex_indirect || is_aindex_indirect || is_sindex_indirect) {
int i;
for (i = 0; i < type.length; ++i) {
LLVMValueRef idx = lp_build_const_int32(gallivm, i);
LLVMValueRef vert_chan_index = vertex_index ? vertex_index : lp_build_const_int32(gallivm, 0);
LLVMValueRef attr_chan_index = attrib_index;
+ LLVMValueRef swiz_chan_index = swizzle_index;
LLVMValueRef channel_vec;
if (is_vindex_indirect) {
@@ -3218,9 +3220,14 @@ draw_tcs_llvm_emit_store_output(const struct lp_build_tcs_iface *tes_iface,
attrib_index, idx, "");
}
+ if (is_sindex_indirect) {
+ swiz_chan_index = LLVMBuildExtractElement(builder,
+ swizzle_index, idx, "");
+ }
+
indices[0] = vert_chan_index;
indices[1] = attr_chan_index;
- indices[2] = swizzle_index;
+ indices[2] = swiz_chan_index;
channel_vec = LLVMBuildGEP(builder, tcs->output, indices, 3, "");
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index b07e556ecc9..ad6df764f6f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
@@ -487,6 +487,7 @@ static void emit_store_chan(struct lp_build_nir_context *bld_base,
}
static void emit_store_tcs_chan(struct lp_build_nir_context *bld_base,
+ bool is_compact,
unsigned bit_size,
unsigned location,
unsigned const_index,
@@ -512,9 +513,13 @@ static void emit_store_tcs_chan(struct lp_build_nir_context *bld_base,
LLVMValueRef attrib_index_val;
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, swizzle);
- if (indir_index)
- attrib_index_val = lp_build_add(&bld_base->uint_bld, indir_index, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, location));
- else
+ if (indir_index) {
+ if (is_compact) {
+ swizzle_index_val = lp_build_add(&bld_base->uint_bld, indir_index, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, swizzle));
+ attrib_index_val = lp_build_const_int32(gallivm, const_index + location);
+ } else
+ attrib_index_val = lp_build_add(&bld_base->uint_bld, indir_index, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, location));
+ } else
attrib_index_val = lp_build_const_int32(gallivm, const_index + location);
if (bit_size == 64) {
LLVMValueRef split_vals[2];
@@ -524,21 +529,25 @@ static void emit_store_tcs_chan(struct lp_build_nir_context *bld_base,
indir_vertex_index ? true : false,
indir_vertex_index,
indir_index ? true : false,
- attrib_index_val, swizzle_index_val,
+ attrib_index_val,
+ false, swizzle_index_val,
split_vals[0], mask_vec(bld_base));
bld->tcs_iface->emit_store_output(bld->tcs_iface, &bld_base->base, 0,
indir_vertex_index ? true : false,
indir_vertex_index,
indir_index ? true : false,
- attrib_index_val, swizzle_index_val2,
+ attrib_index_val,
+ false, swizzle_index_val2,
split_vals[1], mask_vec(bld_base));
} else {
chan_val = LLVMBuildBitCast(builder, chan_val, bld_base->base.vec_type, "");
bld->tcs_iface->emit_store_output(bld->tcs_iface, &bld_base->base, 0,
indir_vertex_index ? true : false,
indir_vertex_index,
- indir_index ? true : false,
- attrib_index_val, swizzle_index_val,
+ indir_index && !is_compact ? true : false,
+ attrib_index_val,
+ indir_index && is_compact ? true : false,
+ swizzle_index_val,
chan_val, mask_vec(bld_base));
}
}
@@ -567,11 +576,17 @@ static void emit_store_var(struct lp_build_nir_context *bld_base,
comp = 2;
}
+ if (var->data.compact) {
+ location += const_index / 4;
+ comp += const_index % 4;
+ const_index = 0;
+ }
+
for (unsigned chan = 0; chan < num_components; chan++) {
if (writemask & (1u << chan)) {
LLVMValueRef chan_val = (num_components == 1) ? dst : LLVMBuildExtractValue(builder, dst, chan, "");
if (bld->tcs_iface) {
- emit_store_tcs_chan(bld_base, bit_size, location, const_index, indir_vertex_index, indir_index, comp, chan, chan_val);
+ emit_store_tcs_chan(bld_base, var->data.compact, bit_size, location, const_index, indir_vertex_index, indir_index, comp, chan, chan_val);
} else
emit_store_chan(bld_base, deref_mode, bit_size, location + const_index, comp, chan, chan_val);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 856cea40c55..12bf55b3f40 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -459,6 +459,7 @@ struct lp_build_tcs_iface
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index,
LLVMValueRef value,
LLVMValueRef mask_vec);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index f3f339923db..5104a572c4d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1763,6 +1763,7 @@ emit_store_tcs_output(struct lp_build_tgsi_context *bld_base,
vertex_index,
reg->Register.Indirect,
attrib_index,
+ false,
channel_index,
value,
mask_vec(bld_base));
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index cc3bf717653..e5f0074033a 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -611,6 +611,7 @@ void swr_tcs_llvm_store_output(const struct lp_build_tcs_iface *tcs_iface,
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index,
LLVMValueRef value,
LLVMValueRef mask_vec)
More information about the mesa-commit
mailing list