diff options
author | Ian Romanick <[email protected]> | 2011-12-22 17:37:26 -0800 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2012-01-03 19:21:19 -0800 |
commit | 4535874c1a6da74d9130e494d514284302e4d08e (patch) | |
tree | 0a339aac202cd0e2cc6f2af258eff702ee42d792 /src | |
parent | 0ed11e333147e280208d9d0b3ff3f39970547643 (diff) |
ff_fragment_shader: Don't generate swizzles for scalar combiner inputs
There are a couple scenarios where the source could be zero and the
operand could be either SRC_ALPHA or ONE_MINUS_SRC_ALPHA. For
example, if the source was ZERO. This would result in something like
(0).w, and a later call to ir_validate would get angry.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/ff_fragment_shader.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 008da0d0e3d..3e736fa1500 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -632,15 +632,19 @@ emit_combine_source(struct texenv_fragment_program *p, new(p->mem_ctx) ir_constant(1.0f), src); - case OPR_SRC_ALPHA: - return new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); + case OPR_SRC_ALPHA: + return src->type->is_scalar() + ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); + + case OPR_ONE_MINUS_SRC_ALPHA: { + ir_rvalue *const scalar = (src->type->is_scalar()) + ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); - case OPR_ONE_MINUS_SRC_ALPHA: return new(p->mem_ctx) ir_expression(ir_binop_sub, new(p->mem_ctx) ir_constant(1.0f), - new(p->mem_ctx) ir_swizzle(src, - 3, 3, - 3, 3, 1)); + scalar); + } + case OPR_ZERO: return new(p->mem_ctx) ir_constant(0.0f); case OPR_ONE: |