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@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6339>
This commit is contained in:
Dave Airlie
2020-04-07 11:11:51 +10:00
parent 597d0e9b5f
commit e616223024
5 changed files with 35 additions and 10 deletions

View File

@@ -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, "");

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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));

View File

@@ -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)