diff options
author | Jason Ekstrand <[email protected]> | 2016-02-06 09:05:10 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-02-09 15:00:17 -0800 |
commit | ee85014b90af1d94d637ec763a803479e9bac5dc (patch) | |
tree | 91a7aea9be51e8c18b18f40f237175e9471e0d41 /src/compiler | |
parent | 3f421849945d763b3e477ceb1c726c2dbed3bafd (diff) |
nir/tex_instr: Rename sampler to texture
We're about to separate the two concepts. When we do, the sampler will
become optional. Doing a rename first makes the separation a bit more
safe because drivers that depend on GLSL or TGSI behaviour will be fine to
just use the texture index all the time.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/glsl_to_nir.cpp | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir.c | 10 | ||||
-rw-r--r-- | src/compiler/nir/nir.h | 24 | ||||
-rw-r--r-- | src/compiler/nir/nir_clone.c | 8 | ||||
-rw-r--r-- | src/compiler/nir/nir_instr_set.c | 18 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_samplers.c | 18 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_tex.c | 12 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_constant_folding.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_print.c | 12 | ||||
-rw-r--r-- | src/compiler/nir/nir_remove_dead_variables.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_validate.c | 4 |
11 files changed, 58 insertions, 58 deletions
diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp index 68b7aebbc37..ee1a0cb9348 100644 --- a/src/compiler/nir/glsl_to_nir.cpp +++ b/src/compiler/nir/glsl_to_nir.cpp @@ -1852,7 +1852,7 @@ nir_visitor::visit(ir_texture *ir) unreachable("not reached"); } - instr->sampler = evaluate_deref(&instr->instr, ir->sampler); + instr->texture = evaluate_deref(&instr->instr, ir->sampler); unsigned src_number = 0; diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 7f343ee5e38..6a070f530b2 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -486,9 +486,9 @@ nir_tex_instr_create(nir_shader *shader, unsigned 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; - instr->sampler = NULL; + instr->texture_index = 0; + instr->texture_array_size = 0; + instr->texture = NULL; return instr; } @@ -1007,8 +1007,8 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb cb, void *state) return false; } - if (instr->sampler != NULL) { - if (!visit_deref_src(instr->sampler, cb, state)) + if (instr->texture != NULL) { + if (!visit_deref_src(instr->texture, cb, state)) return false; } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 16203af9cfb..48dda99a949 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -965,7 +965,7 @@ typedef enum { nir_tex_src_ms_index, /* MSAA sample index */ nir_tex_src_ddx, nir_tex_src_ddy, - nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */ + nir_tex_src_texture_offset, /* < dynamically uniform indirect offset */ nir_num_tex_src_types } nir_tex_src_type; @@ -1015,17 +1015,17 @@ typedef struct { /* gather component selector */ unsigned component : 2; - /** The sampler index + /** The texture index * - * If this texture instruction has a nir_tex_src_sampler_offset source, - * then the sampler index is given by sampler_index + sampler_offset. + * If this texture instruction has a nir_tex_src_texture_offset source, + * then the texture index is given by texture_index + texture_offset. */ - unsigned sampler_index; + unsigned texture_index; - /** The size of the sampler array or 0 if it's not an array */ - unsigned sampler_array_size; + /** The size of the texture array or 0 if it's not an array */ + unsigned texture_array_size; - nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */ + nir_deref_var *texture; /* if this is NULL, use texture_index instead */ } nir_tex_instr; static inline unsigned @@ -2091,15 +2091,15 @@ typedef struct nir_lower_tex_options { unsigned saturate_t; unsigned saturate_r; - /* Bitmask of samplers that need swizzling. + /* Bitmask of textures that need swizzling. * - * If (swizzle_result & (1 << sampler_index)), then the swizzle in - * swizzles[sampler_index] is applied to the result of the texturing + * If (swizzle_result & (1 << texture_index)), then the swizzle in + * swizzles[texture_index] is applied to the result of the texturing * operation. */ unsigned swizzle_result; - /* A swizzle for each sampler. Values 0-3 represent x, y, z, or w swizzles + /* A swizzle for each texture. Values 0-3 represent x, y, z, or w swizzles * while 4 and 5 represent 0 and 1 respectively. */ uint8_t swizzles[32][4]; diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 5eff743d835..d9c190d35e9 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -357,10 +357,10 @@ clone_tex(clone_state *state, const nir_tex_instr *tex) ntex->is_new_style_shadow = tex->is_new_style_shadow; memcpy(ntex->const_offset, tex->const_offset, sizeof(ntex->const_offset)); ntex->component = tex->component; - ntex->sampler_index = tex->sampler_index; - ntex->sampler_array_size = tex->sampler_array_size; - if (tex->sampler) - ntex->sampler = clone_deref_var(state, tex->sampler, &ntex->instr); + ntex->texture_index = tex->texture_index; + ntex->texture_array_size = tex->texture_array_size; + if (tex->texture) + ntex->texture = clone_deref_var(state, tex->texture, &ntex->instr); return ntex; } diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index d3f939fe805..4489a881905 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -155,10 +155,10 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr) hash = HASH(hash, instr->const_offset); unsigned component = instr->component; hash = HASH(hash, component); - hash = HASH(hash, instr->sampler_index); - hash = HASH(hash, instr->sampler_array_size); + hash = HASH(hash, instr->texture_index); + hash = HASH(hash, instr->texture_array_size); - assert(!instr->sampler); + assert(!instr->texture); return hash; } @@ -305,13 +305,13 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) memcmp(tex1->const_offset, tex2->const_offset, sizeof(tex1->const_offset)) != 0 || tex1->component != tex2->component || - tex1->sampler_index != tex2->sampler_index || - tex1->sampler_array_size != tex2->sampler_array_size) { + tex1->texture_index != tex2->texture_index || + tex1->texture_array_size != tex2->texture_array_size) { return false; } - /* Don't support un-lowered sampler derefs currently. */ - assert(!tex1->sampler && !tex2->sampler); + /* Don't support un-lowered texture derefs currently. */ + assert(!tex1->texture && !tex2->texture); return true; } @@ -421,8 +421,8 @@ instr_can_rewrite(nir_instr *instr) case nir_instr_type_tex: { nir_tex_instr *tex = nir_instr_as_tex(instr); - /* Don't support un-lowered sampler derefs currently. */ - if (tex->sampler) + /* Don't support un-lowered texture derefs currently. */ + if (tex->texture) return false; return true; diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c index 96e82914014..bccb544dc91 100644 --- a/src/compiler/nir/nir_lower_samplers.c +++ b/src/compiler/nir/nir_lower_samplers.c @@ -52,7 +52,7 @@ calc_sampler_offsets(nir_deref *tail, nir_tex_instr *instr, calc_sampler_offsets(tail->child, instr, array_elements, indirect, b, location); - instr->sampler_index += deref_array->base_offset * *array_elements; + instr->texture_index += deref_array->base_offset * *array_elements; if (deref_array->deref_array_type == nir_deref_array_type_indirect) { nir_ssa_def *mul = @@ -91,16 +91,16 @@ static void lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_program, gl_shader_stage stage, nir_builder *builder) { - if (instr->sampler == NULL) + if (instr->texture == NULL) return; - instr->sampler_index = 0; - unsigned location = instr->sampler->var->data.location; + instr->texture_index = 0; + unsigned location = instr->texture->var->data.location; unsigned array_elements = 1; nir_ssa_def *indirect = NULL; builder->cursor = nir_before_instr(&instr->instr); - calc_sampler_offsets(&instr->sampler->deref, instr, &array_elements, + calc_sampler_offsets(&instr->texture->deref, instr, &array_elements, &indirect, builder, &location); if (indirect) { @@ -120,13 +120,13 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr /* Now we can go ahead and move the source over to being a * first-class texture source. */ - instr->src[instr->num_srcs].src_type = nir_tex_src_sampler_offset; + instr->src[instr->num_srcs].src_type = nir_tex_src_texture_offset; instr->num_srcs++; nir_instr_rewrite_src(&instr->instr, &instr->src[instr->num_srcs - 1].src, nir_src_for_ssa(indirect)); - instr->sampler_array_size = array_elements; + instr->texture_array_size = array_elements; } if (location > shader_program->NumUniformStorage - 1 || @@ -135,10 +135,10 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr return; } - instr->sampler_index += + instr->texture_index += shader_program->UniformStorage[location].opaque[stage].index; - instr->sampler = NULL; + instr->texture = NULL; } typedef struct { diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index ae24fb2e16a..4c0759b8788 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -133,7 +133,7 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex) txs = nir_tex_instr_create(b->shader, 1); txs->op = nir_texop_txs; txs->sampler_dim = GLSL_SAMPLER_DIM_RECT; - txs->sampler_index = tex->sampler_index; + txs->texture_index = tex->texture_index; txs->dest_type = nir_type_int; /* only single src, the lod: */ @@ -291,11 +291,11 @@ nir_lower_tex_block(nir_block *block, void *void_state) /* mask of src coords to saturate (clamp): */ unsigned sat_mask = 0; - if ((1 << tex->sampler_index) & state->options->saturate_r) + if ((1 << tex->texture_index) & state->options->saturate_r) sat_mask |= (1 << 2); /* .z */ - if ((1 << tex->sampler_index) & state->options->saturate_t) + if ((1 << tex->texture_index) & state->options->saturate_t) sat_mask |= (1 << 1); /* .y */ - if ((1 << tex->sampler_index) & state->options->saturate_s) + if ((1 << tex->texture_index) & state->options->saturate_s) sat_mask |= (1 << 0); /* .x */ /* If we are clamping any coords, we must lower projector first @@ -317,10 +317,10 @@ nir_lower_tex_block(nir_block *block, void *void_state) state->progress = true; } - if (((1 << tex->sampler_index) & state->options->swizzle_result) && + if (((1 << tex->texture_index) & state->options->swizzle_result) && !nir_tex_instr_is_query(tex) && !(tex->is_shadow && tex->is_new_style_shadow)) { - swizzle_result(b, tex, state->options->swizzles[tex->sampler_index]); + swizzle_result(b, tex, state->options->swizzles[tex->texture_index]); state->progress = true; } } diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c index 28a73f86f95..20b31a8110c 100644 --- a/src/compiler/nir/nir_opt_constant_folding.c +++ b/src/compiler/nir/nir_opt_constant_folding.c @@ -136,8 +136,8 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr *instr) static bool constant_fold_tex_instr(nir_tex_instr *instr) { - if (instr->sampler) - return constant_fold_deref(&instr->instr, instr->sampler); + if (instr->texture) + return constant_fold_deref(&instr->instr, instr->texture); else return false; } diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 4ec32cf48da..5e7ae820968 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -622,8 +622,8 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) case nir_tex_src_ddy: fprintf(fp, "(ddy)"); break; - case nir_tex_src_sampler_offset: - fprintf(fp, "(sampler_offset)"); + case nir_tex_src_texture_offset: + fprintf(fp, "(texture_offset)"); break; default: @@ -652,13 +652,13 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) fprintf(fp, "%u (gather_component), ", instr->component); } - if (instr->sampler) { - print_deref(instr->sampler, state); + if (instr->texture) { + print_deref(instr->texture, state); } else { - fprintf(fp, "%u", instr->sampler_index); + fprintf(fp, "%u", instr->texture_index); } - fprintf(fp, " (sampler)"); + fprintf(fp, " (texture)"); } static void diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c index db754e56b1c..24bae46c7fc 100644 --- a/src/compiler/nir/nir_remove_dead_variables.c +++ b/src/compiler/nir/nir_remove_dead_variables.c @@ -54,8 +54,8 @@ add_var_use_call(nir_call_instr *instr, struct set *live) static void add_var_use_tex(nir_tex_instr *instr, struct set *live) { - if (instr->sampler != NULL) { - nir_variable *var = instr->sampler->var; + if (instr->texture != NULL) { + nir_variable *var = instr->texture->var; _mesa_set_add(live, var); } } diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 920d6102340..2fadff7869e 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -445,8 +445,8 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state) validate_src(&instr->src[i].src, state); } - if (instr->sampler != NULL) - validate_deref_var(instr, instr->sampler, state); + if (instr->texture != NULL) + validate_deref_var(instr, instr->texture, state); validate_dest(&instr->dest, state); } |