LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index)
{
const struct draw_tcs_llvm_iface *tcs = draw_tcs_llvm_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;
res = bld->zero;
LLVMValueRef idx = lp_build_const_int32(gallivm, i);
LLVMValueRef vert_chan_index = vertex_index;
LLVMValueRef attr_chan_index = attrib_index;
+ LLVMValueRef swiz_chan_index = swizzle_index;
LLVMValueRef channel_vec;
if (is_vindex_indirect) {
attr_chan_index = LLVMBuildExtractElement(builder,
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->input, indices, 3, "");
channel_vec = LLVMBuildLoad(builder, channel_vec, "");
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index,
uint32_t name)
{
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;
res = bld->zero;
LLVMValueRef idx = lp_build_const_int32(gallivm, i);
LLVMValueRef vert_chan_index = vertex_index;
LLVMValueRef attr_chan_index = attrib_index;
+ LLVMValueRef swiz_chan_index = swizzle_index;
LLVMValueRef channel_vec;
if (is_vindex_indirect) {
attr_chan_index = LLVMBuildExtractElement(builder,
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, "");
channel_vec = LLVMBuildLoad(builder, channel_vec, "");
LLVMValueRef vertex_index,
boolean is_aindex_indirect,
LLVMValueRef attrib_index,
+ boolean is_sindex_indirect,
LLVMValueRef swizzle_index)
{
const struct draw_tes_llvm_iface *tes = draw_tes_llvm_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;
res = bld->zero;
LLVMValueRef idx = lp_build_const_int32(gallivm, i);
LLVMValueRef vert_chan_index = vertex_index;
LLVMValueRef attr_chan_index = attrib_index;
+ LLVMValueRef swiz_chan_index = swizzle_index;
LLVMValueRef channel_vec;
if (is_vindex_indirect) {
attr_chan_index = LLVMBuildExtractElement(builder,
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, tes->input, indices, 3, "");
channel_vec = LLVMBuildLoad(builder, channel_vec, "");
struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base;
struct gallivm_state *gallivm = bld_base->base.gallivm;
int dmul = bit_size == 64 ? 2 : 1;
+ unsigned location = var->data.driver_location;
+ unsigned location_frac = var->data.location_frac;
+
+ if (!var->data.compact && !indir_index)
+ location += const_index;
+ else if (var->data.compact) {
+ location += const_index / 4;
+ location_frac += const_index % 4;
+ const_index = 0;
+ }
switch (deref_mode) {
case nir_var_shader_in:
for (unsigned i = 0; i < num_components; i++) {
- int idx = (i * dmul) + var->data.location_frac;
+ int idx = (i * dmul) + location_frac;
+
if (bld->gs_iface) {
LLVMValueRef vertex_index_val = lp_build_const_int32(gallivm, vertex_index);
- LLVMValueRef attrib_index_val = lp_build_const_int32(gallivm, const_index + var->data.driver_location);
+ LLVMValueRef attrib_index_val = lp_build_const_int32(gallivm, location);
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx);
LLVMValueRef result2;
+
result[i] = bld->gs_iface->fetch_input(bld->gs_iface, &bld_base->base,
false, vertex_index_val, 0, attrib_index_val, swizzle_index_val);
if (bit_size == 64) {
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx);
LLVMValueRef result2;
- 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, var->data.driver_location));
- else
- attrib_index_val = lp_build_const_int32(gallivm, const_index + var->data.driver_location);
+ if (indir_index) {
+ if (var->data.compact) {
+ swizzle_index_val = lp_build_add(&bld_base->uint_bld, indir_index, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, idx));
+ attrib_index_val = lp_build_const_int32(gallivm, 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, var->data.driver_location));
+ } else
+ attrib_index_val = lp_build_const_int32(gallivm, location);
+
if (var->data.patch) {
result[i] = bld->tes_iface->fetch_patch_input(bld->tes_iface, &bld_base->base,
indir_index ? true : false, attrib_index_val, swizzle_index_val);
result[i] = bld->tes_iface->fetch_vertex_input(bld->tes_iface, &bld_base->base,
indir_vertex_index ? true : false,
indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val);
+ (indir_index && !var->data.compact) ? true : false, attrib_index_val,
+ (indir_index && var->data.compact) ? true : false, swizzle_index_val);
if (bit_size == 64) {
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx + 1);
result2 = bld->tes_iface->fetch_vertex_input(bld->tes_iface, &bld_base->base,
indir_vertex_index ? true : false,
indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val);
+ indir_index ? true : false, attrib_index_val, false, swizzle_index_val);
result[i] = emit_fetch_64bit(bld_base, result[i], result2);
}
}
LLVMValueRef attrib_index_val;
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx);
- 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, var->data.driver_location));
- else
- attrib_index_val = lp_build_const_int32(gallivm, const_index + var->data.driver_location);
+ if (indir_index) {
+ if (var->data.compact) {
+ swizzle_index_val = lp_build_add(&bld_base->uint_bld, indir_index, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, idx));
+ attrib_index_val = lp_build_const_int32(gallivm, 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, var->data.driver_location));
+ } else
+ attrib_index_val = lp_build_const_int32(gallivm, location);
result[i] = bld->tcs_iface->emit_fetch_input(bld->tcs_iface, &bld_base->base,
indir_vertex_index ? true : false, indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val);
+ (indir_index && !var->data.compact) ? true : false, attrib_index_val,
+ (indir_index && var->data.compact) ? true : false, swizzle_index_val);
if (bit_size == 64) {
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx + 1);
LLVMValueRef result2 = bld->tcs_iface->emit_fetch_input(bld->tcs_iface, &bld_base->base,
indir_vertex_index ? true : false, indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val);
+ indir_index ? true : false, attrib_index_val,
+ false, swizzle_index_val);
result[i] = emit_fetch_64bit(bld_base, result[i], result2);
}
} else {
} else {
if (bld->indirects & nir_var_shader_in) {
LLVMValueRef lindex = lp_build_const_int32(gallivm,
- var->data.driver_location * 4 + idx);
+ location * 4 + idx);
LLVMValueRef input_ptr = lp_build_pointer_get(gallivm->builder,
bld->inputs_array, lindex);
if (bit_size == 64) {
LLVMValueRef lindex2 = lp_build_const_int32(gallivm,
- var->data.driver_location * 4 + (idx + 1));
+ location * 4 + (idx + 1));
LLVMValueRef input_ptr2 = lp_build_pointer_get(gallivm->builder,
bld->inputs_array, lindex2);
result[i] = emit_fetch_64bit(bld_base, input_ptr, input_ptr2);
} else {
if (bit_size == 64) {
LLVMValueRef tmp[2];
- tmp[0] = bld->inputs[var->data.driver_location + const_index][idx];
- tmp[1] = bld->inputs[var->data.driver_location + const_index][idx + 1];
+ tmp[0] = bld->inputs[location][idx];
+ tmp[1] = bld->inputs[location][idx + 1];
result[i] = emit_fetch_64bit(bld_base, tmp[0], tmp[1]);
} else {
- result[i] = bld->inputs[var->data.driver_location + const_index][idx];
+ result[i] = bld->inputs[location][idx];
}
}
}
return;
}
for (unsigned i = 0; i < num_components; i++) {
- int idx = (i * dmul) + var->data.location_frac;
+ int idx = (i * dmul) + location_frac;
if (bld->tcs_iface) {
LLVMValueRef vertex_index_val = lp_build_const_int32(gallivm, vertex_index);
LLVMValueRef attrib_index_val;
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, var->data.driver_location));
else
- attrib_index_val = lp_build_const_int32(gallivm, const_index + var->data.driver_location);
+ attrib_index_val = lp_build_const_int32(gallivm, location);
result[i] = bld->tcs_iface->emit_fetch_output(bld->tcs_iface, &bld_base->base,
- indir_vertex_index ? true : false, indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val, 0);
+ indir_vertex_index ? true : false, indir_vertex_index ? indir_vertex_index : vertex_index_val,
+ (indir_index && !var->data.compact) ? true : false, attrib_index_val,
+ (indir_index && var->data.compact) ? true : false, swizzle_index_val, 0);
if (bit_size == 64) {
LLVMValueRef swizzle_index_val = lp_build_const_int32(gallivm, idx + 1);
LLVMValueRef result2 = bld->tcs_iface->emit_fetch_output(bld->tcs_iface, &bld_base->base,
indir_vertex_index ? true : false, indir_vertex_index ? indir_vertex_index : vertex_index_val,
- indir_index ? true : false, attrib_index_val, swizzle_index_val, 0);
+ indir_index ? true : false, attrib_index_val,
+ false, swizzle_index_val, 0);
result[i] = emit_fetch_64bit(bld_base, result[i], result2);
}
}