diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-12 10:19:08 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-16 12:11:02 -0800 |
commit | 38e55153af031e48125b1cd0a5d939bb92379ddc (patch) | |
tree | 386166b2f5265da45ca02a12d5034bf3d5cc6aa1 /src/glsl/opt_algebraic.cpp | |
parent | 4f84a3aa32b06c99e65a4bf91452671075f8204c (diff) |
glsl: Refactor is_vec_{zero,one} to be methods of ir_constant
These predicates will be used in other places soon.
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 72 |
1 files changed, 4 insertions, 68 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 2ed66db476..c7f5c3b4d6 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -68,80 +68,16 @@ public: bool progress; }; -static bool +static inline bool is_vec_zero(ir_constant *ir) { - int c; - - if (!ir) - return false; - if (!ir->type->is_scalar() && - !ir->type->is_vector()) - return false; - - for (c = 0; c < ir->type->vector_elements; c++) { - switch (ir->type->base_type) { - case GLSL_TYPE_FLOAT: - if (ir->value.f[c] != 0.0) - return false; - break; - case GLSL_TYPE_INT: - if (ir->value.i[c] != 0) - return false; - break; - case GLSL_TYPE_UINT: - if (ir->value.u[c] != 0) - return false; - break; - case GLSL_TYPE_BOOL: - if (ir->value.b[c] != false) - return false; - break; - default: - assert(!"bad base type"); - return false; - } - } - - return true; + return (ir == NULL) ? false : ir->is_zero(); } -static bool +static inline bool is_vec_one(ir_constant *ir) { - int c; - - if (!ir) - return false; - if (!ir->type->is_scalar() && - !ir->type->is_vector()) - return false; - - for (c = 0; c < ir->type->vector_elements; c++) { - switch (ir->type->base_type) { - case GLSL_TYPE_FLOAT: - if (ir->value.f[c] != 1.0) - return false; - break; - case GLSL_TYPE_INT: - if (ir->value.i[c] != 1) - return false; - break; - case GLSL_TYPE_UINT: - if (ir->value.u[c] != 1) - return false; - break; - case GLSL_TYPE_BOOL: - if (ir->value.b[c] != true) - return false; - break; - default: - assert(!"bad base type"); - return false; - } - } - - return true; + return (ir == NULL) ? false : ir->is_one(); } static void |