OSDN Git Service

i965/fs: Apply gl_FrontFacing ? -1 : 1 optimization only for floats
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 28 Feb 2015 16:32:57 +0000 (08:32 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 17 Mar 2015 22:01:44 +0000 (15:01 -0700)
At the very least, unreal4/sun-temple/102.shader_test uses this pattern
for a signed integer result.  However, that shader did not hit the
optimization in the first place because it uses !gl_FrontFacing.  I
changed the shader to use remove the logical-not and reverse the other
operands.  I verified that incorrect code is generated before this
change and correct code is generated after.

Fixes fs-frontfacing-ternary-1-neg-1.shader_test.

No shader-db changes.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index 91dd212..6d56115 100644 (file)
@@ -2735,6 +2735,9 @@ fs_visitor::try_opt_frontfacing_ternary(ir_if *ir)
    if (!then_rhs || !else_rhs)
       return false;
 
+   if (then_rhs->type->base_type != GLSL_TYPE_FLOAT)
+      return false;
+
    if ((then_rhs->is_one() && else_rhs->is_negative_one()) ||
        (else_rhs->is_one() && then_rhs->is_negative_one())) {
       then_assign->lhs->accept(this);