summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-02-09 14:51:28 -0800
committerJason Ekstrand <[email protected]>2016-02-10 16:33:50 -0800
commit8750299a420af76cebd3067f6f603eacde06ae06 (patch)
tree9668b5b42f3029de2472090f6e7d9f0e676b8164 /src/compiler/nir
parent70dff4a55e767de8b9ce10f055b94ebb1f6a9755 (diff)
nir: Remove the const_offset from nir_tex_instr
When NIR was originally drafted, there was no easy way to determine if something was constant or not. The result was that we had lots of special-casing for constant values such as this. Now that load_const instructions are SSA-only, it's really easy to find constants and this isn't really needed anymore. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/glsl_to_nir.cpp16
-rw-r--r--src/compiler/nir/nir.h3
-rw-r--r--src/compiler/nir/nir_clone.c1
-rw-r--r--src/compiler/nir/nir_instr_set.c3
-rw-r--r--src/compiler/nir/nir_print.c14
5 files changed, 5 insertions, 32 deletions
diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp
index ee1a0cb9348..a23fba75010 100644
--- a/src/compiler/nir/glsl_to_nir.cpp
+++ b/src/compiler/nir/glsl_to_nir.cpp
@@ -1825,7 +1825,7 @@ nir_visitor::visit(ir_texture *ir)
num_srcs++;
if (ir->shadow_comparitor != NULL)
num_srcs++;
- if (ir->offset != NULL && ir->offset->as_constant() == NULL)
+ if (ir->offset != NULL)
num_srcs++;
nir_tex_instr *instr = nir_tex_instr_create(this->shader, num_srcs);
@@ -1882,16 +1882,10 @@ nir_visitor::visit(ir_texture *ir)
/* we don't support multiple offsets yet */
assert(ir->offset->type->is_vector() || ir->offset->type->is_scalar());
- ir_constant *const_offset = ir->offset->as_constant();
- if (const_offset != NULL) {
- 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].src =
- nir_src_for_ssa(evaluate_rvalue(ir->offset));
- instr->src[src_number].src_type = nir_tex_src_offset;
- src_number++;
- }
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->offset));
+ instr->src[src_number].src_type = nir_tex_src_offset;
+ src_number++;
}
switch (ir->op) {
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 8085341b552..cccb3a41da5 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1010,9 +1010,6 @@ typedef struct {
*/
bool is_new_style_shadow;
- /* constant offset - must be 0 if the offset source is used */
- int const_offset[4];
-
/* gather component selector */
unsigned component : 2;
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index a666d8ee451..b6bb5fe5668 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -355,7 +355,6 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
ntex->is_array = tex->is_array;
ntex->is_shadow = tex->is_shadow;
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->texture_index = tex->texture_index;
diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
index c3cf2579be7..159ded0e72b 100644
--- a/src/compiler/nir/nir_instr_set.c
+++ b/src/compiler/nir/nir_instr_set.c
@@ -152,7 +152,6 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
hash = HASH(hash, instr->is_array);
hash = HASH(hash, instr->is_shadow);
hash = HASH(hash, instr->is_new_style_shadow);
- hash = HASH(hash, instr->const_offset);
unsigned component = instr->component;
hash = HASH(hash, component);
hash = HASH(hash, instr->texture_index);
@@ -303,8 +302,6 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
tex1->is_array != tex2->is_array ||
tex1->is_shadow != tex2->is_shadow ||
tex1->is_new_style_shadow != tex2->is_new_style_shadow ||
- memcmp(tex1->const_offset, tex2->const_offset,
- sizeof(tex1->const_offset)) != 0 ||
tex1->component != tex2->component ||
tex1->texture_index != tex2->texture_index ||
tex1->texture_array_size != tex2->texture_array_size ||
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index d9d75c2e8df..8ccaf8a0edb 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -637,20 +637,6 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
fprintf(fp, ", ");
}
- bool has_nonzero_offset = false;
- for (unsigned i = 0; i < 4; i++) {
- if (instr->const_offset[i] != 0) {
- has_nonzero_offset = true;
- break;
- }
- }
-
- if (has_nonzero_offset) {
- fprintf(fp, "[%i %i %i %i] (offset), ",
- instr->const_offset[0], instr->const_offset[1],
- instr->const_offset[2], instr->const_offset[3]);
- }
-
if (instr->op == nir_texop_tg4) {
fprintf(fp, "%u (gather_component), ", instr->component);
}