diff options
Diffstat (limited to 'src/glsl/nir')
-rw-r--r-- | src/glsl/nir/glsl_to_nir.cpp | 36 | ||||
-rw-r--r-- | src/glsl/nir/nir.c | 5 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 24 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_samplers.cpp | 11 | ||||
-rw-r--r-- | src/glsl/nir/nir_print.c | 4 | ||||
-rw-r--r-- | src/glsl/nir/nir_validate.c | 8 |
6 files changed, 48 insertions, 40 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 372f219f4f4..6ac830e44d9 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -1662,20 +1662,20 @@ nir_visitor::visit(ir_texture *ir) 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++; } @@ -1688,16 +1688,16 @@ nir_visitor::visit(ir_texture *ir) 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; @@ -1705,24 +1705,24 @@ nir_visitor::visit(ir_texture *ir) 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; diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index ad86a6ea945..da9b7a1d3b6 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -447,8 +447,9 @@ nir_tex_instr_create(void *mem_ctx, unsigned num_srcs) 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; diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 1daf53fa44c..e797ce24978 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -822,8 +822,13 @@ typedef enum { 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 */ @@ -846,8 +851,7 @@ typedef struct { 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; @@ -917,13 +921,13 @@ nir_tex_instr_dest_size(nir_tex_instr *instr) 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 @@ -934,10 +938,10 @@ nir_tex_instr_src_size(nir_tex_instr *instr, unsigned src) } 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; diff --git a/src/glsl/nir/nir_lower_samplers.cpp b/src/glsl/nir/nir_lower_samplers.cpp index 5e90a4ce82e..99f31fc0281 100644 --- a/src/glsl/nir/nir_lower_samplers.cpp +++ b/src/glsl/nir/nir_lower_samplers.cpp @@ -94,12 +94,15 @@ lower_sampler(nir_tex_instr *instr, struct gl_shader_program *shader_program, 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); diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 7cf2e0b2508..fe5ceeaf035 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -402,11 +402,11 @@ print_tex_instr(nir_tex_instr *instr, print_var_state *state, FILE *fp) } 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; diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index d2ce021196e..0d267baa21f 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -381,13 +381,13 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) { 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); } |