if (ir->coordinate != NULL) {
instr->coord_components = ir->coordinate->type->vector_elements;
- instr->src[src_number] = evaluate_rvalue(ir->coordinate);
- instr->src_type[src_number] = nir_tex_src_coord;
+ instr->src[src_number].src = evaluate_rvalue(ir->coordinate);
+ instr->src[src_number].src_type = nir_tex_src_coord;
src_number++;
}
if (ir->projector != NULL) {
- instr->src[src_number] = evaluate_rvalue(ir->projector);
- instr->src_type[src_number] = nir_tex_src_projector;
+ instr->src[src_number].src = evaluate_rvalue(ir->projector);
+ instr->src[src_number].src_type = nir_tex_src_projector;
src_number++;
}
if (ir->shadow_comparitor != NULL) {
- instr->src[src_number] = evaluate_rvalue(ir->shadow_comparitor);
- instr->src_type[src_number] = nir_tex_src_comparitor;
+ instr->src[src_number].src = evaluate_rvalue(ir->shadow_comparitor);
+ instr->src[src_number].src_type = nir_tex_src_comparitor;
src_number++;
}
for (unsigned i = 0; i < const_offset->type->vector_elements; i++)
instr->const_offset[i] = const_offset->value.i[i];
} else {
- instr->src[src_number] = evaluate_rvalue(ir->offset);
- instr->src_type[src_number] = nir_tex_src_offset;
+ instr->src[src_number].src = evaluate_rvalue(ir->offset);
+ instr->src[src_number].src_type = nir_tex_src_offset;
src_number++;
}
}
switch (ir->op) {
case ir_txb:
- instr->src[src_number] = evaluate_rvalue(ir->lod_info.bias);
- instr->src_type[src_number] = nir_tex_src_bias;
+ instr->src[src_number].src = evaluate_rvalue(ir->lod_info.bias);
+ instr->src[src_number].src_type = nir_tex_src_bias;
src_number++;
break;
case ir_txf:
case ir_txs:
if (ir->lod_info.lod != NULL) {
- instr->src[src_number] = evaluate_rvalue(ir->lod_info.lod);
- instr->src_type[src_number] = nir_tex_src_lod;
+ instr->src[src_number].src = evaluate_rvalue(ir->lod_info.lod);
+ instr->src[src_number].src_type = nir_tex_src_lod;
src_number++;
}
break;
case ir_txd:
- instr->src[src_number] = evaluate_rvalue(ir->lod_info.grad.dPdx);
- instr->src_type[src_number] = nir_tex_src_ddx;
+ instr->src[src_number].src = evaluate_rvalue(ir->lod_info.grad.dPdx);
+ instr->src[src_number].src_type = nir_tex_src_ddx;
src_number++;
- instr->src[src_number] = evaluate_rvalue(ir->lod_info.grad.dPdy);
- instr->src_type[src_number] = nir_tex_src_ddy;
+ instr->src[src_number].src = evaluate_rvalue(ir->lod_info.grad.dPdy);
+ instr->src[src_number].src_type = nir_tex_src_ddy;
src_number++;
break;
case ir_txf_ms:
- instr->src[src_number] = evaluate_rvalue(ir->lod_info.sample_index);
- instr->src_type[src_number] = nir_tex_src_ms_index;
+ instr->src[src_number].src = evaluate_rvalue(ir->lod_info.sample_index);
+ instr->src[src_number].src_type = nir_tex_src_ms_index;
src_number++;
break;
dest_init(&instr->dest);
instr->num_srcs = num_srcs;
- for (unsigned i = 0; i < 4; i++)
- src_init(&instr->src[i]);
+ instr->src = ralloc_array(mem_ctx, nir_tex_src, num_srcs);
+ for (unsigned i = 0; i < num_srcs; i++)
+ src_init(&instr->src[i].src);
instr->sampler_index = 0;
instr->sampler_array_size = 0;
nir_tex_src_ddx,
nir_tex_src_ddy,
nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */
- nir_num_texinput_types
-} nir_texinput_type;
+ nir_num_tex_src_types
+} nir_tex_src_type;
+
+typedef struct {
+ nir_src src;
+ nir_tex_src_type src_type;
+} nir_tex_src;
typedef enum {
nir_texop_tex, /**< Regular texture look-up */
nir_texop op;
nir_dest dest;
- nir_src src[4];
- nir_texinput_type src_type[4];
+ nir_tex_src *src;
unsigned num_srcs, coord_components;
bool is_array, is_shadow;
static inline unsigned
nir_tex_instr_src_size(nir_tex_instr *instr, unsigned src)
{
- if (instr->src_type[src] == nir_tex_src_coord)
+ if (instr->src[src].src_type == nir_tex_src_coord)
return instr->coord_components;
- if (instr->src_type[src] == nir_tex_src_offset ||
- instr->src_type[src] == nir_tex_src_ddx ||
- instr->src_type[src] == nir_tex_src_ddy) {
+ if (instr->src[src].src_type == nir_tex_src_offset ||
+ instr->src[src].src_type == nir_tex_src_ddx ||
+ instr->src[src].src_type == nir_tex_src_ddy) {
if (instr->is_array)
return instr->coord_components - 1;
else
}
static inline int
-nir_tex_instr_src_index(nir_tex_instr *instr, nir_texinput_type type)
+nir_tex_instr_src_index(nir_tex_instr *instr, nir_tex_src_type type)
{
for (unsigned i = 0; i < instr->num_srcs; i++)
- if (instr->src_type[i] == type)
+ if (instr->src[i].src_type == type)
return (int) i;
return -1;
case nir_deref_array_type_indirect: {
assert(!has_indirect);
- assert(instr->num_srcs < 4);
+ instr->src = reralloc(mem_ctx, instr->src, nir_tex_src,
+ instr->num_srcs + 1);
+ memset(&instr->src[instr->num_srcs], 0, sizeof *instr->src);
+ instr->src[instr->num_srcs].src_type = nir_tex_src_sampler_offset;
+ instr->num_srcs++;
- nir_instr_rewrite_src(&instr->instr, &instr->src[instr->num_srcs],
+ nir_instr_rewrite_src(&instr->instr,
+ &instr->src[instr->num_srcs - 1].src,
nir_src_copy(deref_array->indirect, mem_ctx));
- instr->src_type[instr->num_srcs] = nir_tex_src_sampler_offset;
- instr->num_srcs++;
instr->sampler_array_size = glsl_get_length(deref->type);
}
for (unsigned i = 0; i < instr->num_srcs; i++) {
- print_src(&instr->src[i], fp);
+ print_src(&instr->src[i].src, fp);
fprintf(fp, " ");
- switch(instr->src_type[i]) {
+ switch(instr->src[i].src_type) {
case nir_tex_src_coord:
fprintf(fp, "(coord)");
break;
{
validate_dest(&instr->dest, state);
- bool src_type_seen[nir_num_texinput_types];
- for (unsigned i = 0; i < nir_num_texinput_types; i++)
+ bool src_type_seen[nir_num_tex_src_types];
+ for (unsigned i = 0; i < nir_num_tex_src_types; i++)
src_type_seen[i] = false;
for (unsigned i = 0; i < instr->num_srcs; i++) {
- assert(!src_type_seen[instr->src_type[i]]);
- src_type_seen[instr->src_type[i]] = true;
+ assert(!src_type_seen[instr->src[i].src_type]);
+ src_type_seen[instr->src[i].src_type] = true;
validate_src(&instr->src[i], state);
}
fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, offset;
for (unsigned i = 0; i < instr->num_srcs; i++) {
- fs_reg src = get_nir_src(instr->src[i]);
- switch (instr->src_type[i]) {
+ fs_reg src = get_nir_src(instr->src[i].src);
+ switch (instr->src[i].src_type) {
case nir_tex_src_bias:
lod = retype(src, BRW_REGISTER_TYPE_F);
break;