diff options
author | Brian Paul <[email protected]> | 2008-08-04 15:30:32 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-08-04 17:14:49 -0600 |
commit | 50ecc38545ff59e9f99d092eebf555816ee3f7f0 (patch) | |
tree | b8d15a3628bf23d0d41a56f0ba5ee9a7cd7c51a0 /src | |
parent | f70f6e076c9f1a2c06ec433ce93da5913eef457a (diff) |
mesa: glsl: if/while/do condition must be boolean
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 86db53c6ac5..8414f2ebde0 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2050,6 +2050,23 @@ _slang_is_scalar_or_boolean(slang_assemble_ctx *A, slang_operation *oper) /** + * Test if an operation is boolean. + */ +static GLboolean +_slang_is_boolean(slang_assemble_ctx *A, slang_operation *oper) +{ + slang_typeinfo type; + GLboolean isBool; + + slang_typeinfo_construct(&type); + _slang_typeof_operation(A, oper, &type); + isBool = (type.spec.type == SLANG_SPEC_BOOL); + slang_typeinfo_destruct(&type); + return isBool; +} + + +/** * Generate loop code using high-level IR_LOOP instruction */ static slang_ir_node * @@ -2064,7 +2081,7 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper) GLboolean isConst, constTrue; /* type-check expression */ - if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) { + if (!_slang_is_boolean(A, &oper->children[0])) { slang_info_log_error(A->log, "scalar/boolean expression expected for 'while'"); return NULL; } @@ -2127,7 +2144,7 @@ _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper) GLboolean isConst, constTrue; /* type-check expression */ - if (!_slang_is_scalar_or_boolean(A, &oper->children[1])) { + if (!_slang_is_boolean(A, &oper->children[1])) { slang_info_log_error(A->log, "scalar/boolean expression expected for 'do/while'"); return NULL; } @@ -2256,6 +2273,11 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper) GLboolean isConst, constTrue; /* type-check expression */ + if (!_slang_is_boolean(A, &oper->children[0])) { + slang_info_log_error(A->log, "boolean expression expected for 'while'"); + return NULL; + } + if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) { slang_info_log_error(A->log, "scalar/boolean expression expected for 'if'"); return NULL; |