summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-04-07 11:11:51 +1000
committerDave Airlie <airlied@redhat.com>2020-07-27 13:11:58 +1000
commit0143189afae152346250a099339924bb8e52598f (patch)
treefa556f2600fbb52873beafce5bfa57416a88bc71
parentdde857cd6ca8ca6851189b8aa23da9bc49d366b7 (diff)
gallivm/nir: fixup compact TCS variable storage.
This fixes tess factors with gl spirv
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c11
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c31
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h1
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c1
-rw-r--r--src/gallium/auxiliary/nir/nir_to_tgsi_info.c2
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp1
6 files changed, 37 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 845ed6242b1..e5c2d3f92ee 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/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
index b9af10f2ca1..7e6ca276b3b 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
@@ -585,6 +585,8 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
}
unsigned attrib_count = glsl_count_attribute_slots(type, false);
+ if (variable->data.compact)
+ attrib_count = DIV_ROUND_UP(glsl_get_length(type), 4);
for (unsigned k = 0; k < attrib_count; k++, i++) {
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
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)