aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/opt_cse.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-11-18 09:29:58 +0100
committermarha <marha@users.sourceforge.net>2013-11-18 09:29:58 +0100
commit72ba71645132923bb8e0b93f7683aef8bc485aa2 (patch)
treebaeaeff7e7ce5bf65f056625b435b8d55d4a04fa /mesalib/src/glsl/opt_cse.cpp
parent4d64875593956234795d9947ac1d225e5b110f0f (diff)
parent7c20de6c7fb53ed404d4df0d975328318810ce01 (diff)
downloadvcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.tar.gz
vcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.tar.bz2
vcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.zip
Merge remote-tracking branch 'origin/released'
* origin/released: libXext mesa xkeyboard-config pixman 18 nov 2013 Conflicts: libXext/src/eat.h
Diffstat (limited to 'mesalib/src/glsl/opt_cse.cpp')
-rw-r--r--mesalib/src/glsl/opt_cse.cpp180
1 files changed, 1 insertions, 179 deletions
diff --git a/mesalib/src/glsl/opt_cse.cpp b/mesalib/src/glsl/opt_cse.cpp
index c53b4c6e7..8f73940d8 100644
--- a/mesalib/src/glsl/opt_cse.cpp
+++ b/mesalib/src/glsl/opt_cse.cpp
@@ -243,184 +243,6 @@ is_cse_candidate(ir_rvalue *ir)
return v.ok;
}
-static bool
-equals(ir_rvalue *a, ir_rvalue *b);
-
-static bool
-equals(ir_constant *a, ir_constant *b)
-{
- if (!a || !b)
- return false;
-
- if (a->type != b->type)
- return false;
-
- for (unsigned i = 0; i < a->type->components(); i++) {
- if (a->value.u[i] != b->value.u[i])
- return false;
- }
-
- return true;
-}
-
-static bool
-equals(ir_dereference_variable *a, ir_dereference_variable *b)
-{
- if (!a || !b)
- return false;
-
- return a->var == b->var;
-}
-
-static bool
-equals(ir_dereference_array *a, ir_dereference_array *b)
-{
- if (!a || !b)
- return false;
-
- if (!equals(a->array, b->array))
- return false;
-
- if (!equals(a->array_index, b->array_index))
- return false;
-
- return true;
-}
-
-static bool
-equals(ir_swizzle *a, ir_swizzle *b)
-{
- if (!a || !b)
- return false;
-
- if (a->type != b->type)
- return false;
-
- if (a->mask.x != b->mask.x ||
- a->mask.y != b->mask.y ||
- a->mask.z != b->mask.z ||
- a->mask.w != b->mask.w) {
- return false;
- }
-
- return equals(a->val, b->val);
-}
-
-static bool
-equals(ir_texture *a, ir_texture *b)
-{
- if (!a || !b)
- return false;
-
- if (a->type != b->type)
- return false;
-
- if (a->op != b->op)
- return false;
-
- if (!equals(a->coordinate, b->coordinate))
- return false;
-
- if (!equals(a->projector, b->projector))
- return false;
-
- if (!equals(a->shadow_comparitor, b->shadow_comparitor))
- return false;
-
- if (!equals(a->offset, b->offset))
- return false;
-
- if (!equals(a->sampler, b->sampler))
- return false;
-
- switch (a->op) {
- case ir_tex:
- case ir_lod:
- case ir_query_levels:
- break;
- case ir_txb:
- if (!equals(a->lod_info.bias, b->lod_info.bias))
- return false;
- break;
- case ir_txl:
- case ir_txf:
- case ir_txs:
- if (!equals(a->lod_info.lod, b->lod_info.lod))
- return false;
- break;
- case ir_txd:
- if (!equals(a->lod_info.grad.dPdx, b->lod_info.grad.dPdx) ||
- !equals(a->lod_info.grad.dPdy, b->lod_info.grad.dPdy))
- return false;
- break;
- case ir_txf_ms:
- if (!equals(a->lod_info.sample_index, b->lod_info.sample_index))
- return false;
- break;
- case ir_tg4:
- if (!equals(a->lod_info.component, b->lod_info.component))
- return false;
- break;
- default:
- assert(!"Unrecognized texture op");
- }
-
- return true;
-}
-
-static bool
-equals(ir_expression *a, ir_expression *b)
-{
- if (!a || !b)
- return false;
-
- if (a->type != b->type)
- return false;
-
- if (a->operation != b->operation)
- return false;
-
- for (unsigned i = 0; i < a->get_num_operands(); i++) {
- if (!equals(a->operands[i], b->operands[i]))
- return false;
- }
-
- return true;
-}
-
-static bool
-equals(ir_rvalue *a, ir_rvalue *b)
-{
- if (!a || !b)
- return !a && !b;
-
- if (a->type != b->type)
- return false;
-
- switch (a->ir_type) {
- case ir_type_texture:
- return equals(a->as_texture(), b->as_texture());
-
- case ir_type_constant:
- return equals(a->as_constant(), b->as_constant());
-
- case ir_type_expression:
- return equals(a->as_expression(), b->as_expression());
-
- case ir_type_dereference_variable:
- return equals(a->as_dereference_variable(), b->as_dereference_variable());
-
- case ir_type_dereference_array:
- return equals(a->as_dereference_array(), b->as_dereference_array());
-
- case ir_type_swizzle:
- return equals(a->as_swizzle(), b->as_swizzle());
-
- default:
- return false;
- }
-}
-
/**
* Tries to find and return a reference to a previous computation of a given
* expression.
@@ -441,7 +263,7 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
printf("\n");
}
- if (!equals(rvalue, *entry->val))
+ if (!rvalue->equals(*entry->val))
continue;
if (debug) {